File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ export function del (obj, key) {
50
50
delete obj [ key ]
51
51
var ob = obj . __ob__
52
52
if ( ! ob ) {
53
+ if ( obj . _isVue ) {
54
+ delete obj . _data [ key ]
55
+ obj . _digest ( )
56
+ }
53
57
return
54
58
}
55
59
ob . dep . notify ( )
Original file line number Diff line number Diff line change @@ -286,6 +286,25 @@ describe('Observer', function () {
286
286
expect ( dep3 . notify . calls . count ( ) ) . toBe ( 2 )
287
287
} )
288
288
289
+ it ( 'observing set/delete in Vm object' , function ( done ) {
290
+ var el = document . createElement ( 'div' )
291
+ var vm = new Vue ( {
292
+ el : el ,
293
+ template : '<div>{{a}}</div>' ,
294
+ data : { a : 1 }
295
+ } )
296
+ expect ( el . innerHTML ) . toBe ( '<div>1</div>' )
297
+ Vue . set ( vm , 'a' , 2 )
298
+ Vue . nextTick ( function ( ) {
299
+ expect ( el . innerHTML ) . toBe ( '<div>2</div>' )
300
+ Vue . delete ( vm , 'a' )
301
+ Vue . nextTick ( function ( ) {
302
+ expect ( el . innerHTML ) . toBe ( '<div></div>' )
303
+ done ( )
304
+ } )
305
+ } )
306
+ } )
307
+
289
308
it ( 'observing array mutation' , function ( ) {
290
309
var arr = [ ]
291
310
var ob = observe ( arr )
You can’t perform that action at this time.
0 commit comments