fix: adopted stylesheets (#2785)

This commit is contained in:
Niklas von Hertzen
2022-01-01 01:57:17 +08:00
committed by GitHub
parent 1cc853a318
commit 74696faf47
4 changed files with 57 additions and 15 deletions

View File

@@ -40,6 +40,10 @@ class AutonomousCustomElement extends HTMLElement {
wrapper.appendChild(img);
wrapper.appendChild(info);
}
connectedCallback() {
this.shadowRoot.adoptedStyleSheets = [sheet];
}
}
customElements.define('autonomous-custom-element', AutonomousCustomElement);

View File

@@ -3,10 +3,11 @@
<head>
<title>Web components tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
const sheet = new CSSStyleSheet();
sheet.replaceSync('* { color: red !important; }')
</script>
<script type="text/javascript" src="../../test.js"></script>
<style>
</style>
</head>
<body>
<div>