- From: Di Zhang <notifications@github.com>
- Date: Fri, 26 Jul 2024 14:19:23 -0700
- To: w3c/selection-api <selection-api@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/selection-api/issues/180@github.com>
To simplify selection for components that only wish to handle selections within a sub-tree, we would like to add the optional selectionRoot parameter. If provided, the returned StaticRange from getComposedRanges() will only contain endpoints that are inclusive descendants of this selectionRoot.
Proposal:
```
sequence<StaticRange> getComposedRanges(optional GetComposedRangesOptions options = {});
dictionary GetComposedRangesOptions {
sequence<ShadowRoot> shadowRoots = [];
selectionRoot = null; // new
};
```
We would also need to redefine how the rescoping works for selectionRoot:
* If selection range's start node is outside/above the selectionRoot, it is rescoped to be the first position within selectionRoot.
* If selection range's end node is outside/above the selectionRoot, it is rescoped to be the last position within selectionRoot.
## Resources
This parameter was first suggested in the [explainer](https://github.com/mfreed7/shadow-dom-selection?tab=readme-ov-file#re-scoping) and had positive feedback. Please see the example in the explainer as it illustrates this parameter well.
Related issue: https://github.com/w3c/selection-api/issues/176
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/180
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/selection-api/issues/180@github.com>
Received on Friday, 26 July 2024 21:19:27 UTC