File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,15 @@ import { isRef, UnwrapRef } from './ref'
1515import { rawSet , accessModifiedSet } from '../utils/sets'
1616
1717export function isRaw ( obj : any ) : boolean {
18- return Boolean ( obj ?. __ob__ && obj . __ob__ ?. __raw__ )
18+ return Boolean (
19+ obj ?. __ob__ && typeof obj . __ob__ === 'object' && obj . __ob__ ?. __raw__
20+ )
1921}
2022
2123export function isReactive ( obj : any ) : boolean {
22- return Boolean ( obj ?. __ob__ && ! obj . __ob__ ?. __raw__ )
24+ return Boolean (
25+ obj ?. __ob__ && typeof obj . __ob__ === 'object' && ! obj . __ob__ ?. __raw__
26+ )
2327}
2428
2529/**
Original file line number Diff line number Diff line change @@ -1169,4 +1169,28 @@ describe('setup', () => {
11691169
11701170 expect ( warn ) . not . toBeCalled ( )
11711171 } )
1172+
1173+ it ( 'should work with mock objects' , async ( ) => {
1174+ const originalProxy = new Proxy (
1175+ { } ,
1176+ {
1177+ get ( ) {
1178+ return jest . fn ( )
1179+ } ,
1180+ }
1181+ )
1182+
1183+ const opts = {
1184+ template : `<div/>` ,
1185+ setup ( ) {
1186+ return {
1187+ proxy : originalProxy ,
1188+ }
1189+ } ,
1190+ }
1191+ const Constructor = Vue . extend ( opts ) . extend ( { } )
1192+
1193+ const vm = new Vue ( Constructor ) . $mount ( )
1194+ expect ( vm . proxy ) . toBe ( originalProxy )
1195+ } )
11721196} )
You can’t perform that action at this time.
0 commit comments