Skip to content

Commit 00141d8

Browse files
authored
The initial-value descriptor when registering Custom Properties can be optional (#56519)
This is manual export of bugzilla fix - https://commits.webkit.org/303757@main
1 parent a7709c0 commit 00141d8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Properties and Values API: optional initial-value descriptor</title>
4+
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#initial-value-descriptor">
5+
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/9078">
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<style>
9+
@property --registered {
10+
syntax: '*';
11+
initial-value: ;
12+
inherits: false;
13+
}
14+
#target {
15+
--test-bg: var(--registered) green;
16+
--test-fallback: var(--registered, red);
17+
background-color: var(--test-bg, var(--test-fallback));
18+
}
19+
</style>
20+
<div id="target"></div>
21+
<script>
22+
test(function() {
23+
const target = document.getElementById('target');
24+
const style = getComputedStyle(target);
25+
26+
// When initial-value is omitted (empty space), the property should be registered
27+
// with a space character as the initial value, making var(--registered) green
28+
// evaluate to " green" which is a valid color value.
29+
assert_equals(style.backgroundColor, 'rgb(0, 128, 0)',
30+
'background-color should be green when @property has empty initial-value');
31+
}, '@property with empty initial-value should use space character');
32+
</script>

0 commit comments

Comments
 (0)