ladybird/Tests/LibWeb/Text/input/Editing/execCommand-delete.html
Jelle Raaijmakers 8986e1f1ec LibWeb: Merge nested editing hosts
If a node with `contenteditable=true/plaintextonly` is the child of an
editable node or an editing host, we should make it editable instead of
an editing host. This effectively merges nested editing hosts together,
which is how other browsers deal with this as well.

Gains us 5 WPT subtest passes in `editing`.
2025-09-04 00:24:55 +02:00

27 lines
993 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<script src="../include.js"></script>
<div id="a" contenteditable>foobar</div>
<div id="b" contenteditable>foo👩🏼👨🏻bar</div>
<div id="c" contenteditable>foo<div contenteditable>bar</div></div>
<script>
test(() => {
const testDelete = function (divId, anchorExpression, position) {
println(`--- ${divId} ---`);
const divElm = document.querySelector(`div#${divId}`);
println(`Before: ${divElm.innerHTML}`);
// Place cursor
const anchor = anchorExpression(divElm);
getSelection().setBaseAndExtent(anchor, position, anchor, position);
// Press backspace
document.execCommand("delete");
println(`After: ${divElm.innerHTML}`);
};
testDelete("a", (node) => node.firstChild, 3);
testDelete("b", (node) => node.firstChild, 15);
testDelete("c", (node) => node.childNodes[1].firstChild, 0);
});
</script>