mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-14 15:13:07 +00:00
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.
29 lines
736 B
HTML
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>
|