Bläddra i källkod

Revert to previous stage

The only way to apply this on the node is to execute it on the
mutation. Otherwise, we have to rewrite a big part of the lifecycle
system.
Alexandre Lepretre 1 år sedan
förälder
incheckning
83456d3c7c
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 0 3
      packages/alpinejs/src/lifecycle.js
  2. 5 0
      packages/alpinejs/src/mutation.js

+ 0 - 3
packages/alpinejs/src/lifecycle.js

@@ -82,9 +82,6 @@ export function interceptInit(callback) { initInterceptors.push(callback) }
 export function initTree(el, walker = walk, intercept = () => {}) {
 export function initTree(el, walker = walk, intercept = () => {}) {
     deferHandlingDirectives(() => {
     deferHandlingDirectives(() => {
         walker(el, (el, skip) => {
         walker(el, (el, skip) => {
-            if (el._x_isInit) return;
-            el._x_isInit = true
-
             intercept(el, skip)
             intercept(el, skip)
 
 
             initInterceptors.forEach(i => i(el, skip))
             initInterceptors.forEach(i => i(el, skip))

+ 5 - 0
packages/alpinejs/src/mutation.js

@@ -194,10 +194,15 @@ function onMutate(mutations) {
         node._x_ignore = true
         node._x_ignore = true
     })
     })
     for (let node of addedNodes) {
     for (let node of addedNodes) {
+        // If the node is already init, it means it's a move operation
+        if (node._x_isInit) continue
+
         // If the node was eventually removed as part of one of his
         // If the node was eventually removed as part of one of his
         // parent mutations, skip it
         // parent mutations, skip it
         if (! node.isConnected) continue
         if (! node.isConnected) continue
 
 
+        node._x_isInit = true
+
         delete node._x_ignoreSelf
         delete node._x_ignoreSelf
         delete node._x_ignore
         delete node._x_ignore
         onElAddeds.forEach(i => i(node))
         onElAddeds.forEach(i => i(node))