[w3c/selection-api] Define to remove selection range automatically if a selection range is modified into different selection root (Issue #175)

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](https://github.com/web-platform-tests/wpt/blob/0d75348206dc25ee759f46f94587ce86d81647a8/selection/move-selection-range-into-different-root.tentative.html), then, [both Chrome and Firefox get same result](https://wpt.fyi/results/selection/move-selection-range-into-different-root.tentative.html?run_id=5159444605829120&run_id=5186991854977024&run_id=6212624877879296&run_id=5073475970007040).

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](https://w3c.github.io/selection-api/#dom-selection-addrange) at `Selection.addRange()` at least.

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

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/175
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/selection-api/issues/175@github.com>

Received on Thursday, 4 April 2024 01:33:26 UTC