File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -233,11 +233,11 @@ Watcher.prototype.run = function () {
233
233
var value = this . get ( )
234
234
if (
235
235
value !== this . value ||
236
- // Deep watchers and Array watchers should fire even
236
+ // Deep watchers and watchers on Object/Arrays should fire even
237
237
// when the value is the same, because the value may
238
238
// have mutated; but only do so if this is a
239
239
// non-shallow update (caused by a vm digest).
240
- ( ( isArray ( value ) || this . deep ) && ! this . shallow )
240
+ ( ( isObject ( value ) || this . deep ) && ! this . shallow )
241
241
) {
242
242
// set new value
243
243
var oldValue = this . value
Original file line number Diff line number Diff line change @@ -289,6 +289,20 @@ describe('Watcher', function () {
289
289
} )
290
290
} )
291
291
292
+ it ( 'fire change for prop addition/deletion in non-deep mode' , function ( done ) {
293
+ new Watcher ( vm , 'b' , spy )
294
+ Vue . set ( vm . b , 'e' , 123 )
295
+ nextTick ( function ( ) {
296
+ expect ( spy ) . toHaveBeenCalledWith ( vm . b , vm . b )
297
+ expect ( spy . calls . count ( ) ) . toBe ( 1 )
298
+ Vue . delete ( vm . b , 'e' )
299
+ nextTick ( function ( ) {
300
+ expect ( spy . calls . count ( ) ) . toBe ( 2 )
301
+ done ( )
302
+ } )
303
+ } )
304
+ } )
305
+
292
306
it ( 'watch function' , function ( done ) {
293
307
var watcher = new Watcher ( vm , function ( ) {
294
308
return this . a + this . b . d
You can’t perform that action at this time.
0 commit comments