ladybird/Tests/LibWeb/Text/input/selection-collapseToEnd.html
Jelle Raaijmakers 2052792663 LibWeb: Use correct boundaries in Selection::collapse_to_start/end()
We were using the anchor_node() as the boundary point node when
collapsing a selection, but the spec tells us to use the start and end
boundary point nodes.
2024-12-21 19:15:58 +01:00

29 lines
736 B
HTML

<script src="include.js"></script>
<div>
Well
<ul>
<li>Hello</li>
<li>Friends</li>
<li>!</li>
</ul>
</div>
<script>
test(() => {
const anchor = document.querySelector('div');
const range = document.createRange();
range.setStart(anchor, 0);
range.setEnd(anchor.childNodes[1], 3);
getSelection().addRange(range);
const printRange = () => {
let activeRange = getSelection().getRangeAt(0);
println(`${activeRange.startContainer} ${activeRange.startOffset} ${activeRange.endContainer} ${activeRange.endOffset}`);
};
printRange();
getSelection().collapseToEnd();
printRange();
})
</script>