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 () {
233233 var value = this . get ( )
234234 if (
235235 value !== this . value ||
236- // Deep watchers and Array watchers should fire even
236+ // Deep watchers and watchers on Object/Arrays should fire even
237237 // when the value is the same, because the value may
238238 // have mutated; but only do so if this is a
239239 // non-shallow update (caused by a vm digest).
240- ( ( isArray ( value ) || this . deep ) && ! this . shallow )
240+ ( ( isObject ( value ) || this . deep ) && ! this . shallow )
241241 ) {
242242 // set new value
243243 var oldValue = this . value
Original file line number Diff line number Diff line change @@ -289,6 +289,20 @@ describe('Watcher', function () {
289289 } )
290290 } )
291291
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+
292306 it ( 'watch function' , function ( done ) {
293307 var watcher = new Watcher ( vm , function ( ) {
294308 return this . a + this . b . d
You can’t perform that action at this time.
0 commit comments