at-property-optional-initial-value.html (1265B)
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>