Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
@keyframes fade {
from { opacity: 0.5; }
to { opacity: 0.5; }
}
</style>
<div id="host"><span id="slotted">slotted</span></div>
<script>
test(() => {
const host = document.getElementById("host");
const slotted = document.getElementById("slotted");
const shadowRoot = host.attachShadow({ mode: "open" });
const sharedSheet = new CSSStyleSheet();
sharedSheet.replaceSync(`
#slotted {
animation-name: fade;
animation-duration: 1s;
animation-fill-mode: both;
}
`);
const shadowKeyframesSheet = new CSSStyleSheet();
shadowKeyframesSheet.replaceSync(`
@keyframes fade {
from { opacity: 0.25; }
to { opacity: 0.25; }
}
`);
document.adoptedStyleSheets = [sharedSheet];
shadowRoot.innerHTML = "<slot></slot>";
shadowRoot.adoptedStyleSheets = [sharedSheet, shadowKeyframesSheet];
println(`opacity: ${getComputedStyle(slotted).opacity}`);
});
</script>