-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-variables] Custom props with invalid var() should behave as 'unset'
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a
- Loading branch information
1 parent
6a665f6
commit 9ce2c0e
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
css/css-variables/variables-substitute-guaranteed-invalid.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<title>Testing substitution of guaranteed-invalid values</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-variables/#guaranteed-invalid"> | ||
<link rel="help" href="https://drafts.csswg.org/css-variables/#cycles"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
#target1 { | ||
/* Cycle */ | ||
--var1: var(--var2); | ||
--var2: var(--var1); | ||
|
||
/* Reference to cycle */ | ||
--var3: var(--var1); | ||
|
||
/* Reference to non-existent property */ | ||
--var4: var(--noexist); | ||
} | ||
|
||
#target1parent { | ||
--var3: inherited; | ||
--var4: inherited; | ||
} | ||
</style> | ||
<div id="target1parent"> | ||
<div id="target1"></div> | ||
</div> | ||
<script> | ||
test( function () { | ||
let cs = getComputedStyle(target1); | ||
assert_equals(cs.getPropertyValue('--var1'), ''); | ||
assert_equals(cs.getPropertyValue('--var2'), ''); | ||
}, 'Custom properties in a cycle are guaranteed-invalid'); | ||
|
||
test( function () { | ||
let cs = getComputedStyle(target1); | ||
assert_equals(cs.getPropertyValue('--var3'), ' inherited'); | ||
}, 'A custom property referencing a cycle is treated as unset'); | ||
|
||
test( function () { | ||
let cs = getComputedStyle(target1); | ||
assert_equals(cs.getPropertyValue('--var4'), ' inherited'); | ||
}, 'A custom property referencing a non-existent variable is treated as unset'); | ||
</script> |