diff --git a/packages/alpinejs/src/mutation.js b/packages/alpinejs/src/mutation.js index dedf1cc9a..e669c5429 100644 --- a/packages/alpinejs/src/mutation.js +++ b/packages/alpinejs/src/mutation.js @@ -196,6 +196,7 @@ function onMutate(mutations) { for (let node of addedNodes) { // If the node was eventually removed as part of one of his // parent mutations, skip it + if (removedNodes.has(node)) continue if (! node.isConnected) continue delete node._x_ignoreSelf diff --git a/tests/cypress/integration/mutation.spec.js b/tests/cypress/integration/mutation.spec.js index 0c1f48a7d..283de6c70 100644 --- a/tests/cypress/integration/mutation.spec.js +++ b/tests/cypress/integration/mutation.spec.js @@ -219,3 +219,27 @@ test('no side effects when directives are added to an element that is removed af get('span').should(haveText('0')) } ) +test( + "previously initialized elements are not reinitialized on being moved", + html` + +