Re: [WICG/webcomponents] Selection APIs for Shadow DOM (#79)

We just had a very good discussion of this proposal/issue at a TPAC 2021 breakout - thanks to all that participated! I will summarize the conclusions and takeaways as I heard them - feel free to correct me if I missed something:

1. We discussed several alternative API shapes:
    a. Have `getComposedRange()` return a list of ranges, partitioned by shadow boundaries.
    b. Have `shadowRoot.getSelection()` which returns a "fake" range whose endpoints live entirely within that shadow root.
    c. Have `getComposedRange()` return something like `Event.composedPath()`, with lists of nodes up to the document root.
2. We generally agreed that the best way forward for a "V1 API" was to move ahead with a `getComposedRange()` very similar to the one being proposed, but that requires passing in any (open or closed) shadow roots.
3. If/when a use case comes to light for which developers end up wanting access to **all** open roots, we can add a parameter (e.g. `getComposedRange({anyOpenShadowRoot:true})`).
4. I took an action item to dig further into the details of the "fake" range returned by `getRangeAt()` under this proposal. How would this be represented, exactly? What happens when the live `Range` is mutated by Javascript (e.g. with `range.setStart()`)? What happens when a tree mutation changes the selection boundaries within a shadow root?
5. I took an action item to dig further into browser selection canonicalization behavior, which adjusts selection endpoints in various ways, such as pushing them to the deepest equivalent point in the tree. The suggestion is that this behavior shouldn't materially change, for compat reasons, but this needs more attention.

I will incorporate all of the above (including the conclusions of my action items) back into the explainer, and I'll post here when that's done. At that point, the meeting participants thought it would be worthwhile to reach out to editor component authors, to see if the (new) proposed API would meet most of their needs. We should include not only the components listed in https://github.com/WICG/webcomponents/issues/79#issuecomment-946842531, but also the ones listed in the [explainer](https://github.com/mfreed7/shadow-dom-selection#helpfulrelated-links).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/79#issuecomment-946897700

Received on Tuesday, 19 October 2021 16:33:02 UTC