Files
ladybird/Tests/LibWeb/Text/input/Editing/execCommand-forwardDelete.html
Jelle Raaijmakers b9da7baac4 LibWeb: Extend logic for extraneous line breaks in block elements
While editing, we need to consider whether removing a <br> has any
effect on layout to determine whether its extraneous. This new condition
finds most cases for extraneous <br>s inside block elements.
2025-09-16 06:57:30 -04:00

40 lines
1.7 KiB
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>a&nbsp;&nbsp;&nbsp;</div>
<div id="c" contenteditable>a&nbsp;&nbsp;b</div>
<div id="d" contenteditable>a&nbsp;&nbsp;&nbsp;b</div>
<div id="e" contenteditable>a&nbsp;&nbsp;&nbsp;&nbsp;b</div>
<div id="f" contenteditable>a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b</div>
<div id="g" contenteditable>&nbsp;&nbsp;b</div>
<div id="h" contenteditable>foo👩🏼👨🏻bar</div>
<div id="i" contenteditable>foo<div>bar<br>baz</div></div>
<script>
test(() => {
const testForwardDelete = function(divId, anchorExpression, start, end = start) {
println(`--- ${divId} ---`);
const divElm = document.querySelector(`div#${divId}`);
println(`Before: ${divElm.innerHTML}`);
// Place cursor
const anchor = anchorExpression(divElm);
getSelection().setBaseAndExtent(anchor, start, anchor, end);
// Press delete
document.execCommand("forwardDelete");
println(`After: ${divElm.innerHTML}`);
};
testForwardDelete("a", (node) => node.firstChild, 3);
testForwardDelete("b", (node) => node.firstChild, 1);
testForwardDelete("c", (node) => node.firstChild, 1);
testForwardDelete("d", (node) => node.firstChild, 1);
testForwardDelete("e", (node) => node.firstChild, 1);
testForwardDelete("f", (node) => node.firstChild, 1);
testForwardDelete("g", (node) => node.firstChild, 0);
testForwardDelete("h", (node) => node.firstChild, 3);
testForwardDelete("i", (node) => node.firstChild, 3);
});
</script>