-
Notifications
You must be signed in to change notification settings - Fork 30
Change Selection to be associated with a composed live range #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Conversation
(I know this is a WIP, just note that the cached live range should be interpreted as legacy selection range) |
Hi @rniwa, could you help review? This PR uses the "composed selection range" getting defined in DOM. Thank you. |
The change looks good! |
Good question, we are actually discussing about the naming and currently landed on "legacy uncomposed range". Not the most intuitive I guess, but as you say, it is just wording..
Currently, there are no changes to the getRangeAt() method nor new API being introduced. It is all semantics so the output of getComposedRanges() can now cross shadow root boundaries interoperability, without breaking any spec rules. |
Overall the changes look great. |
The goal of this PR is to add the definitions necessary so the getComposedRanges() API can access a composed live range's endpoints that might cross shadow boundaries instead of accessing the legacy uncomposed live range, which is scoped to be contained within one root only.
This specification is aligned with the currently shipped getComposedRanges() in Webkit and Gecko (behind a flag). It only adds definitions and references; it does not change the structure of any existing user-facing API.
Note: This PR is not ready to merge, but can be reviewed. It depends on the definitions "composed live range" and "cached live range", being specced at: whatwg/dom#1342
The Editing WG issue discussing this change is: #2
To summarize, this spec PR changes:
Each selection can be associated with a single composed live range.
Most of the existing Selection API functions will refer to the composed live range's cached live range to make sure we are backward compatible. This includes updating definitions for anchor/focus, getRangeAt(0), addRange(), removeRange(), etc. However, for getComposedRanges(), we will refer to the composed live range's endpoints directly.
Add "reset the range" algorithm
We add a new "reset the range" of this selection algorithm, which is called by collapse(), collapseToStart(), collapseToEnd(), extend(), setBaseAndExtent(), selectAllChildren(). This will make sure to create and set the composed live range and its cached live range, and call {{Range}}'s "set the start/end" algorithm.
For normative changes, the following tasks have been completed:
Editing WG resolution on the proposed changes, with at least two implementers participating and not objecting:
For browsers that are shipping the feature, implementation bugs are filed for the proposed changes (link to bug, or write "Not Implementing"):
Preview | Diff