Caleb Porzio 2 년 전
부모
커밋
f3616c8706
1개의 변경된 파일13개의 추가작업 그리고 2개의 파일을 삭제
  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))
+        })
     })
 })