shadow-reassign-dynamic-002.html (847B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Scoping: Dynamic reassignment of a slot.</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 5 <link rel="help" href="https://drafts.csswg.org/css-scoping/#selectors-data-model"> 6 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1465572"> 7 <link rel="match" href="reference/green-box.html"/> 8 <div id="host"> 9 FAIL 10 <div style="background: green" slot="the-slot"></div> 11 </div> 12 <script> 13 document.body.offsetTop; 14 host.attachShadow({ mode: "open" }).innerHTML = ` 15 <style>::slotted(div) { width: 100px; height: 100px }</style> 16 <p>Test passes if you see a single 100px by 100px green box below.</p> 17 <slot>FAIL</slot> 18 `; 19 document.body.offsetTop; 20 host.shadowRoot.querySelector("slot").setAttribute("name", "the-slot"); 21 </script>