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.

Ok, thanks for the clarification.

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

We could do that but then we may need to indicate that those end points either start before/after the root or not. Some components may not want to do anything unless the entirety of the selection resides within; e.g. text editor. If the user selected the entire document, the component may need to differentiate that from when the user selected everything in the component.

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

Perhaps. We probably still want to allow a list of shadow roots as well so that scripts can "see" the entire selection when there are multiple components that coordinate with one another when the user selects content across shadow boundaries. e.g. table cells / rows.

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

Received on Friday, 5 November 2021 07:19:45 UTC