Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<meta charset="utf-8">
<title>adoptedStyleSheets adopt link tag</title>
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<style id="styleSheet">
div {
background-color: green !important;
}
</style>
<my-element id="host"></my-element>
<script>
customElements.define('my-element', class extends HTMLElement {
connectedCallback() {
this.attachShadow({mode:'open'}).append(document.createElement('div'));
const sheet = new CSSStyleSheet();
sheet.replaceSync(`
div {
display: block;
width: 100px;
height: 100px;
background: red;
}
`);
this.shadowRoot.adoptedStyleSheets = [sheet, styleSheet.sheet];
}
});
</script>