Skip to content

Fix root id-change patch corruption - #4335

Closed
lukaszsamson wants to merge 1 commit into
phoenixframework:mainfrom
lukaszsamson:ls-fix-root-id-corruption
Closed

Fix root id-change patch corruption#4335
lukaszsamson wants to merge 1 commit into
phoenixframework:mainfrom
lukaszsamson:ls-fix-root-id-corruption

Conversation

@lukaszsamson

Copy link
Copy Markdown
Contributor

The previous code returned the result of onNodeAdded which is undefined. Morphdom aborts an element morph only when onBeforeElUpdated returns strictly false

https://github.com/patrick-steele-idem/morphdom/blob/8e004ca546b428dbe5a5e34a78b8af6179f85013/src/morphdom.js#L219-L222

It continued with attribute and child morphing using:

  • fromEl - the detached old root
  • toEl - the visible replacement root

This PR changes it to recursively apply onNodeAdded for the replacement and its children. It also explicitly returns false to stop morphdom from processing the detached old root

Screen.Recording.2026-07-22.at.11.17.46.mov

Fixes #4334

@SteffenDE

Copy link
Copy Markdown
Member

Thank you @lukaszsamson. I think the original fix for #3423 is actually wrong and this should be handled in morphdom instead, see patrick-steele-idem/morphdom#290.

I opened #4338.

SteffenDE added a commit that referenced this pull request Jul 23, 2026
zekedou pushed a commit to plastic-forks/phoenix_live_view that referenced this pull request Aug 1, 2026
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.

Root id change replacement corrupts DOM patch and removes new children

2 participants