Skip to content

Truly independent web browser

1018 B
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<div id="container">
    <svg width="100" height="100">
        <rect id="first" x="1" y="1" width="10" height="10" fill="red"></rect>
        <rect id="second" x="20" y="1" width="10" height="10" fill="blue"></rect>
    </svg>
</div>
<script>
    test(() => {
        internals.updateStyle();

        // Hiding the subtree recomputes its SVG styles. Changing the root font size drops the
        // style sharing cache, so rebuilding on reappearance must still preserve each rect's
        // own presentation attributes.
        container.style.display = "none";
        internals.updateStyle();
        document.documentElement.style.fontSize = "17px";
        internals.updateStyle();

        container.style.display = "block";
        internals.updateStyle();

        for (const rect of [first, second]) {
            const style = getComputedStyle(rect);
            println(`${rect.id}: x ${style.x}, fill ${style.fill}`);
        }
    });
</script>