[w3c/selection-api] Selection API collapse and setBaseAndExtent algorithms contain redundant checks of offset (#124)

In the [specification of the collapse method](https://w3c.github.io/selection-api/#dom-selection-collapse) 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](https://w3c.github.io/selection-api/#dom-selection-setbaseandextent). And I suggest the same change, removing the explicit `IndexSizeError` step.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/124

Received on Saturday, 19 September 2020 16:25:35 UTC