Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collapse() now has an optional argument and detach() is a no-op #243

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions dom/ranges/Range-collapse.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
var range;
if (rangeEndpoints == "detached") {
range = document.createRange();
range.detach();
assert_throws("INVALID_STATE_ERR", function() {
range.collapse(toStart);
}, "Detached Range must throw INVALID_STATE_ERR on .collapse()");
assert_throws("INVALID_STATE_ERR", function() {
range.collapsed;
}, "Detached Range must throw INVALID_STATE_ERR on .collapsed access");
return;
range.detach(); // should be a no-op and therefore the following should not throw
range.collapse(toStart);
assert_equals(true, range.collapsed);
}

// Have to account for Ranges involving Documents!
Expand All @@ -37,7 +32,10 @@
&& range.startOffset == range.endOffset,
"collapsed must be true if and only if the start and end are equal");

range.collapse(toStart);
if(undefined == toStart)
range.collapse()
else
range.collapse(toStart);

assert_equals(range.startContainer, expectedContainer,
"Wrong startContainer");
Expand Down Expand Up @@ -128,6 +126,11 @@
eval(ranges[i]),
false
]);
tests.push([
"Range " + i + " " + ranges[i] + ", toStart omitted",
eval(ranges[i]),
undefined
]);
}
generate_tests(testCollapse, tests);

Expand Down