You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Selection should detach associated Range when Range move to another root. #79
Current Selection API should specify behavior when associate Range, added by Selection#addRange(), when it is moved to another document or it is moved DocumentFragment.
As of February 2017, Both Edge and Firefox keep such Range to associated. They returns node in another document by Selection#anchorNode and focusNode properties.
I propose when associated Range is moved another root, Selection should stop to associate it.
I don't think changing the behavior of Selection-Range relationship like that only in the case where a Range's boundary points is in another document or otherwise disconnected is a good idea. This makes the API's behavior rather hard to predict.
We should either spec Gecko/Edge's behavior or what WebKit does, which is that addRange doesn't let the original range control selection, and getRangeAt makes a new Range each time it gets called.
In the last draft, collapse()extend()setBaseAndExtent() and selectAllChildren() reject nodes in a different root though addRange() accepts anything. It's inconsistent. IMO, addRange() should reject Ranges with nodes in different roots.
The Background section of the draft says:
IE9 and Firefox 6.0a2 allow arbitrary ranges in the selection, which follows what this spec originally said. However, this leads to unpleasant corner cases that authors, implementers, and spec writers all have to deal with, and they don't make any real sense.
Looks like Blink implemented this proposed behavior so that when range's roots are moved to another document, it disassociates itself from the selection.
Activity
rniwa commentedon Feb 13, 2017
I don't think changing the behavior of
Selection-Rangerelationship like that only in the case where a Range's boundary points is in another document or otherwise disconnected is a good idea. This makes the API's behavior rather hard to predict.We should either spec Gecko/Edge's behavior or what WebKit does, which is that
addRangedoesn't let the original range control selection, andgetRangeAtmakes a newRangeeach time it gets called.tkent-google commentedon Feb 15, 2017
In the last draft,
collapse()extend()setBaseAndExtent()andselectAllChildren()reject nodes in a different root thoughaddRange()accepts anything. It's inconsistent. IMO,addRange()should reject Ranges with nodes in different roots.The Background section of the draft says:
tkent-google commentedon Feb 17, 2017
I was wrong.
addRange()in the draft rejects Ranges in different root.https://www.w3.org/TR/selection-api/#dom-selection-addrange
rniwa commentedon Jul 13, 2022
Looks like Blink implemented this proposed behavior so that when range's roots are moved to another document, it disassociates itself from the selection.