Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /selection/collapse-common-ancestor-2.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Selecting a subtree after collapsing into the previous closest common inclusive ancestor</title>
<link rel="match" href="collapse-common-ancestor-ref.html">
<meta name="assert" content="Collapsing into the node the selection was registered on must not leave stale marks that keep the subtree from being selected again.">
<div id="outer">before<div id="inner"><span>AAA</span><span>BBB</span></div>after</div>
<script>
// Make |outer| the closest common inclusive ancestor.
getSelection().setBaseAndExtent(outer.firstChild, 0, outer.lastChild,
outer.lastChild.length);
document.body.offsetWidth;
// Collapse into |outer| itself, which neither drops nor recomputes its marks.
getSelection().collapse(outer, 1);
document.body.offsetWidth;
getSelection().setBaseAndExtent(outer.firstChild, 0, outer.lastChild,
outer.lastChild.length);
</script>