File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
test/unit/features/options Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 3
3
import { _Set as Set , isObject } from '../util/index'
4
4
import type { SimpleSet } from '../util/index'
5
5
import VNode from '../vdom/vnode'
6
+ import Vue from '../instance/index'
7
+
6
8
7
9
const seenObjects = new Set ( )
8
10
@@ -19,7 +21,7 @@ export function traverse (val: any) {
19
21
function _traverse ( val : any , seen : SimpleSet ) {
20
22
let i , keys
21
23
const isA = Array . isArray ( val )
22
- if ( ( ! isA && ! isObject ( val ) ) || Object . isFrozen ( val ) || val instanceof VNode ) {
24
+ if ( ( ! isA && ! isObject ( val ) ) || Object . isFrozen ( val ) || val instanceof VNode || val instanceof Vue ) {
23
25
return
24
26
}
25
27
if ( val . __ob__ ) {
Original file line number Diff line number Diff line change @@ -106,6 +106,29 @@ describe('Options watch', () => {
106
106
} ) . then ( done )
107
107
} )
108
108
109
+ it ( 'with option: deep and with reference to a Vue instance' , done => {
110
+ const vueInstance = new Vue ( ) ;
111
+ const vm = new Vue ( {
112
+ data : { a : { b : vueInstance } } ,
113
+ watch : {
114
+ a : {
115
+ handler : spy ,
116
+ deep : true
117
+ }
118
+ }
119
+ } )
120
+ const oldA = vm . a
121
+ expect ( spy ) . not . toHaveBeenCalled ( )
122
+ vm . a . b = 2
123
+ expect ( spy ) . not . toHaveBeenCalled ( )
124
+ waitForUpdate ( ( ) => {
125
+ expect ( spy ) . toHaveBeenCalledWith ( vm . a , vm . a )
126
+ vm . a = { b : 3 }
127
+ } ) . then ( ( ) => {
128
+ expect ( spy ) . toHaveBeenCalledWith ( vm . a , oldA )
129
+ } ) . then ( done )
130
+ } )
131
+
109
132
it ( 'correctly merges multiple extends' , done => {
110
133
const spy2 = jasmine . createSpy ( 'A' )
111
134
const spy3 = jasmine . createSpy ( 'B' )
You can’t perform that action at this time.
0 commit comments