LearnNewsExamplesServices
Frontmatter
id19926
titleDeltaUpdates.updateNode applies properties after nodeName to the detached old element
stateClosed
labels
bugaicore
assigneesneo-gemini-julia
createdAtOct 20, 2026, 8:23 PM
updatedAtOct 20, 2026, 10:05 PM
githubUrlhttps://github.com/neomjs/neo/issues/19926
authorneo-gemini-julia
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 20, 2026, 10:05 PM

DeltaUpdates.updateNode applies properties after nodeName to the detached old element

neo-gemini-julia
neo-gemini-julia commented on Oct 20, 2026, 8:23 PM

Context

During CI execution on #19923 (job/118770140013), test/playwright/e2e/core/DistEsmWorkspaceBoot.spec.mjs:186:5 (the same workspace boots from source, where HtmlTemplateProcessor parses the template at runtime) failed with:

Locator:  locator('p.greeting')
Expected: "Hello, workspace!"
Received: ""
10 × locator resolved to <p class="greeting" id="neo-functional-component-1"></p>
  • Live latest-open sweep: checked latest 20 open issues in neomjs/neo (sort: 'created') at 2026-10-20T18:21:45Z; no equivalent found.
  • A2A in-flight claim sweep: checked latest 30 messages (status: 'all') at 2026-10-20T18:21:50Z; no competing claim found.
  • Memory Core rationale & own-assignment sweeps: queried DeltaUpdates changeNodeName updateNode nodeName textContent clone replaceChild (surfaced original changeNodeName implementation in #8597 / #8598 / #8600) and checked open assigned issues (0 in neomjs/neo).

The Problem

When a single VDom updateNode delta changes both nodeName and any property ordered after nodeName on Neo.vdom.VNode (scrollLeft, scrollTop, style, innerHTML, or textContent), the properties after nodeName are applied to the detached old DOM element instead of the newly created replacement element in the live DOM.

In DistEsmWorkspaceBoot.spec.mjs:186, Greeting (Neo.functional.component.Base with enableHtmlTemplates: true) dynamically imports HtmlTemplateProcessor.mjs in initAsync(). When Viewport's initial mount completes before import('./HtmlTemplateProcessor.mjs') resolves, Greeting mounts its placeholder {id: 'neo-functional-component-1'} (<div id="neo-functional-component-1"></div>). Once HtmlTemplateProcessor.mjs loads, afterSetIsReady(true, false) re-runs vdomEffect and emits a single updateNode delta:

{
    cls        : {add: ['greeting']},
    nodeName   : 'p',
    textContent: 'Hello, workspace!',
    id         : 'neo-functional-component-1'
}

In Neo.main.DeltaUpdates#updateNode:

  1. node is resolved to <div id="neo-functional-component-1">.
  2. case 'cls' adds greeting to node.classList.
  3. case 'nodeName' calls me.changeNodeName(node, 'p'), which creates clone = document.createElement('p'), copies attributes (class="greeting", id="neo-functional-component-1") and existing child nodes onto clone, and executes node.parentNode.replaceChild(clone, node) — without returning clone or updating node in updateNode.
  4. case 'textContent' executes node.textContent = 'Hello, workspace!' on the detached <div> (node), leaving <p class="greeting" id="neo-functional-component-1"></p> empty in the live DOM.

The Architectural Reality

  • Design authority: src/main/DeltaUpdates.mjs:857-858 — "Updates various properties of an existing DOM node based on the provided delta. This includes updating attributes, class names, inner HTML, node name, and inline styles."
  • Neo.vdom.VNode (src/vdom/VNode.mjs:94-111) assigns attributes, className, nodeName, scrollLeft, scrollTop, style, and innerHTML / textContent in that exact property order.
  • Neo.vdom.Helper#compareAttributes (src/vdom/Helper.mjs:76-198) iterates Object.keys(vnode) in VNode property order, so nodeName always precedes scrollLeft, scrollTop, style, innerHTML, and textContent in the emitted delta object, and any caller passing a delta where nodeName precedes attributes or cls would similarly lose those mutations if node is not updated to the replacement element.

The Fix

  1. In src/main/DeltaUpdates.mjs:
    • Update changeNodeName(node, nodeName) (:157-198) to return clone (the newly created replacement HTMLElement, or null if !node).
    • Update updateNode(delta) (:915-917) to assign node = me.changeNodeName(node, value) so all subsequent property mutations in the same updateNode loop (textContent, innerHTML, style, scrollLeft, scrollTop, cls, attributes) operate on the live replacement element in the DOM.
  2. Add a Playwright unit test verifying that DeltaUpdates#updateNode with {id, cls, nodeName, style, textContent} (and {id, nodeName, innerHTML, attributes}) applies every property to the replaced live DOM element rather than the detached old element.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
Neo.main.DeltaUpdates#changeNodeName(node, nodeName) src/main/DeltaUpdates.mjs:157-198 Returns the newly created replacement HTMLElement (clone) after replaceChild(clone, node) Returns null when node is falsy JSDoc @returns {HTMLElement|null} on changeNodeName Playwright unit test in test/playwright/unit/
Neo.main.DeltaUpdates#updateNode(delta) src/main/DeltaUpdates.mjs:872-946 Rebinds node = me.changeNodeName(node, value) on case 'nodeName' so subsequent keys in delta mutate the live replacement element Unchanged when delta.nodeName is absent JSDoc on updateNode Playwright unit test in test/playwright/unit/
  • Decision Record impact: none (bugfix restoring DeltaUpdates#updateNode contract when nodeName and content/style properties co-occur in one delta).

Acceptance Criteria

  • AC-1: Neo.main.DeltaUpdates#changeNodeName(node, nodeName) returns the newly created HTMLElement (clone) that replaced node in node.parentNode.
  • AC-2: Neo.main.DeltaUpdates#updateNode(delta) updates its node reference to the return value of me.changeNodeName(node, value) so properties processed after nodeName in the same delta (textContent, innerHTML, style, scrollLeft, scrollTop, cls, attributes) land on the live replacement element in the DOM.
  • AC-3: Unit test coverage verifies that an updateNode delta combining nodeName with cls, style, attributes, and textContent / innerHTML leaves all properties present on the live DOM element after replacement.

Out of Scope

  • Changing Neo.functional.component.Base#initAsync lazy-loading of HtmlTemplateProcessor.mjs.
  • Changing Neo.vdom.VNode property ordering.

Related

  • Surfaced on #19923 (DistEsmWorkspaceBoot.spec.mjs:186:5)
  • Prior changeNodeName work: #8597, #8598, #8600

Origin Session ID: 2d742cad-83f2-415e-a6f1-12dc4a906d85 Retrieval Hint: "DeltaUpdates updateNode changeNodeName detached node textContent HtmlTemplateProcessor DistEsmWorkspaceBoot"

tobiu referenced in commit 73d1ba8 - "fix(vdom): rebind node on changeNodeName in DeltaUpdates.updateNode (#19926) (#19927) on Oct 20, 2026, 10:05 PM
tobiu closed this issue on Oct 20, 2026, 10:05 PM