File tree 2 files changed +21
-13
lines changed
2 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -193,4 +193,20 @@ describe('watch', () => {
193
193
scope . stop ( )
194
194
expect ( calls ) . toEqual ( [ 'sync 2' , 'post 2' ] )
195
195
} )
196
+
197
+ test ( 'once option should be ignored by simple watch' , async ( ) => {
198
+ let dummy : any
199
+ const source = ref ( 0 )
200
+ watch (
201
+ ( ) => {
202
+ dummy = source . value
203
+ } ,
204
+ null ,
205
+ { once : true } ,
206
+ )
207
+ expect ( dummy ) . toBe ( 0 )
208
+
209
+ source . value ++
210
+ expect ( dummy ) . toBe ( 1 )
211
+ } )
196
212
} )
Original file line number Diff line number Diff line change @@ -218,19 +218,11 @@ export function watch(
218
218
}
219
219
}
220
220
221
- if ( once ) {
222
- if ( cb ) {
223
- const _cb = cb
224
- cb = ( ...args ) => {
225
- _cb ( ...args )
226
- watchHandle ( )
227
- }
228
- } else {
229
- const _getter = getter
230
- getter = ( ) => {
231
- _getter ( )
232
- watchHandle ( )
233
- }
221
+ if ( once && cb ) {
222
+ const _cb = cb
223
+ cb = ( ...args ) => {
224
+ _cb ( ...args )
225
+ watchHandle ( )
234
226
}
235
227
}
236
228
You can’t perform that action at this time.
0 commit comments