@@ -10,12 +10,12 @@ import {
10
10
import {
11
11
ComponentPublicInstance ,
12
12
PublicInstanceProxyHandlers ,
13
- RuntimeCompiledPublicInstanceProxyHandlers ,
14
13
createRenderContext ,
15
14
exposePropsOnRenderContext ,
16
15
exposeSetupStateOnRenderContext ,
17
16
ComponentPublicInstanceConstructor ,
18
- publicPropertiesMap
17
+ publicPropertiesMap ,
18
+ RuntimeCompiledPublicInstanceProxyHandlers
19
19
} from './componentPublicInstance'
20
20
import {
21
21
ComponentPropsOptions ,
@@ -711,18 +711,24 @@ type CompileFunction = (
711
711
) => InternalRenderFunction
712
712
713
713
let compile : CompileFunction | undefined
714
-
715
- // dev only
716
- export const isRuntimeOnly = ( ) => ! compile
714
+ let installWithProxy : ( i : ComponentInternalInstance ) => void
717
715
718
716
/**
719
717
* For runtime-dom to register the compiler.
720
718
* Note the exported method uses any to avoid d.ts relying on the compiler types.
721
719
*/
722
720
export function registerRuntimeCompiler ( _compile : any ) {
723
721
compile = _compile
722
+ installWithProxy = i => {
723
+ if ( i . render ! . _rc ) {
724
+ i . withProxy = new Proxy ( i . ctx , RuntimeCompiledPublicInstanceProxyHandlers )
725
+ }
726
+ }
724
727
}
725
728
729
+ // dev only
730
+ export const isRuntimeOnly = ( ) => ! compile
731
+
726
732
export function finishComponentSetup (
727
733
instance : ComponentInternalInstance ,
728
734
isSSR : boolean ,
@@ -792,11 +798,8 @@ export function finishComponentSetup(
792
798
// for runtime-compiled render functions using `with` blocks, the render
793
799
// proxy used needs a different `has` handler which is more performant and
794
800
// also only allows a whitelist of globals to fallthrough.
795
- if ( instance . render . _rc ) {
796
- instance . withProxy = new Proxy (
797
- instance . ctx ,
798
- RuntimeCompiledPublicInstanceProxyHandlers
799
- )
801
+ if ( installWithProxy ) {
802
+ installWithProxy ( instance )
800
803
}
801
804
}
802
805
0 commit comments