فهرست منبع

fix: already init component

Alexandre Lepretre 1 سال پیش
والد
کامیت
2bb702f8e7
2فایلهای تغییر یافته به همراه3 افزوده شده و 4 حذف شده
  1. 3 0
      packages/alpinejs/src/lifecycle.js
  2. 0 4
      packages/alpinejs/src/mutation.js

+ 3 - 0
packages/alpinejs/src/lifecycle.js

@@ -82,6 +82,9 @@ export function interceptInit(callback) { initInterceptors.push(callback) }
 export function initTree(el, walker = walk, intercept = () => {}) {
     deferHandlingDirectives(() => {
         walker(el, (el, skip) => {
+            if (el._x_isInit) return;
+            el._x_isInit = true
+
             intercept(el, skip)
 
             initInterceptors.forEach(i => i(el, skip))

+ 0 - 4
packages/alpinejs/src/mutation.js

@@ -194,10 +194,6 @@ function onMutate(mutations) {
         node._x_ignore = true
     })
     for (let node of addedNodes) {
-        // If an element gets moved on a page, it's registered
-        // as both an "add" and "remove", so we want to skip those.
-        if (removedNodes.includes(node)) continue
-
         // If the node was eventually removed as part of one of his
         // parent mutations, skip it
         if (! node.isConnected) continue