adoptedstylesheets-adopt-style-subresource.tentative.html (874B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>adoptedStyleSheets adopt link tag</title> 4 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10013"> 5 <link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html"> 6 <p>Test passes if there is a filled green square.</p> 7 <style id="styleSheet"> 8 @import url("./resources/adoptedstylesheet-adopt-link.css"); 9 </style> 10 <my-element id="host"></my-element> 11 <script> 12 customElements.define('my-element', class extends HTMLElement { 13 connectedCallback() { 14 this.attachShadow({mode:'open'}).append(document.createElement('div')); 15 const sheet = new CSSStyleSheet(); 16 sheet.replaceSync(` 17 div { 18 display: block; 19 width: 100px; 20 height: 100px; 21 background: red; 22 } 23 `); 24 this.shadowRoot.adoptedStyleSheets = [sheet, styleSheet.sheet]; 25 } 26 }); 27 </script>