Skip to content

Truly independent web browser

890 B
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<svg width="400" height="100">
    <text id="changed" y="50" style="text-transform: uppercase">abc</text>
    <text id="reference" y="80">ABCD</text>
</svg>
<script>
    // SVG shapes a text node's characters with text-transform applied, but with its own white space processing, so it
    // keeps a copy of them apart from the rendered text. A change to the source must reach that copy too.
    test(() => {
        const changed = document.getElementById("changed");
        const reference = document.getElementById("reference");
        const width = element => element.getBoundingClientRect().width;
        println(`differs before the change: ${width(changed) !== width(reference)}`);
        changed.firstChild.data = "abcd";
        println(`matches after the change: ${width(changed) === width(reference)}`);
    });
</script>