Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
calebporzio committed Jul 16, 2024
1 parent 09b9cdd commit adab95e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/alpinejs/src/directives/x-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ directive('for', (el, { expression }, { effect, cleanup }) => {
effect(() => loop(el, iteratorNames, evaluateItems, evaluateKey))

cleanup(() => {
Object.values(el._x_lookup).forEach(el =>
Object.values(el._x_lookup).forEach(el =>
mutateDom(() => {
destroyTree(el)

el.remove()
}))
}
))

delete el._x_prevKeys
delete el._x_lookup
Expand Down Expand Up @@ -142,13 +144,15 @@ function loop(el, iteratorNames, evaluateItems, evaluateKey) {
// for browser performance.

// We'll remove all the nodes that need to be removed,
// letting the mutation observer pick them up and
// clean up any side effects they had.
// and clean up any side effects they had.
for (let i = 0; i < removes.length; i++) {
let key = removes[i]
if (!(key in lookup)) continue

if (! (key in lookup)) continue

mutateDom(() => {
destroyTree(lookup[key])

lookup[key].remove()
})

Expand Down
3 changes: 2 additions & 1 deletion packages/alpinejs/src/directives/x-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ directive('if', (el, { expression }, { effect, cleanup }) => {
el._x_undoIf = () => {
mutateDom(() => {
destroyTree(clone)

clone.remove()
})

Expand All @@ -40,7 +41,7 @@ directive('if', (el, { expression }, { effect, cleanup }) => {
}

let hide = () => {
if (!el._x_undoIf) return
if (! el._x_undoIf) return

el._x_undoIf()

Expand Down

0 comments on commit adab95e

Please sign in to comment.