revert-rule-basic.tentative.html (1890B)
1 <!DOCTYPE html> 2 <title>The revert-rule keyword: basic behavior</title> 3 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10443"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <style> 8 #test1 { 9 color: green; 10 } 11 #test1 { 12 color: red; 13 color: revert-rule; 14 } 15 </style> 16 <div id=test1></div> 17 <script> 18 test(() => { 19 assert_true(CSS.supports('color:revert-rule')); 20 assert_equals(getComputedStyle(test1).color, 'rgb(0, 128, 0)') 21 }, 'The revert-rule keyword rolls back to the previous rule'); 22 </script> 23 24 25 <style> 26 #test2 { /* Specificity: (0, 0, 1) */ 27 color: red; 28 } 29 #test2#test2#test2 { /* Specificity: (0, 0, 3) */ 30 color: red; 31 color: revert-rule; 32 } 33 #test2#test2 { /* Specificity: (0, 0, 2) */ 34 color: green; 35 } 36 </style> 37 <div id=test2></div> 38 <script> 39 test(() => { 40 assert_true(CSS.supports('color:revert-rule')); 41 assert_equals(getComputedStyle(test2).color, 'rgb(0, 128, 0)') 42 }, 'Cascade order determines the previous rule, not order of appearance'); 43 </script> 44 45 46 <style> 47 #test3 { 48 color: red; 49 } 50 #test3 { 51 color: green; 52 } 53 </style> 54 <div id=test3 style="color:red; color:revert-rule"></div> 55 <script> 56 test(() => { 57 assert_true(CSS.supports('color:revert-rule')); 58 assert_equals(getComputedStyle(test3).color, 'rgb(0, 128, 0)') 59 }, 'Reverting from style attribute reverts to regular rules'); 60 </script> 61 62 63 <style> 64 #test4 { z-index: 1; } 65 #test4 { z-index: 2; } 66 #test4 { z-index: -1; z-index: revert-rule; } 67 #test4 { z-index: -1; z-index: revert-rule; } 68 #test4 { z-index: -1; z-index: revert-rule; } 69 </style> 70 <div id=test4></div> 71 <script> 72 test(() => { 73 assert_true(CSS.supports('z-index:revert-rule')); 74 assert_equals(getComputedStyle(test4).zIndex, '2') 75 }, 'A chain of revert-rule works'); 76 </script>