-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should Live Range expose endpoints inside a shadow tree? #1362
Comments
Thanks for filing, this is great to track. I will say I do think this can be separated from composed selection range work in #1342 and w3c/selection-api#345. Getting composed selection ranges wired up correctly and working across shadow DOMs seems tangential to this, especially since the issue here does not depend on the infrastructure provided by the composed selection work, and there are significant compat differences between the two efforts. |
I don't see it that way. We haven't really attempted to tackle how shadow roots work with selections thus far, though I believe we had a shared understanding that selections would not end up exposing shadow roots. Now that we are in the process of formalizing how selections and shadow roots interact, this should be tackled as part of that (or before). |
But aren't the two problems separate? Not all browsers even ship That's what makes the two seem cosmetically similar, but actually quite separate in terms of feasibility. It'd be a shame to hold the former hostage to the latter, which has more compat risk than the former, and doesn't seem to depend on it either. Do you think it would be possible to land spec infra in DOM that supports |
https://github.com/mfreed7/shadow-dom-selection?tab=readme-ov-file#changes-to-existing-selection-apis has the section for |
Right now, the range boundary points will be collapsed at the new boundary point. The range will not be removed from the selection.
|
In the Selection API spec, the definitions for anchor/focus says:
Given this, the Selection API does expect the Range API to return endpoints that are within shadow trees. |
Yep, I think that's what @annevk is saying is a problem that was never really thought through, and should be fixed. I think I agree, but I just think that it can come after we fully specify |
What is the issue with the DOM Standard?
While reviewing the Composed Selection Range PR, @annevk brought up a concern about the current spec, which makes it possible for getRangeAt(0) to expose nodes in the shadow DOM.
For example, what happens when a user selects inside a shadow tree only, to boundary points S1 and S2?
Currently, per the steps on how to set the start and end of a live range, this would return a live range at {S1, S2} since the nodes share the same root. That is the behavior in Chrome and Firefox.
Safari returns a Range collapsed at the shadow host.
Anne argues that this range should be rescoped to return the entire shadow host.
However, we (Chrome) are worried that changing this behavior will break sites that depend on getRangeAt(0) returning nodes in the shadow DOM, and don't expect the range to be "rescoped" to the ShadowRoot's host. Changing this behavior in the spec, and in 2/3 implementations, poses a compatibility risk that we think is worth exploring, but are not sure is feasible.
The text was updated successfully, but these errors were encountered: