Skip to content
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

Change Selection to be associated with a composed live range #345

Draft
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

dizhang168
Copy link
Member

@dizhang168 dizhang168 commented Jan 24, 2025

Note: This PR is not ready to merge, but can 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:

  1. 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. However, for getComposedRanges(), we will refer to the composed live range's endpoints directly. This includes updating definitions for anchor/focus, getRangeAt(0), addRange(), removeRange(), etc.

  2. 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:


Preview | Diff

<var>end</var>, run these steps:
</p>
<ol>
<li>Let <var>newCachedRange</var> be a new {{Range}} object.</li>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the {{Range}} should refer to the Range interface defined in [dom]. However, it keeps pointing to range, which I redefined in this PR. How can I overwrite this behavior?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would just remove the dfn of range that you introduced here. We already know the type of "composed live range", once it's able to link to DOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants