var-reference-registered-properties-002.html (1130B)
1 <!DOCTYPE HTML> 2 <link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" /> 3 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1899272"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id=element></div> 7 <script> 8 test(function() { 9 CSS.registerProperty({ 10 name: '--length-calc', 11 syntax: '<length>', 12 initialValue: '0px', 13 inherits: true 14 }); 15 CSS.registerProperty({ 16 name: '--length-calc-reset', 17 syntax: '<length>', 18 initialValue: '0px', 19 inherits: false 20 }); 21 let element = document.getElementById("element"); 22 element.style = 'font-size: 11px; --length-calc: calc(10em + 10px); --unregistered:var(--length-calc-reset); --length-calc-reset: var(--length-calc)'; 23 let cs = getComputedStyle(element); 24 for (let prop of ["--length-calc", "--length-calc-reset", "--unregistered"]) { 25 assert_equals(cs.getPropertyValue(prop), "120px", "Should resolve properly: " + prop); 26 } 27 }, "Property dependency tracking across inherited and non-inherited properties"); 28 </script>