getComposedRange() review

Open
#161 19 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
html
Domain
api, web-dev

Research direction

Start by reviewing the getComposedRange() algorithm and the linked Selection API, DOM, and Web Components discussions. Resolve the empty-selection result and ShadowRoot matching questions, then determine how the proposed range duality affects getRangeAt(); the issue is done when these behaviors have an agreed specification.

Written by the indexing model from the issue text.

Description

NewAPI

If this is empty, return a new StaticRange whose start node and end node are null and whose start offset and end offset are 0.

Start/end node cannot be null. I think we use some kind of default instead, such as "the body element"?

While startNode is a node, startNode's root is a shadow root, and startNode is not a shadow-including inclusive ancestor of any of shadowRoots

It seems that if you pass in the ShadowRoot instance start node is part of, this wouldn't result in a match. Which if you made a selection inside that ShadowRoot instance doesn't seem to be what you want?


One thing I'm missing here still is https://github.com/WICG/webcomponents/issues/79#issuecomment-972726532. As we can no longer expose the true range directly we need to deal with that duality somehow, also for existing APIs such as getRangeAt(). That will require changes to both DOM and Selection.

Dominant language
HTML
Stars
49
Forks
30
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from w3c/selection-api

All issues in w3c/selection-api

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.