sibling-combinators-on-anon-content-2-shadow.xhtml (1044B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait"> 3 <head> 4 </head> 5 <body> 6 <template id="template"> 7 <style> 8 .a:empty + .b { color: green; } 9 </style> 10 <span class="a">Some text</span> 11 <span class="b">This should be green</span> 12 <slot/> 13 </template> 14 <custom-element id="foo"></custom-element> 15 <script> 16 customElements.define("custom-element", class extends HTMLElement { 17 constructor() { 18 super(); 19 const template = document.getElementById("template"); 20 const shadowRoot = this.attachShadow({mode: "open"}) 21 .appendChild(template.content.cloneNode(true)); 22 } 23 24 nixText() { 25 this.shadowRoot.children[1].textContent = ""; 26 } 27 }); 28 window.onload = function() { 29 var el = document.getElementById("foo"); 30 // Flush its layout 31 el.offsetWidth; 32 el.nixText(); 33 document.documentElement.className = ""; 34 } 35 </script> 36 </body> 37 </html>