Skip to content

Truly independent web browser

1.2 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
    #root { --theme: red; }
    .scope { --gap: 4px; }
    .reader { color: var(--theme); }
</style>
<div id="root">
    <div class="scope"><span></span><span></span><span></span><span></span><span class="reader"></span></div>
    <div class="scope"><span></span><span></span><span></span><span></span><span class="reader"></span></div>
</div>
<script>
    // An element declaring custom properties of its own that reads none keeps its declared values
    // over the moved environment: the move computes only the elements that read the moved name.
    test(() => {
        internals.updateStyle();
        document.body.offsetWidth;
        const root = document.getElementById("root");
        root.style.setProperty("--theme", "blue");
        internals.updateStyle();
        for (const reader of document.querySelectorAll(".reader"))
            println(`reader: ${getComputedStyle(reader).color}`);
        for (const scope of document.querySelectorAll(".scope"))
            println(`scope: ${getComputedStyle(scope).getPropertyValue("--theme")} ${getComputedStyle(scope).getPropertyValue("--gap")}`);
    });
</script>