w3c / selection-api

Selection API
http://w3c.github.io/selection-api/
Other
47 stars 30 forks source link

Define to remove selection range automatically if a selection range is modified into different selection root #175

Open masayuki-nakano opened 7 months ago

masayuki-nakano commented 7 months ago

Related to https://github.com/whatwg/dom/issues/772

Currently, Chrome and Firefox returns mutable reference of Range object from Selection.getRangeAt(). Then, the Range can be updated outside the DOM tree, e.g., into a different document, into a disconnected tree. I wrote a test, then, both Chrome and Firefox get same result.

I believe that Selection should not keep storing a range whose boundary points' root is not the document associated with the Selection because this kind of checks are done at Selection.addRange() at least.

Cc: @sefeng211, @smaug----, @zcorpan

dizhang168 commented 1 month ago

This might be a duplicate of: https://github.com/w3c/selection-api/issues/79