Skip to content

Commit

Permalink
Init directives for x-if contents after it's created.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklan committed Jun 17, 2021
1 parent 1509849 commit b9d03fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/alpinejs/src/directives/x-if.js
@@ -1,7 +1,8 @@
import { evaluateLater } from '../evaluator'
import { setStyles } from '../utils/styles'
import { directive } from '../directives'
import { once } from '../utils/once'
import {initTree} from "../lifecycle";
import {addScopeToNode} from "../scope";
import {reactive} from "../reactivity";

directive('if', (el, { modifiers, expression }, { effect, cleanup }) => {
let evaluate = evaluateLater(el, expression)
Expand All @@ -11,6 +12,10 @@ directive('if', (el, { modifiers, expression }, { effect, cleanup }) => {

let clone = el.content.cloneNode(true).firstElementChild

addScopeToNode(clone, reactive(modifiers), el)

initTree(clone)

el.after(clone)

el._x_currentIfEl = clone
Expand Down

0 comments on commit b9d03fe

Please sign in to comment.