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 and setBaseAndExtent methods contain redundant checks of offset #124

Open
darinadler opened this issue Sep 19, 2020 · 1 comment

Comments

@darinadler
Copy link

In the specification of the collapse method there is a step that says that the method must throw IndexSizeError if offset is longer than the node’s length. This check is also done as part of creating newRange in subsequent steps. So the IndexSizeError exception will be thrown in either case. However, because the specification explicitly calls for doing this before checking the node’s root, this difference is observable in obscure cases.

I suggest we remove the explicit IndexSizeError step. Better for consistency with other operations in the Selection API that don't explicitly specify an IndexSizeError check. I think it’s likely this is not already needed for web compatibility, so it’s not too late to fix this.

These same considerations apply to the setBaseAndExtent method. And I suggest the same change, removing the explicit IndexSizeError step.

@darinadler darinadler changed the title Selection API collapse and setBaseAndExtent algorithms contain redundant checks of offset collapse and setBaseAndExtent methods contain redundant checks of offset Sep 19, 2020
@darinadler
Copy link
Author

The WPT tests for collapse and setPosition expect the IndexSizeError check to be done before the document.contains check. The WPT test for setBaseAndExtent is does not cover the case where there is both IndexSizeError and a document.contains violation and so does not detect if the check is done before or after the document.contains check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants