File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import {
20
20
WatcherPostFlushQueueKey ,
21
21
} from '../utils/symbols'
22
22
import { getCurrentScopeVM } from './effectScope'
23
+ import { rawSet } from '../utils/sets'
23
24
24
25
export type WatchEffect = ( onInvalidate : InvalidateCbRegistrator ) => void
25
26
@@ -475,7 +476,7 @@ export function watch<T = any>(
475
476
}
476
477
477
478
function traverse ( value : unknown , seen : Set < unknown > = new Set ( ) ) {
478
- if ( ! isObject ( value ) || seen . has ( value ) ) {
479
+ if ( ! isObject ( value ) || seen . has ( value ) || rawSet . has ( value ) ) {
479
480
return value
480
481
}
481
482
seen . add ( value )
Original file line number Diff line number Diff line change 7
7
set,
8
8
computed,
9
9
nextTick,
10
+ markRaw,
10
11
} = require ( '../../src' )
11
12
const { mockWarn } = require ( '../helpers' )
12
13
@@ -177,6 +178,34 @@ describe('api/watch', () => {
177
178
. then ( done )
178
179
} )
179
180
181
+ it ( 'markRaw' , ( done ) => {
182
+ const nestedState = ref ( 100 )
183
+
184
+ const state = ref ( {
185
+ rawValue : markRaw ( {
186
+ nestedState,
187
+ } ) ,
188
+ } )
189
+
190
+ watch (
191
+ state ,
192
+ ( ) => {
193
+ spy ( )
194
+ } ,
195
+ { deep : true }
196
+ )
197
+
198
+ function changeRawValue ( ) {
199
+ nestedState . value = Math . random ( )
200
+ }
201
+
202
+ changeRawValue ( )
203
+
204
+ waitForUpdate ( ( ) => {
205
+ expect ( spy ) . not . toBeCalled ( )
206
+ } ) . then ( done )
207
+ } )
208
+
180
209
it ( 'should flush after render (immediate=false)' , ( done ) => {
181
210
let rerenderedText
182
211
const vm = new Vue ( {
You can’t perform that action at this time.
0 commit comments