diff --git a/packages/diffhtml/lib/transaction.js b/packages/diffhtml/lib/transaction.js index abdf7e5b..91f02a22 100644 --- a/packages/diffhtml/lib/transaction.js +++ b/packages/diffhtml/lib/transaction.js @@ -149,6 +149,12 @@ export default class Transaction { this.endedCallbacks = new Set(); StateCache.set(mount, this.state); + + // When a previous mount is injected into a new location, remove the + // state held for it, this allows previously diffed elements to be updated. + if (StateCache.has(input)) { + StateCache.delete(input); + } } /** diff --git a/packages/diffhtml/test/integration/inner.js b/packages/diffhtml/test/integration/inner.js index d250abee..559a8a88 100644 --- a/packages/diffhtml/test/integration/inner.js +++ b/packages/diffhtml/test/integration/inner.js @@ -354,6 +354,24 @@ describe('Integration: innerHTML', function() { diff.innerHTML(this.fixture, diff.html`
after
after
Test
Test 2
Test 2