Intent to prototype: Selection.getComposedRanges() and ShadowDOM Selection

409 views
Skip to first unread message

Sean Feng

unread,
Mar 18, 2024, 4:20:44 PMMar 18
to dev-pl...@mozilla.org

Hi all,

In bug 1867058, I plan to land some patches that implement the Selection.getComposedRanges() and the Selection.direction APIs, as specified in https://www.w3.org/TR/selection-api/. Selection.direction exposes the direction of the selection, and Selection.getComposedRanges() allows web authors to get selection endpoints across the shadow boundaries.

In addition to these two new APIs, I'll also land some patches that allow users to visually select page contents that cross the ShadowDOM boundary. There are follow-up works that are needed before we can ship this feature. bug 1881095 will ensure the copy-paste feature for ShadowDOM selection works, bug 1881096 will ensure printing ShadowDOM selection works and bug 1867059 will ensure we have a sensible solution for slotted contents.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1867058

Specification: https://www.w3.org/TR/selection-api/

Platform coverage: all

Preference: dom.shadowdom.selection_across_boundary.enabled. It's only enabled in Nightly for now.

Link to standards-positions discussion: https://github.com/mfreed7/shadow-dom-selection.

Other browsers:

  • Blink: I am quite sure they are positive, given they contributed to the spec design heavily, however I couldn't find a reference to it. 
  • WebKit: Shipped since 17.0

web-platform-tests: https://github.com/web-platform-tests/wpt/blob/2b057d90e32114618d004c5a8c6eff351b8a4fbd/shadow-dom/selection-getComposedRanges.tentative.html, https://github.com/web-platform-tests/wpt/blob/2b057d90e32114618d004c5a8c6eff351b8a4fbd/shadow-dom/selection-direction.tentative.html. bug 1867058 also contains additional WPTs.

Thanks,

Sean

Reply all
Reply to author
Forward
0 new messages