scope-cssom.html (1975B)
1 <!DOCTYPE html> 2 <title>@scope - CSSOM</title> 3 <link rel="help" href="https://drafts.csswg.org/css-cascade-6/#the-cssscoperule-interface"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <style id=style> 7 @scope {} 8 @scope (.a) {} 9 @scope (.a) to (.b) { 10 div { 11 display: block; 12 } 13 } 14 @scope to (.b) {} 15 </style> 16 <script> 17 18 // CSSScopeRule.cssText 19 test(() => { 20 assert_equals(style.sheet.rules[0].cssText, '@scope {\n}'); 21 }, 'CSSScopeRule.cssText, implicit scope'); 22 23 test(() => { 24 assert_equals(style.sheet.rules[1].cssText, '@scope (.a) {\n}'); 25 }, 'CSSScopeRule.cssText, root only'); 26 27 test(() => { 28 assert_equals(style.sheet.rules[2].cssText, '@scope (.a) to (.b) {\n div { display: block; }\n}'); 29 }, 'CSSScopeRule.cssText, root and limit'); 30 31 test(() => { 32 assert_equals(style.sheet.rules[3].cssText, '@scope to (.b) {\n}'); 33 }, 'CSSScopeRule.cssText, limit only'); 34 35 // start 36 test(() => { 37 assert_equals(style.sheet.rules[0].start, null); 38 }, 'CSSScopeRule.start, implicit scope'); 39 40 test(() => { 41 assert_equals(style.sheet.rules[1].start, '.a'); 42 }, 'CSSScopeRule.start, root only'); 43 44 test(() => { 45 assert_equals(style.sheet.rules[2].start, '.a'); 46 }, 'CSSScopeRule.start, root and limit'); 47 48 test(() => { 49 assert_equals(style.sheet.rules[3].start, null); 50 }, 'CSSScopeRule.start, limit only'); 51 52 // end 53 test(() => { 54 assert_equals(style.sheet.rules[0].end, null); 55 }, 'CSSScopeRule.end, implicit scope'); 56 57 test(() => { 58 assert_equals(style.sheet.rules[1].end, null); 59 }, 'CSSScopeRule.end, root only'); 60 61 test(() => { 62 assert_equals(style.sheet.rules[2].end, '.b'); 63 }, 'CSSScopeRule.end, root and limit'); 64 65 test(() => { 66 assert_equals(style.sheet.rules[3].end, '.b'); 67 }, 'CSSScopeRule.end, limit only'); 68 69 test(() => { 70 assert_true(style.sheet.rules[0] instanceof CSSGroupingRule); 71 assert_false(style.sheet.rules[0] instanceof CSSConditionRule); 72 }, 'CSSScopeRule is a CSSGroupingRule'); 73 </script>