Re: [whatwg/dom] Introduce DOM post-insertion steps (PR #1261)

@domfarolino commented on this pull request.



> @@ -2752,6 +2812,16 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
  <var>parent</var> with <var>nodes</var>, « », <var>previousSibling</var>, and <var>child</var>.
 
  <li><p>Run the <a>children changed steps</a> for <var>parent</var>.
+
+ <li>
+  <p>For each <var>node</var> in <var>nodes</var>, in <a>tree order</a>:
+
+  <ol>
+   <li><p>For each <a>shadow-including inclusive descendant</a> <var>inclusiveDescendant</var> of
+   <var>node</var>, in <a>shadow-including tree order</a>, run the <a>post-insertion steps</a> with
+   <var>inclusiveDescendant</var>.
+  </ol>
+ </li>

> Is this the correct order relative to mutation observers? This should be observable using `takeRecords()`.

Good catch. Yes, Chrome and Firefox both can observe the _queued_ record this way. I am not actually sure the WPTs assert this, so let me modify a few to include this check.

> I also still worry about this not being entirely consistent with the removal case.

Hmm, could you elaborate on this concern? I don't know what is inconsistent about it. Assuming we have no opportunities to execute script during removal, we shouldn't need to move anything to an equivalent post-removal steps. And post-removal steps seem risky anyways, since we'd be operating exclusively on detached elements. The true equivalent for removal would be to let each node run their own script-observable non-script-executing side-effects one-by-one before any of them get removed, but I feel like as long as none of them are executing script, then that shouldn't actually be observable? And we certainly don't want to run script for each element just immediately before its removal, since that's the worst part of mutation events.

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

Message ID: <whatwg/dom/pull/1261/review/1931503444@github.com>

Received on Tuesday, 12 March 2024 16:00:11 UTC