whitespace-crash-001.html (1184B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Scoping: Dynamic shadow root creation and whitespace optimization crash.</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 <p>Test passes if you see a single 100px by 100px green box below.</p> 9 <!-- 10 It's important for the test-case that there's whitespace inside the host, 11 and that it's not assigned to any slot. 12 --> 13 <div id="host"> 14 <div style="display: inline" slot="the-slot"></div> 15 </div> 16 <script> 17 // Flush layout before creating a ShadowRoot, so that the whitespace ends up 18 // suppressed. 19 document.body.offsetTop; 20 host.attachShadow({ mode: "open" }).innerHTML = ` 21 <style> 22 ::slotted(div) { 23 width: 100px; 24 height: 100px; 25 background: green; 26 } 27 </style> 28 <slot name="the-slot"></slot> 29 `; 30 document.body.offsetTop; 31 host.firstElementChild.style.display = "block"; // or anything else that reframes the <div>. 32 </script>