File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,8 @@ export function mixin(Vue: VueConstructor) {
149
149
}
150
150
}
151
151
152
- function customReactive ( target : object ) {
152
+ function customReactive ( target : object , visited = new Set ( ) ) {
153
+ if ( visited . has ( target ) ) return
153
154
if (
154
155
! isPlainObject ( target ) ||
155
156
isRef ( target ) ||
@@ -165,7 +166,8 @@ export function mixin(Vue: VueConstructor) {
165
166
const val = target [ k ]
166
167
defineReactive ( target , k , val )
167
168
if ( val ) {
168
- customReactive ( val )
169
+ visited . add ( val )
170
+ customReactive ( val , visited )
169
171
}
170
172
return
171
173
} )
Original file line number Diff line number Diff line change @@ -5,9 +5,12 @@ import {
5
5
ref ,
6
6
nextTick ,
7
7
SetupContext ,
8
+ getCurrentInstance ,
8
9
} from '../src'
10
+ import { mockWarn } from './helpers'
9
11
10
12
describe ( 'setupContext' , ( ) => {
13
+ mockWarn ( true )
11
14
it ( 'should have proper properties' , ( ) => {
12
15
let context : SetupContext = undefined !
13
16
@@ -195,4 +198,31 @@ describe('setupContext', () => {
195
198
196
199
expect ( _attrs . foo ) . toBe ( 'bar2' )
197
200
} )
201
+
202
+ // #563
203
+ it ( 'should not RangeError: Maximum call stack size exceeded' , async ( ) => {
204
+ createApp (
205
+ defineComponent ( {
206
+ template : `<div/>` ,
207
+ setup ( ) {
208
+ // @ts -expect-error
209
+ const app = getCurrentInstance ( ) . proxy
210
+ let mockNT : any = [ ]
211
+ mockNT . __ob__ = { }
212
+ const test = {
213
+ app,
214
+ mockNT,
215
+ }
216
+ return {
217
+ test,
218
+ }
219
+ } ,
220
+ } )
221
+ ) . mount ( )
222
+
223
+ await nextTick ( )
224
+ expect (
225
+ `"RangeError: Maximum call stack size exceeded"`
226
+ ) . not . toHaveBeenWarned ( )
227
+ } )
198
228
} )
You can’t perform that action at this time.
0 commit comments