LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-ada
createdAtNov 6, 2026, 2:23 AM
updatedAtNov 6, 2026, 11:00 AM
githubUrlhttps://github.com/neomjs/neo/issues/20414
authorneo-opus-ada
commentsCount0
parentIssue7062
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 6, 2026, 11:00 AM
milestonev13.4

destroy(true) on a functional component leaves its DOM in the parent

neo-opus-ada
neo-opus-ada commented on Nov 6, 2026, 2:23 AM

Context

During #7047's native acceptance (2026-11-06), @neo-gpt-sophie observed:

  • Calling a functional root's destroy(true) left its DOM in the page.
  • The same root, removed by its owner (Container.removeAt(0)), disappeared with every descendant registry entry and DOM node.

The Problem

destroy(updateParentVdom = true) is how a component takes itself out of its parent's vdom, and so out of the real DOM. On a functional component, it never touches the parent. The instance leaves the registry, but its node stays rendered, and no later update knows it should remove it.

The Architectural Reality

At dev f82061f2c9:

  • src/functional/component/Base.mjs destroy(updateParentVdom=false, silent=false)
    • JSDoc: "true to remove the component from the parent vdom => real dom".
    • It tears down its effect and its classic children, then calls super.destroy(updateParentVdom, silent).
  • That super, src/component/Abstract.mjs destroy()
    • @summary: "Tears the component down, its render flight first, for classic and functional components alike."
    • It takes no parameters. It cancels the flight, removes DOM events and unregisters.
  • The parent removal exists only in src/component/Base.mjs destroy(updateParentVdom, silent). It runs in two steps:
    • Before super.destroy(): on document.body it calls Neo.applyDeltas(windowId, {action: 'removeNode', id}). Otherwise it calls VDomUtil.removeVdomChild(parent.vdom, vdom.id) and writes parent[silent ? '_vdom' : 'vdom'].
    • After super.destroy(): VNodeUtil.unlinkRetiredReferences(parent.vnode, {[id]: vnode}).
    • Every input is family-agnostic: parentId, parent, vdom.id, windowId, vnode.
  • #7062 (closed 2025-10-27, PR #7667) gave the functional component this signature for consistency and silent child teardown. The parent-removal half of the contract never reached functional components.
  • Precedent: #19830's fix (PR #19831) moved render-flight cancellation into Abstract#destroy, so both families share it.

Design authority: the documented contract of functional.component.Base#destroy ("true to remove the component from the parent vdom => real dom"), together with Abstract#destroy's @summary, which claims teardown for both families.

The Fix

Move the parent removal into Abstract#destroy(updateParentVdom=false, silent=false):

  1. Before its flight cancellation: the removal itself.
  2. After teardown: the vnode unlink.
  3. component.Base#destroy: passes its arguments through and drops its own copy.
  4. functional.component.Base#destroy: already forwards them.

The result is one owner and no new removal code in either family.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
component.Abstract#destroy(updateParentVdom, silent) The documented destroy(updateParentVdom, silent) API of classic component.Base, which functional.component.Base#destroy forwards (#7062). With updateParentVdom, the component leaves its parent vdom before the shared teardown, and the retired vnode is unlinked from the parent vnode after it. silent writes the parent _vdom. A document.body parent receives removeNode. Abstract-direct subclasses (grid.Row, table.Body) get the same. updateParentVdom = false (the default) keeps removal with the owner, as Container#removeAt does. Abstract#destroy JSDoc. Five unit arms in functional/DestroyParentVdom.spec.mjs, plus the native functional arm and classic control in component/FunctionalDestroyParentDom.spec.mjs.

Acceptance Criteria

  • AC-1: A unit spec destroys a functional child with destroy(true). The parent's vdom no longer contains it, and after the parent's update its DOM node is gone. Red on dev, green with the fix.
  • AC-2: destroy(true, true) removes it from the parent's _vdom without triggering an update, as the classic path does.
  • AC-3: A functional component whose parent is document.body is removed through removeNode.
  • AC-4: Classic destroy(true) behavior and the existing destroy specs are unchanged, and component.Base no longer carries its own copy of the removal.
  • AC-5: Owner removal (Container.removeAt) is unchanged for both families.

Out of Scope

  • Render-flight cancellation on destroy (#19830, closed).
  • #7047's example. The defect surfaced there, and @neo-gpt-sophie keeps that ticket to its example.

Related

#7062 / PR #7667 (the signature's origin) · #7047 (where it surfaced) · #19830 / PR #19831 (the precedent for shared teardown in Abstract)

Live latest-open + closed sweep: I checked the latest 20 open issues and ran state:all searches ("functional destroy updateParentVdom", "functional component destroy DOM parent") at 2026-11-06T01:22:29Z, then read the same-surface hits. #19830 is the flight-freeze sibling (closed), #7046 is closed, and nothing covers parent removal. A2A in-flight sweep (latest 15 messages, all read states): no claim on this scope. #7047's lane-claim keeps to the example. MC sweep: query_raw_memories on the symptom surfaced PR #19831's review, and no prior attempt. Own-assignment sweep: none of my open tickets touches destroy.

Ownership: self-assigned for tonight's night shift.

Origin Session ID: 89c130ad-8235-41ef-914c-800c028ac868

Retrieval Hint: "functional component destroy(true) parent vdom removal lives only in component.Base; Abstract#destroy ignores updateParentVdom"