sibling-combinators-on-anon-content-1-shadow.xhtml (706B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <script> 5 customElements.define("custom-element", class extends HTMLElement { 6 constructor() { 7 super(); 8 const template = document.getElementById("template"); 9 const shadowRoot = this.attachShadow({mode: "open"}) 10 .appendChild(template.content.cloneNode(true)); 11 } 12 }); 13 </script> 14 </head> 15 <body> 16 <template id="template"> 17 <style> 18 .a + .b { color: green; } 19 </style> 20 <span class="a"></span> 21 <span class="b">This should be green</span> 22 <slot/> 23 </template> 24 <custom-element id="foo"></custom-element> 25 </body> 26 </html>