Skip to content

Should Live Range expose endpoints inside a shadow tree? #1362

Open
@dizhang168

Description

@dizhang168

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions