Re: [w3ctag/design-reviews] Modification of selection APIs to account for shadow dom (Issue #694)

Thanks for the feedback!

I understand your question - you're saying it'd be nice to allow users of the new API to get/use `StaticRange` as a return value, while **not** crossing shadow bounds. If that's correct, I think the existing API already offers a few ways to do that. First, just calling `selection.getComposedRange()` with no arguments will result in a `StaticRange` that does not cross shadow bounds (because none were provided). So that might be the API you're asking for. If authors are building a component, and would just like a `StaticRange` that is scoped within their tree, the `selectionRoot` parameter (see [this section of the explainer](https://github.com/mfreed7/shadow-dom-selection#re-scoping)) can be used:

```javascript
selection.getComposedRange({selectionRoot: componentRoot});
```

In both of these cases, the returned `StaticRange` will not cross shadow bounds. Let me know if I missed something about your question.

I appreciate (very much) that you didn't ask for the other permutation, returning a live `Range` that crosses shadow bounds. 😄 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/694#issuecomment-1079509577

You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/694/1079509577@github.com>

Received on Friday, 25 March 2022 23:18:25 UTC