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