mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 10:20:22 +00:00
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`.
27 lines
993 B
HTML
27 lines
993 B
HTML
<!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>
|