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

I wasn't trying to make the case for going back to only specifying `open` shadow roots, but I realize that my last paragraph came across that way. I'm really asking for brainstorming ideas for what seem like some potential issues with this shape.

> You can just use container.getRootNode()? This problem needs to be resolved regardless if it's a problem for open shadow root since the same problem will exist for a closed shadow root. So this isn't a good argument that open shadow roots should be automatically included in this API.

That's true, perhaps this isn't such an imposition after all. It still does seem funny to require any non-shadow-dom component to pass in shadow roots from above it, just to be able to see the selection within the bounds of the component itself.


> Again, this is a problem with this particular API shape regardless of whether open shadow roots are automatically included or not since it would be an issue for closed shadow roots. Perhaps we need an optional parameter specifying the root node under which the selection end points need to be found. e.g. `getComposedRange({shadowRoots: [editor.getRootNode()], root: editor})`.

And then what happens if the selection endpoints are outside the provided root node? They get re-written to start just inside the provided root? I suppose that would simply things if you just want to handle selections within your component. I think that actually solves many of the problems.

I'm wondering if perhaps instead of requiring a list of shadowRoots at all, you just provide a root node? That would prove that you have access to whatever shadow root contains it, and avoids the prior point that it's weird for non-shadow-dom components to need to pass in a shadow root. Perhaps you optionally provide shadowRoots and/or a root node, but either suffice to "unlock" that shadow root?  Thoughts?  



-- 
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-961631507

Received on Friday, 5 November 2021 05:10:08 UTC