Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<title id="desc">HTML5 Selection: Remove the element containing the selection</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
function RunTest()
{
var selection = window.getSelection();
var div1 = document.getElementById("div1");
var span1 = document.getElementById("span1");
var range = document.createRange();
range.selectNode(span1);
selection.addRange(range);
assert_equals(selection.toString(), span1.textContent);
document.body.removeChild(div1);
assert_equals(selection.toString(), "");
}
</script>
</head>
<body onload="test(RunTest);">
<div id="div1">some text
<span id="span1">aaaaaaaa</span>
</div>
<div id="div2">Remove the element containing the selection</div>
</body>
</html>