Skip to content

Truly independent web browser

1009 B
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="../../work-test.js"></script>
<div id="host" tabindex="0"></div>
<script>
    test(() => {
        const host = document.getElementById("host");
        const shadowRoot = host.attachShadow({ mode: "open" });
        shadowRoot.innerHTML = "<style>:host(:focus) { color: green }</style><span id=child></span>";

        // `:host()` is a guard on the host, not a combinator: it styles the element it tests. A
        // change to what it tests reaches that element, and the tree it hosts only through what
        // that tree inherits from it.
        const work = styleWork(() => host.focus({ preventScroll: true }));
        println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);
        println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);
        println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);
    });
</script>