Caleb Porzio %!s(int64=2) %!d(string=hai) anos
pai
achega
f3616c8706
Modificáronse 1 ficheiros con 13 adicións e 2 borrados
  1. 13 2
      packages/alpinejs/src/directives/x-modelable.js

+ 13 - 2
packages/alpinejs/src/directives/x-modelable.js

@@ -22,7 +22,18 @@ directive('modelable', (el, { expression }, { effect, evaluateLater }) => {
         let outerGet = el._x_model.get
         let outerSet = el._x_model.set
 
-        effect(() => innerSet(outerGet()))
-        effect(() => outerSet(innerGet()))
+        effect(() => {
+            // Putting this operation in a microtask so that
+            // it doesn't get tracked in the effect:
+            let value = outerGet()
+            queueMicrotask(() => innerSet(value))
+        })
+
+        effect(() => {
+            // Putting this operation in a microtask so that
+            // it doesn't get tracked in the effect:
+            let value = innerGet()
+            queueMicrotask(() => outerSet(value))
+        })
     })
 })