Re: [whatwg/dom] Should Live Range expose endpoints inside a shadow tree? (Issue #1362)

dizhang168 left a comment (whatwg/dom#1362)

In the Selection API spec, the definitions for anchor/focus says:
> Each [selection](https://w3c.github.io/selection-api/#dfn-selection)s also have an anchor and a focus. If the [selection](https://w3c.github.io/selection-api/#dfn-selection)'s [range](https://dom.spec.whatwg.org/#concept-range) is null, its [anchor](https://w3c.github.io/selection-api/#dfn-anchor) and [focus](https://w3c.github.io/selection-api/#dfn-focus) are both null. If the [selection](https://w3c.github.io/selection-api/#dfn-selection)'s [range](https://dom.spec.whatwg.org/#concept-range) is not null and its [direction](https://w3c.github.io/selection-api/#dfn-direction) is [forwards](https://w3c.github.io/selection-api/#dfn-forwards), its [anchor](https://w3c.github.io/selection-api/#dfn-anchor) is the [range](https://dom.spec.whatwg.org/#concept-range)'s [start](https://dom.spec.whatwg.org/#concept-range-start), and its [focus](https://w3c.github.io/selection-api/#dfn-focus) is the [end](https://dom.spec.whatwg.org/#concept-range-end). Otherwise, its [focus](https://w3c.github.io/selection-api/#dfn-focus) is the [start](https://dom.spec.whatwg.org/#concept-range-start) and its [anchor](https://w3c.github.io/selection-api/#dfn-anchor) is the [end](https://dom.spec.whatwg.org/#concept-range-end).

> Note [anchor](https://w3c.github.io/selection-api/#dfn-anchor) and [focus](https://w3c.github.io/selection-api/#dfn-focus) of [selection](https://w3c.github.io/selection-api/#dfn-selection) need not to be in the [document tree](https://dom.spec.whatwg.org/#concept-document-tree). It could be in a [shadow tree](https://dom.spec.whatwg.org/#concept-shadow-tree) of the same [document](https://dom.spec.whatwg.org/#document).

Given this, the Selection API does expect the Range API to return endpoints that are within shadow trees.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1362#issuecomment-2707738194
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1362/2707738194@github.com>

Received on Friday, 7 March 2025 23:49:04 UTC