Re: [whatwg/dom] Introduce `moveBefore()` state-preserving atomic move API (PR #1307)

@domfarolino commented on this pull request.



> + <li><p>Let <var>oldParent</var> be <var>node</var>'s <a for=tree>parent</a>.
+
+ <li><p><a>Assert</a>: <var>oldParent</var> is non-null.
+
+ <li><p>Let <var>index</var> be <var>node</var>'s <a for=tree>index</a>.
+
+ <li>
+  <p>For each <a>live range</a> whose <a for=range>start node</a> is <var>parent</var> and
+  <a for=range>start offset</a> is greater than <var>index</var>, decrease its
+  <a for=range>start offset</a> by 1.</p>
+
+  <p class="note">Note that unlike the traditional <a for=/ lt="remove">removal</a> case, we do not
+  need to update <a>live range</a> state when their <a for=range>start node</a> or
+  <a for=range>end node</a> is an <a>inclusive descendant</a> of the <var>node</var>. This is
+  because said <a>nodes</a> do not get removed from their <a>tree</a>, so ranges associated with
+  them stay intact.</p>

> Ok, so something else still updates Range boundary points so that start is before end point?

No, a Range's start does not have to be before its end, in DOM tree order. Just like if you create a new Range whose start comes after its end in DOM tree order, the start's [position](https://dom.spec.whatwg.org/#concept-range-bp-position) will be "after" its end, which is observable via `intersectsNode()` since nodes that are after end but before start, will no longer `intersectsNode()` the Range. The same goes for when `moveBefore()` moves things around such that the range's start is after its end, in tree order.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1307#discussion_r1836862873
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1307/review/2427601903@github.com>

Received on Monday, 11 November 2024 15:39:09 UTC