Skip to content

Truly independent web browser

868 B
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<div id="host"></div>
<script>
    test(() => {
        // The host's own shadow tree weighs its :host rules in the context their priority names,
        // for the host and its pseudo-elements alike.
        const host = document.getElementById("host");
        host.attachShadow({ mode: "open" }).innerHTML = `
            <style>
                :host { color: rgb(0, 0, 255); }
                :host::before { content: "before"; }
                :host(.on)::before { color: rgb(0, 128, 0); }
            </style>`;
        internals.updateStyle();
        host.className = "on";
        internals.updateStyle();
        println(`host: ${getComputedStyle(host).color}`);
        println(`before: ${getComputedStyle(host, "::before").content} ${getComputedStyle(host, "::before").color}`);
    });
</script>