File tree Expand file tree Collapse file tree 2 files changed +21
-13
lines changed
Expand file tree Collapse file tree 2 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -193,4 +193,20 @@ describe('watch', () => {
193193 scope . stop ( )
194194 expect ( calls ) . toEqual ( [ 'sync 2' , 'post 2' ] )
195195 } )
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+ } )
196212} )
Original file line number Diff line number Diff line change @@ -218,19 +218,11 @@ export function watch(
218218 }
219219 }
220220
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 ( )
234226 }
235227 }
236228
You can’t perform that action at this time.
0 commit comments