-
Notifications
You must be signed in to change notification settings - Fork 30
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
Throw correct exceptions from collapse/selectAllChildren on detached doctypes #86
base: gh-pages
Are you sure you want to change the base?
Conversation
…doctypes According to the previous spec, trying to collapse to or select a doctype that is not in the current document would not throw. But Chrome, Firefox, and Edge all do throw. (WebKit doesn't seem to throw for doctypes at all.) The wpt test also tests that browsers do throw in this case.
2a053cc
to
d9b03f9
Compare
Updated to reflect the fact that this affects collapse() too. |
@masayuki-nakano points out that this introduces an inconsistency with extend() and setBaseAndExtent(), which do not throw in this case in Chrome. I think we should throw in all cases, because it matches the current behavior of Edge and Firefox and probably the old behavior of Chrome. |
I wrote a test case:
So in most cases three out of four throw, and in the rest it's 50/50, so I think we should just throw in all cases here. |
I should add that usually when browsers disagree, we have a strong preference for not throwing, but I think maybe this is different because half of the not-throwing behavior is due to the fact that WebKit doesn't ever throw when setting a range endpoint to a doctype. This is clearly not required by web compatibility. If you leave out WebKit from the doctype cases, behavior is 100% in favor of throwing in most cases. But on second thought, it's always easier not to throw, so maybe the spec should say never to throw. @rniwa, what do you think? This issue blocks Mozilla's implementation, which I guess therefore won't get done until August. |
I can be convinced about throwing for doctype but I don't think we'd like to change the behavior for out-of-range index since we've seen web contents and App-specific web content that do use such index and expect WebKit to do the "right thing". |
@rniwa By out-of-range index you mean for setBaseAndExtent specifically? For all the others it looks like WebKit already throws, according to my earlier testing. |
…asayuki 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 --HG-- extra : rebase_source : 54701e7136c33ebce651d5f74c3dc1d8b944f9a3
…asayuki 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
…asayuki 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
…asayuki 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
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]
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]
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]
@marcoscaceres : if someone can fix the PR, then yes. I don't think we can marge the PR as is due to the aforementioned issue. |
…asayuki 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 UltraBlame original commit: 0bda6393453ef6ca289a37aa723f87f91160c66f
…asayuki 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 UltraBlame original commit: 0bda6393453ef6ca289a37aa723f87f91160c66f
…asayuki 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 UltraBlame original commit: 0bda6393453ef6ca289a37aa723f87f91160c66f
According to the previous spec, trying to collapse to or select a
doctype that is not in the current document would not throw. But
Chrome, Firefox, and Edge all do throw. (WebKit doesn't seem to throw
for doctypes at all.) The wpt test also tests that browsers do throw in
this case.