Skip to content

fix: [#1896] Call disconnectedFromNode on children in disconnectedFromNode#2021

Open
TrevorBurnham wants to merge 1 commit intocapricorn86:masterfrom
TrevorBurnham:fix/1896-disconnectedFromNode-typo
Open

fix: [#1896] Call disconnectedFromNode on children in disconnectedFromNode#2021
TrevorBurnham wants to merge 1 commit intocapricorn86:masterfrom
TrevorBurnham:fix/1896-disconnectedFromNode-typo

Conversation

@TrevorBurnham
Copy link
Copy Markdown
Contributor

Fixes #1896

Problem

In Node.disconnectedFromNode(), child nodes were incorrectly calling connectedToNode() instead of disconnectedFromNode().

// Before (incorrect)
const childNodes = this[PropertySymbol.nodeArray];
for (let i = 0, max = childNodes.length; i < max; i++) {
    childNodes[i][PropertySymbol.connectedToNode]();  // Wrong!
}

This bug caused nested children to not be properly disconnected when their parent was removed from the document, leaving isConnected as true for grandchildren and deeper descendants.

Solution

Changed the call from connectedToNode() to disconnectedFromNode():

// After (correct)
const childNodes = this[PropertySymbol.nodeArray];
for (let i = 0, max = childNodes.length; i < max; i++) {
    childNodes[i][PropertySymbol.disconnectedFromNode]();
}

I've added test coverage to prevent future regressions.

…onnectedFromNode

Fixed a typo in Node.disconnectedFromNode() where child nodes were
incorrectly calling connectedToNode() instead of disconnectedFromNode().

This bug caused nested children to not be properly disconnected when
their parent was removed from the document, leaving isConnected as true
for grandchildren and deeper descendants.

Added test to verify nested children are properly disconnected.
@TrevorBurnham
Copy link
Copy Markdown
Contributor Author

CI is failing due to #2022, which should be fixed by #2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG in Node.ts:disconnectedFromNode api

1 participant