Caleb Porzio hace 1 año
padre
commit
3f33d14a8b

+ 3 - 1
packages/alpinejs/src/directives/x-for.js

@@ -6,6 +6,7 @@ import { initTree } from '../lifecycle'
 import { mutateDom } from '../mutation'
 import { warn } from '../utils/warn'
 import { dequeueJob } from '../scheduler'
+import { skipDuringClone } from '../clone'
 
 directive('for', (el, { expression }, { effect, cleanup }) => {
     let iteratorNames = parseForExpression(expression)
@@ -205,7 +206,8 @@ function loop(el, iteratorNames, evaluateItems, evaluateKey) {
             mutateDom(() => {
                 lastEl.after(clone)
 
-                initTree(clone)
+                // These nodes will be "inited" as morph walks the tree...
+                skipDuringClone(() => initTree(clone))()
             })
 
             if (typeof key === 'object') {

+ 4 - 2
packages/alpinejs/src/directives/x-if.js

@@ -6,6 +6,7 @@ import { mutateDom } from '../mutation'
 import { walk } from "../utils/walk"
 import { dequeueJob } from '../scheduler'
 import { warn } from "../utils/warn"
+import { skipDuringClone } from '../clone'
 
 directive('if', (el, { expression }, { effect, cleanup }) => {
     if (el.tagName.toLowerCase() !== 'template') warn('x-if can only be used on a <template> tag', el)
@@ -22,7 +23,8 @@ directive('if', (el, { expression }, { effect, cleanup }) => {
         mutateDom(() => {
             el.after(clone)
 
-            initTree(clone)
+            // These nodes will be "inited" as morph walks the tree...
+            skipDuringClone(() => initTree(clone))()
         })
 
         el._x_currentIfEl = clone
@@ -33,7 +35,7 @@ directive('if', (el, { expression }, { effect, cleanup }) => {
                     node._x_effects.forEach(dequeueJob)
                 }
             })
-            
+
             clone.remove();
 
             delete el._x_currentIfEl