Skip to content

Commit

Permalink
Fix deep morphdom key bug
Browse files Browse the repository at this point in the history
  • Loading branch information
calebporzio committed Oct 31, 2024
1 parent 7e636ec commit 021d602
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/morph/src/morph.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export function morph(from, toHtml, options) {
from.appendChild(holdover)

currentFrom = holdover
fromKey = getKey(currentFrom)
} else {
if(! shouldSkip(adding, currentTo)) {
// Add element...
Expand Down Expand Up @@ -256,6 +257,7 @@ export function morph(from, toHtml, options) {
// No "from" key...
currentFrom.replaceWith(fromKeys[toKey])
currentFrom = fromKeys[toKey]
fromKey = getKey(currentFrom)
}
}

Expand All @@ -267,6 +269,7 @@ export function morph(from, toHtml, options) {
fromKeyHoldovers[fromKey] = currentFrom
currentFrom.replaceWith(fromKeyNode)
currentFrom = fromKeyNode
fromKey = getKey(currentFrom)
} else {
// Swap elements with keys...
fromKeyHoldovers[fromKey] = currentFrom; // This ";" needs to be here...
Expand Down

0 comments on commit 021d602

Please sign in to comment.