Caleb Porzio hace 1 año
padre
commit
d17b248c6c
Se han modificado 1 ficheros con 4 adiciones y 8 borrados
  1. 4 8
      packages/alpinejs/src/magics/$refs.js

+ 4 - 8
packages/alpinejs/src/magics/$refs.js

@@ -1,4 +1,4 @@
-import { closestRoot } from '../lifecycle'
+import { closestRoot, findClosest } from '../lifecycle'
 import { mergeProxies } from '../scope'
 import { mergeProxies } from '../scope'
 import { magic } from '../magics'
 import { magic } from '../magics'
 
 
@@ -13,13 +13,9 @@ magic('refs', el => {
 function getArrayOfRefObject(el) {
 function getArrayOfRefObject(el) {
     let refObjects = []
     let refObjects = []
 
 
-    let currentEl = el
-
-    while (currentEl) {
-        if (currentEl._x_refs) refObjects.push(currentEl._x_refs)
-
-        currentEl = currentEl.parentNode
-    }
+    findClosest(el, (i) => {
+        if (i._x_refs) refObjects.push(i._x_refs)
+    })
 
 
     return refObjects
     return refObjects
 }
 }