Parcourir la source

Prevent x-bind objects from being observed

Caleb Porzio il y a 3 ans
Parent
commit
006e521114
1 fichiers modifiés avec 19 ajouts et 21 suppressions
  1. 19 21
      packages/alpinejs/src/directives/x-bind.js

+ 19 - 21
packages/alpinejs/src/directives/x-bind.js

@@ -32,33 +32,31 @@ function applyBindingsObject(el, expression, original, effect) {
 
     let cleanupRunners = []
 
-    effect(() => {
-        while (cleanupRunners.length) cleanupRunners.pop()()
+    while (cleanupRunners.length) cleanupRunners.pop()()
 
-        getBindings(bindings => {
-            let attributes = Object.entries(bindings).map(([name, value]) => ({ name, value }))
+    getBindings(bindings => {
+        let attributes = Object.entries(bindings).map(([name, value]) => ({ name, value }))
 
-            let staticAttributes = attributesOnly(attributes)
-            
-            // Handle binding normal HTML attributes (non-Alpine directives).
-            attributes = attributes.map(attribute => {
-                if (staticAttributes.find(attr => attr.name === attribute.name)) {
-                    return {
-                        name: `x-bind:${attribute.name}`,
-                        value: `"${attribute.value}"`,
-                    }
+        let staticAttributes = attributesOnly(attributes)
+        
+        // Handle binding normal HTML attributes (non-Alpine directives).
+        attributes = attributes.map(attribute => {
+            if (staticAttributes.find(attr => attr.name === attribute.name)) {
+                return {
+                    name: `x-bind:${attribute.name}`,
+                    value: `"${attribute.value}"`,
                 }
+            }
 
-                return attribute
-            })
+            return attribute
+        })
 
-            directives(el, attributes, original).map(handle => {
-                cleanupRunners.push(handle.runCleanups)
+        directives(el, attributes, original).map(handle => {
+            cleanupRunners.push(handle.runCleanups)
 
-                handle()
-            })
-        }, { scope: bindingProviders } )
-    })
+            handle()
+        })
+    }, { scope: bindingProviders } )
 }
 
 function storeKeyForXFor(el, expression) {