- From: Copilot <notifications@github.com>
- Date: Wed, 10 Jun 2026 04:12:16 -0700
- To: w3c/selection-api <selection-api@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/selection-api/pull/359/review/4467186196@github.com>
@Copilot commented on this pull request.
## Pull request overview
This PR updates the Selection API specification to support **multi-range selections**, redefining core concepts (e.g., empty selection, anchor/focus) and adjusting API semantics/algorithms to operate over a set of associated ranges.
**Changes:**
- Redefines a selection as being associated with **one or more ranges**, updating related concepts like empty selection, caret behavior, anchor/focus, `rangeCount`, `type`, and `getRangeAt()`.
- Updates mutation methods (e.g., `addRange()`, `extend()`, `collapse*()`, `deleteFromDocument()`, `getComposedRanges()`) to work with multiple associated ranges, including sorting/merging behavior.
- Refreshes background/explanatory text to reflect the multi-range model.
---
💡 <a href="/w3c/selection-api/new/gh-pages?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
> Each <a>selection</a>s also have an <dfn>anchor</dfn> and a
- <dfn>focus</dfn>. If the <a>selection</a>'s <a>range</a> is null, its
- <a>anchor</a> and <a>focus</a> are both null. If the <a>selection</a>'s
- <a>range</a> is not null and its <a>direction</a> is <a>forwards</a>,
- its <a>anchor</a> is the <a>range</a>'s [=range/start=], and its
- <a>focus</a> is the [=range/end=]. Otherwise, its <a>focus</a> is the
- [=range/start=] and its <a>anchor</a> is the [=range/end=].
+ <dfn>focus</dfn>. If the <a>selection</a> is <a>empty</a>, its
Grammar: "Each selections" should be singular ("Each selection"), and verb agreement should be "has" not "have".
> + <li>For each associated <a>range</a> <var>range</var> in [=this=],
+ in order, run these steps:
The iteration order for associated ranges is underspecified here ("in order"). To keep behavior interoperable, spell out the ordering (e.g., increasing range/start in document order), consistent with addRange()/extend() sorting.
> The stringification must return the string, which is the
- concatenation of the rendered text if there is a [=range=]
- associated with [=this=].
+ concatenation of the rendered text of all associated <a>ranges</a>
+ in [=this=], in associated-range order.
"associated-range order" is referenced but not defined anywhere else in the spec, which makes stringification order ambiguous and risks interop issues. Consider replacing it with an explicit ordering definition (e.g., increasing range/start in document order).
> "extend", set <a>this</a> <a>selection</a>'s <a>focus</a> to the
location as if the user had requested to extend selection by <var>
- granularity</var>.
+ granularity</var>, updating the focused associated <a>range</a>
+ as in {{Selection/extend(node, offset)}}.
"focused associated range" is not defined elsewhere, making this step ambiguous. It likely intends the last associated range (as used by extend()).
> + Each <a>selection</a> can be associated with one or more
+ <a>ranges</a>. When there are no <a>ranges</a> associated with the
+ <a>selection</a>, the selection is <dfn>empty</dfn>. The selection
+ must be initially <a>empty</a>.
The spec still has normative text later that assumes a selection is associated with a single range (e.g., User Interactions around index.html:1003-1012 and selectionchange trigger text around index.html:1054-1058). To fully support multi-range selections, those sections likely need updates to describe how UA-driven changes and selectionchange scheduling behave with multiple associated ranges.
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/pull/359#pullrequestreview-4467186196
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/selection-api/pull/359/review/4467186196@github.com>
Received on Wednesday, 10 June 2026 11:12:20 UTC