Skip to content

Commit

Permalink
Don't allow Selection in nodes not in the document;
Browse files Browse the repository at this point in the history
This matches the spec and Chrome, and seems to bring us closer to Edge
and WebKit as well.  It also matches our own behavior for addRange(),
which was changed in bug 1341137.

For collapse and selectAllChildren, we match the tests and browsers, but
the spec is incorrect at the time of this writing:
w3c/selection-api#86

The removeAllRanges test hadn't been updated for the spec change.

MozReview-Commit-ID: DTK8283k5IP

Upstreamed from https://bugzilla.mozilla.org/show_bug.cgi?id=1359397 [ci skip]
  • Loading branch information
ayg authored and jgraham committed Aug 31, 2017
1 parent 1ef4ab4 commit bc06911
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions selection/removeAllRanges.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
var range = rangeFromEndpoints([paras[0].firstChild, 0, paras[0].firstChild, 1]);

function testRange(rangeDesc, method) {
var endpoints = eval(testRanges[i]);
if (endpoints.length && (!isSelectableNode(endpoints[0]) ||
!isSelectableNode(endpoints[2]))) {
return;
}
test(function() {
setSelectionForwards(eval(rangeDesc));
setSelectionForwards(endpoints);
selection[method]();
assert_equals(selection.rangeCount, 0,
"After " + method + "(), rangeCount must be 0");
Expand All @@ -28,7 +33,7 @@

// Copy-pasted from above
test(function() {
setSelectionBackwards(eval(rangeDesc));
setSelectionBackwards(endpoints);
selection[method]();
assert_equals(selection.rangeCount, 0,
"After " + method + "(), rangeCount must be 0");
Expand Down

0 comments on commit bc06911

Please sign in to comment.