Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/idiomorph.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,20 @@ var Idiomorph = (function () {
const oldElt = /** @type {Element} */ (oldNode);
const newElt = /** @type {Element} */ (newNode);

const oldEltId =
/** @type {boolean | string} */
(oldElt instanceof Element) && oldElt.getAttribute("id");
const newEltId =
/** @type {boolean | string} */
(newElt instanceof Element) && newElt.getAttribute("id");

return (
oldElt.nodeType === newElt.nodeType &&
oldElt.tagName === newElt.tagName &&
// If oldElt has an `id` with possible state and it doesn't match newElt.id then avoid morphing.
// If oldEltId is present with possible state and it doesn't match newEltId then avoid morphing.
// We'll still match an anonymous node with an IDed newElt, though, because if it got this far,
// its not persistent, and new nodes can't have any hidden state.
(!oldElt.id || oldElt.id === newElt.id)
(!oldEltId || oldEltId === newEltId)
);
}

Expand Down