File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ export function nonReactive<T = any>(obj: T): T {
152
152
}
153
153
154
154
// set the vue observable flag at obj
155
- ( obj as any ) . __ob__ = ( observe ( { } ) as any ) . __ob__ ;
155
+ def ( obj , ' __ob__' , ( observe ( { } ) as any ) . __ob__ ) ;
156
156
// mark as nonReactive
157
157
def ( obj , NonReactiveIdentifierKey , NonReactiveIdentifier ) ;
158
158
Original file line number Diff line number Diff line change @@ -276,6 +276,24 @@ describe('setup', () => {
276
276
. then ( done ) ;
277
277
} ) ;
278
278
279
+ it ( "should put a unenumerable '__ob__' for non-reactive object" , ( ) => {
280
+ const clone = obj => JSON . parse ( JSON . stringify ( obj ) ) ;
281
+ const componentSetup = jest . fn ( props => {
282
+ const internalOptions = clone ( props . options ) ;
283
+ return { internalOptions } ;
284
+ } ) ;
285
+ const ExternalComponent = {
286
+ props : [ 'options' ] ,
287
+ setup : componentSetup ,
288
+ } ;
289
+ new Vue ( {
290
+ components : { ExternalComponent } ,
291
+ setup : ( ) => ( { options : { } } ) ,
292
+ template : `<external-component :options="options"></external-component>` ,
293
+ } ) . $mount ( ) ;
294
+ expect ( componentSetup ) . toReturn ( ) ;
295
+ } ) ;
296
+
279
297
it ( 'current vue should exist in nested setup call' , ( ) => {
280
298
const spy = jest . fn ( ) ;
281
299
new Vue ( {
You can’t perform that action at this time.
0 commit comments