collapse and setBaseAndExtent methods contain redundant checks of offset

Open
#124 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
html
Domain
documentation

Research direction

Read the linked specification sections for Selection.collapse() and Selection.setBaseAndExtent(). Compare their explicit IndexSizeError steps with the later newRange creation and with other Selection API operations, then remove the redundant steps if the specification wording supports it.

Written by the indexing model from the issue text.

Description

Compatibility Editorial

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.

Dominant language
HTML
Stars
49
Forks
30
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from w3c/selection-api

All issues in w3c/selection-api

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.