Re: [w3c/selection-api] Change Selection to be associated with a composed live range (PR #345)

@domfarolino commented on this pull request.



> @@ -546,24 +566,18 @@ <h2>
             <var>newFocus</var> be the <a>boundary point</a> (<var>node</var>,
             <var>offset</var>).
             </li>
-            <li>Let <var>newRange</var> be a new <a>range</a>.
-            </li>
-            <li>If <var>node</var>'s [=tree/root=] is not the same as the
-            [=this=]'s <a>range</a>'s [=tree/root=], [=Range/set the start=]
-            <var>newRange</var>'s [=range/start=] and [=range/end=] to
-            <var>newFocus</var>.
+            <li>If <var>node</var>'s [=tree/root=] is not the same as
+            [=this=]'s <a>range</a>'s [=tree/root=], <a>reset the range</a> with
+            <var>newFocus</var> and <var>newFocus</var>.
             </li>
             <li>Otherwise, if <var>oldAnchor</var> is [=boundary point/before=]

I'm curious about this. It looks like [DOM's position computing algorithm that determines "before" and "after"](https://dom.spec.whatwg.org/#concept-range-bp-before) expects that the two input nodes always have the same root, which might not be true, since after all [DOM's "set the start or end"](https://dom.spec.whatwg.org/#concept-range-bp-set) algorithm has cross-root handling logic that we add on to in https://github.com/whatwg/dom/pull/1342.

I guess we should either change "set the start or end" to accept cross-root nodes, or catch that case early on here, and skip the before/after comparison checks.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/pull/345#pullrequestreview-2642330385
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/selection-api/pull/345/review/2642330385@github.com>

Received on Tuesday, 25 February 2025 19:59:32 UTC