Skip to content

Commit

Permalink
fix (#4015)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebporzio authored Feb 5, 2024
1 parent bf36275 commit 84fd08d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/alpinejs/src/directives/x-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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') {
Expand Down
6 changes: 4 additions & 2 deletions packages/alpinejs/src/directives/x-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -33,7 +35,7 @@ directive('if', (el, { expression }, { effect, cleanup }) => {
node._x_effects.forEach(dequeueJob)
}
})

clone.remove();

delete el._x_currentIfEl
Expand Down

0 comments on commit 84fd08d

Please sign in to comment.