Skip to content

Avoid removing existing dom nodes on subsequent replaceNode cal…#2274

Merged
marvinhagemeister merged 2 commits into
masterfrom
fix-subsequent-replace-nodes
Jan 23, 2020
Merged

Avoid removing existing dom nodes on subsequent replaceNode cal…#2274
marvinhagemeister merged 2 commits into
masterfrom
fix-subsequent-replace-nodes

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

Fixes: #2260
Fixes: #2264

We didn't correctly clean up existing nodes that weren't being replaced

@coveralls

coveralls commented Jan 22, 2020

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 97.747% when pulling f2b8600 on fix-subsequent-replace-nodes into 9e3faa9 on master.

Comment thread src/diff/index.js
}
} else if (newVNode !== oldVNode) {
if (excessDomChildren != null) {
excessDomChildren[excessDomChildren.indexOf(dom)] = null;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates the array that is still referenced in diffChildren

@JoviDeCroock JoviDeCroock force-pushed the fix-subsequent-replace-nodes branch from 84f64ad to f2b8600 Compare January 22, 2020 23:48

@marvinhagemeister marvinhagemeister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good find! Can only imagine how much time it took to debug this 👍

@marvinhagemeister marvinhagemeister changed the title Avoid removing existing dom nodes on subsequent replaceNode calls Avoid removing existing dom nodes on subsequent replaceNode cal… Jan 23, 2020
@marvinhagemeister marvinhagemeister merged commit 6cc97cd into master Jan 23, 2020
@marvinhagemeister marvinhagemeister deleted the fix-subsequent-replace-nodes branch January 23, 2020 05:37
porfirioribeiro pushed a commit to porfirioribeiro/preact that referenced this pull request Feb 3, 2020
…actjs#2274)

Avoid removing existing dom nodes on subsequent replaceNode calls
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.

Preact 10 rendering into document.body clobbers existing DOM nodes App breaks after root update if rendered with replaceNode

3 participants