anchor-scope-shadow-all.html (1452B)
1 <!DOCTYPE html> 2 <title>CSS Anchor Positioning: anchor-scope:all is tree-scoped</title> 3 <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-scope"> 4 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10525"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <style> 8 #host::part(scope) { 9 /* This should have no effect, because 'all' is tree-scoped, 10 and specified in a different tree-scope than the anchor names 11 in the shadow. */ 12 anchor-scope: all; 13 } 14 </style> 15 <div id=host> 16 <template shadowrootmode=open> 17 <style> 18 .anchored { 19 background: coral; 20 position: absolute; 21 top: anchor(bottom, 1px); 22 position-anchor: --a; 23 width: 5px; 24 height: 5px; 25 } 26 .anchor { 27 background: skyblue; 28 height: 10px; 29 anchor-name: --a; 30 } 31 .cb { 32 position: relative; 33 width: 200px; 34 height: 200px; 35 border: 1px solid black; 36 } 37 .scope { 38 anchor-scope: --a; 39 } 40 </style> 41 <div class=cb> 42 <div class=anchor></div> 43 <div part=scope> 44 <div class=anchored></div> 45 </div> 46 </div> 47 </template> 48 </div> 49 <script> 50 test((t) => { 51 let e = host.shadowRoot.querySelector('.anchored'); 52 assert_equals(getComputedStyle(e).top, '10px'); 53 }, 'anchor-scope:all is tree-scoped'); 54 </script>