@@ -8,12 +8,11 @@ import {
88} from '@vue/reactivity'
99import {
1010 ComponentPublicInstance ,
11- ComponentPublicProxyTarget ,
1211 PublicInstanceProxyHandlers ,
1312 RuntimeCompiledPublicInstanceProxyHandlers ,
14- createDevProxyTarget ,
15- exposePropsOnDevProxyTarget ,
16- exposeSetupStateOnDevProxyTarget
13+ createRenderContext ,
14+ exposePropsOnRenderContext ,
15+ exposeSetupStateOnRenderContext
1716} from './componentProxy'
1817import { ComponentPropsOptions , initProps } from './componentProps'
1918import { Slots , initSlots , InternalSlots } from './componentSlots'
@@ -136,30 +135,30 @@ export interface ComponentInternalInstance {
136135 components : Record < string , Component >
137136 directives : Record < string , Directive >
138137
139- // the rest are only for stateful components
140- renderContext : Data
138+ // the rest are only for stateful components ---------------------------------
139+
140+ // main proxy that serves as the public instance (`this`)
141+ proxy : ComponentPublicInstance | null
142+ // alternative proxy used only for runtime-compiled render functions using
143+ // `with` block
144+ withProxy : ComponentPublicInstance | null
145+ // This is the target for the public instance proxy. It also holds properties
146+ // injected by user options (computed, methods etc.) and user-attached
147+ // custom properties (via `this.x = ...`)
148+ ctx : Data
149+
150+ // internal state
141151 data : Data
142152 props : Data
143153 attrs : Data
144154 slots : InternalSlots
145- proxy : ComponentPublicInstance | null
146155 refs : Data
147156 emit : EmitFn
148157
149158 // setup
150159 setupState : Data
151160 setupContext : SetupContext | null
152161
153- // The target object for the public instance proxy. In dev mode, we also
154- // define getters for all known instance properties on it so it can be
155- // properly inspected in the console. These getters are skipped in prod mode
156- // for performance. In addition, any user attached properties
157- // (via `this.x = ...`) are also stored on this object.
158- proxyTarget : ComponentPublicProxyTarget
159- // alternative proxy used only for runtime-compiled render functions using
160- // `with` block
161- withProxy : ComponentPublicInstance | null
162-
163162 // suspense related
164163 suspense : SuspenseBoundary | null
165164 asyncDep : Promise < any > | null
@@ -211,15 +210,14 @@ export function createComponentInstance(
211210 update : null ! , // will be set synchronously right after creation
212211 render : null ,
213212 proxy : null ,
214- proxyTarget : null ! , // to be immediately set
215213 withProxy : null ,
216214 effects : null ,
217215 provides : parent ? parent . provides : Object . create ( appContext . provides ) ,
218216 accessCache : null ! ,
219217 renderCache : [ ] ,
220218
221219 // state
222- renderContext : EMPTY_OBJ ,
220+ ctx : EMPTY_OBJ ,
223221 data : EMPTY_OBJ ,
224222 props : EMPTY_OBJ ,
225223 attrs : EMPTY_OBJ ,
@@ -258,9 +256,9 @@ export function createComponentInstance(
258256 emit : null as any // to be set immediately
259257 }
260258 if ( __DEV__ ) {
261- instance . proxyTarget = createDevProxyTarget ( instance )
259+ instance . ctx = createRenderContext ( instance )
262260 } else {
263- instance . proxyTarget = { _ : instance }
261+ instance . ctx = { _ : instance }
264262 }
265263 instance . root = parent ? parent . root : instance
266264 instance . emit = emit . bind ( null , instance )
@@ -335,9 +333,9 @@ function setupStatefulComponent(
335333 // 0. create render proxy property access cache
336334 instance . accessCache = { }
337335 // 1. create public instance / render proxy
338- instance . proxy = new Proxy ( instance . proxyTarget , PublicInstanceProxyHandlers )
336+ instance . proxy = new Proxy ( instance . ctx , PublicInstanceProxyHandlers )
339337 if ( __DEV__ ) {
340- exposePropsOnDevProxyTarget ( instance )
338+ exposePropsOnRenderContext ( instance )
341339 }
342340 // 2. call setup()
343341 const { setup } = Component
@@ -399,7 +397,7 @@ export function handleSetupResult(
399397 // assuming a render function compiled from template is present.
400398 instance . setupState = reactive ( setupResult )
401399 if ( __DEV__ ) {
402- exposeSetupStateOnDevProxyTarget ( instance )
400+ exposeSetupStateOnRenderContext ( instance )
403401 }
404402 } else if ( __DEV__ && setupResult !== undefined ) {
405403 warn (
@@ -469,7 +467,7 @@ function finishComponentSetup(
469467 // also only allows a whitelist of globals to fallthrough.
470468 if ( instance . render . _rc ) {
471469 instance . withProxy = new Proxy (
472- instance . proxyTarget ,
470+ instance . ctx ,
473471 RuntimeCompiledPublicInstanceProxyHandlers
474472 )
475473 }
0 commit comments