Skip to content

Truly independent web browser

1.1 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>#host.active { color: green; }</style>
<div id="host"></div>
<script>
    test(() => {
        const shadowRoot = host.attachShadow({ mode: "open" });
        shadowRoot.innerHTML = `
            <style>
                #target:checked + #reaction { color: green; }
                :host(.active) #reaction { background-color: blue; }
            </style>
            <input id="target" type="checkbox">
            <span id="reaction"></span>
        `;
        const target = shadowRoot.getElementById("target");
        const reaction = shadowRoot.getElementById("reaction");
        internals.updateStyle();

        target.checked = true;
        getComputedStyle(target).color;

        println(`reaction color: ${getComputedStyle(reaction).color}`);

        internals.updateStyle();
        host.className = "active";
        getComputedStyle(host).color;

        println(`cross-scope color: ${getComputedStyle(reaction).color}`);
        println(`cross-scope background: ${getComputedStyle(reaction).backgroundColor}`);
    });
</script>