Skip to content

Commit

Permalink
🐛 Cleans up Teleport clones
Browse files Browse the repository at this point in the history
  • Loading branch information
ekwoka committed Aug 2, 2024
1 parent 8630bac commit fadd710
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/alpinejs/src/directives/x-teleport.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { skipDuringClone } from "../clone"
import { directive } from "../directives"
import { initTree } from "../lifecycle"
import { initTree, destroyTree } from "../lifecycle"
import { mutateDom } from "../mutation"
import { addScopeToNode } from "../scope"
import { warn } from "../utils/warn"
Expand Down Expand Up @@ -64,7 +64,12 @@ directive('teleport', (el, { modifiers, expression }, { cleanup }) => {
})
}

cleanup(() => clone.remove())
cleanup(() =>
mutateDom(() => {
clone.remove()
destroyTree(clone)
})
)
})

let teleportContainerDuringClone = document.createElement('div')
Expand Down

0 comments on commit fadd710

Please sign in to comment.