@@ -22,23 +22,27 @@ export default function intercept<V>(value: V, key: string, interceptCallback: (
22
22
get ( target , name : string ) {
23
23
if ( name === '__original' )
24
24
return value
25
- if ( Reflect . has ( target , name ) && ( mutatingMethods . get ( value . constructor ) ?. includes ( name ) || registeredClasses . includes ( value . constructor ) ) ) {
26
- const method = Reflect . get ( target , name )
25
+ if ( ! Reflect . has ( target , name ) )
26
+ return
27
+ let property = Reflect . get ( target , name )
28
+ if ( property === target . constructor )
29
+ return property
30
+ if ( (
31
+ mutatingMethods . get ( value . constructor ) ?. includes ( name ) || registeredClasses . includes ( value . constructor )
32
+ ) && typeof property === 'function' ) {
27
33
return ( ...args : any ) => {
28
34
interceptCallback ( key , name , ...args )
29
- method . call ( value , ...args )
35
+ return property . call ( target , ...args )
30
36
}
31
37
} else {
32
- let value = Reflect . get ( target , name )
33
- if ( typeof value === 'function' )
34
- value = value . bind ( target )
35
- return value
38
+ if ( typeof property === 'function' )
39
+ property = property . bind ( target ) ;
40
+ return property ;
36
41
}
37
42
} ,
38
43
set ( target : V , name , value : any ) : boolean {
39
- // if (!target || typeof target !== 'object') return false
40
44
target [ name as keyof typeof target ] = value
41
- interceptCallback ( key , '$$iposDefine' , name , value )
45
+ interceptCallback ( key , '$$iposDefine' , name as any , value )
42
46
return true
43
47
} ,
44
48
} )
0 commit comments