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 {
152152 }
153153
154154 // set the vue observable flag at obj
155- ( obj as any ) . __ob__ = ( observe ( { } ) as any ) . __ob__ ;
155+ def ( obj , ' __ob__' , ( observe ( { } ) as any ) . __ob__ ) ;
156156 // mark as nonReactive
157157 def ( obj , NonReactiveIdentifierKey , NonReactiveIdentifier ) ;
158158
Original file line number Diff line number Diff line change @@ -276,6 +276,24 @@ describe('setup', () => {
276276 . then ( done ) ;
277277 } ) ;
278278
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+
279297 it ( 'current vue should exist in nested setup call' , ( ) => {
280298 const spy = jest . fn ( ) ;
281299 new Vue ( {
You can’t perform that action at this time.
0 commit comments