Contact emails
dizha...@chromium.org

Explainer
None

Specification
https://w3c.github.io/selection-api/#dom-selection-getcomposedranges

Summary

This feature ships two new API methods for the Selection API: * 
Selection.direction which returns the selection's direction as either 
"none", "forward" or "backward" * Selection.getComposedRanges() which 
returns a list of 0 or 1 “composed” StaticRange A “composed” StaticRange is 
allowed to cross shadow boundaries, which normal Ranges cannot. For 
example: const range = getSelection().getComposedRanges({ shadowRoots: 
[root] }); If the selection crosses a shadow root boundary that isn’t 
provided in the shadowRots list, then the StaticRange's endpoints will be 
“rescoped” to be outside that tree. This makes sure we do not expose 
unknown shadow trees.


Blink component
Blink>DOM>ShadowDOM 
<https://issues.chromium.org/issues?q=customfield1222907:%22Blink%3EDOM%3EShadowDOM%22>

TAG review
None

TAG review status
Issues addressed

Risks


Interoperability and Compatibility

None


*Gecko*: Positive (
https://github.com/mozilla/standards-positions/issues/1055) Currently in 
development. 
https://groups.google.com/a/mozilla.org/g/dev-platform/c/zF7soLapT-Y

*WebKit*: Shipped/Shipping (
https://github.com/WebKit/WebKit/pull/10843#issuecomment-1592149737) 
Partially shipped new API

*Web developers*: Positive (
https://stackoverflow.com/questions/62054839/shadowroot-getselection)

*Other signals*:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that 
it has potentially high risk for Android WebView-based applications?

No, this is only shipping new APIs without modifying existing behavior.


Debuggability

None


Will this feature be supported on all six Blink platforms (Windows, Mac, 
Linux, ChromeOS, Android, and Android WebView)?Yes

The Selection API is supported on all platforms.


Is this feature fully tested by web-platform-tests 
<https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md>
?Yes

Tests can be found at 
https://wpt.fyi/results/selection/shadow-dom/tentative?label=experimental&label=master&aligned


Flag name on about://flags
SelectionAcrossShadowDOM

Finch feature name
SelectionAcrossShadowDOM

Requires code in //chrome?
False

Tracking bug
https://issues.chromium.org/issues/40286116

Availability expectation
Feature is available on Web Platform Baseline within 6 months of launch in 
Chrome.

Adoption expectation
Feature is available on Web Platform Baseline within 6 months of launch in 
Chrome.

Adoption plan
The feature is already shipped in Safari/Webkit and Firefox has an 
implementation in Nightly. They mentioned also wanting to land this within 
2025.

Estimated milestones
Shipping on desktop
137
Shipping on Android
137
Shipping on WebView
137

Anticipated spec changes

Open questions about a feature may be a source of future web compat or 
interop issues. Please list open issues (e.g. links to known github issues 
in the project for the feature specification) whose resolution may 
introduce web compat/interop risk (e.g., changing to naming or structure of 
the API in a non-backward-compatible way).
This new API is important to return Selection endpoints that are inside a 
shadow DOM and currently not accessible by API. This depends on new 
specification definitions of what it means to have a range that is composed 
and how the endpoints should be compared. That specification includes tree 
traversal, boundary point comparisons and the specification language is 
quite complex. The specification PR has been open since Dec 17, 2024 and is 
stalling due to disagreement on how to phrase/word the spec. There are a 
few remaining open issues about this, but none of those should affect the 
shape of the API - they only affect the spec text itself.
https://github.com/whatwg/dom/pull/1342
https://github.com/whatwg/dom/issues/1362
https://github.com/whatwg/dom/issues/1363
https://github.com/w3c/selection-api/pull/345

Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/5971377218912256?gate=6663146663313408

Links to previous Intent discussions
Intent to Prototype: 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/c40a8cc7-9f46-451c-b449-450e1d072fabn%40chromium.org


This intent message was generated by Chrome Platform Status 
<https://chromestatus.com/>.

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/10d2631e-2014-42ac-9343-c6d43ff47975n%40chromium.org.

Reply via email to