Skip to content

Truly independent web browser

985 B
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="a" contenteditable><p><span style="white-space: break-spaces">a </span> b</p></div>
<div id="b" contenteditable><p><span style="white-space: pre-wrap">a </span> b</p></div>
<div id="c" contenteditable><p><span>a </span> b</p></div>
<script>
    test(() => {
        for (const id of ["a", "b", "c"]) {
            const editingHost = document.getElementById(id);
            println(`Before: ${JSON.stringify(editingHost.innerHTML)}`);

            // Put the cursor after the leading space of " b", which follows a space at the end of the span, and press
            // backspace. The leading space is rendered only if the span preserves its trailing space.
            const text = editingHost.querySelector("span").nextSibling;
            getSelection().collapse(text, 1);
            document.execCommand("delete");

            println(`After: ${JSON.stringify(editingHost.innerHTML)}`);
        }
    });
</script>