Caleb Porzio 3 rokov pred
rodič
commit
f35b578a74

+ 2 - 0
packages/alpinejs/src/magics/$watch.js

@@ -22,6 +22,8 @@ magic('watch', el => (key, callback) => {
 
 
                 oldValue = value
                 oldValue = value
             })
             })
+        } else {
+            oldValue = value
         }
         }
 
 
         firstTime = false
         firstTime = false

+ 1 - 1
tests/cypress/integration/magics/$watch.spec.js

@@ -21,7 +21,7 @@ test('$watch',
     }
     }
 )
 )
 
 
-test('$watch receives old value',
+test.only('$watch receives old value',
     html`
     html`
         <div
         <div
             x-data="{ foo: 'bar', fresh: '', old: '' }"
             x-data="{ foo: 'bar', fresh: '', old: '' }"