@@ -8,12 +8,11 @@ import {
8
8
} from '@vue/reactivity'
9
9
import {
10
10
ComponentPublicInstance ,
11
- ComponentPublicProxyTarget ,
12
11
PublicInstanceProxyHandlers ,
13
12
RuntimeCompiledPublicInstanceProxyHandlers ,
14
- createDevProxyTarget ,
15
- exposePropsOnDevProxyTarget ,
16
- exposeSetupStateOnDevProxyTarget
13
+ createRenderContext ,
14
+ exposePropsOnRenderContext ,
15
+ exposeSetupStateOnRenderContext
17
16
} from './componentProxy'
18
17
import { ComponentPropsOptions , initProps } from './componentProps'
19
18
import { Slots , initSlots , InternalSlots } from './componentSlots'
@@ -136,30 +135,30 @@ export interface ComponentInternalInstance {
136
135
components : Record < string , Component >
137
136
directives : Record < string , Directive >
138
137
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
141
151
data : Data
142
152
props : Data
143
153
attrs : Data
144
154
slots : InternalSlots
145
- proxy : ComponentPublicInstance | null
146
155
refs : Data
147
156
emit : EmitFn
148
157
149
158
// setup
150
159
setupState : Data
151
160
setupContext : SetupContext | null
152
161
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
-
163
162
// suspense related
164
163
suspense : SuspenseBoundary | null
165
164
asyncDep : Promise < any > | null
@@ -211,15 +210,14 @@ export function createComponentInstance(
211
210
update : null ! , // will be set synchronously right after creation
212
211
render : null ,
213
212
proxy : null ,
214
- proxyTarget : null ! , // to be immediately set
215
213
withProxy : null ,
216
214
effects : null ,
217
215
provides : parent ? parent . provides : Object . create ( appContext . provides ) ,
218
216
accessCache : null ! ,
219
217
renderCache : [ ] ,
220
218
221
219
// state
222
- renderContext : EMPTY_OBJ ,
220
+ ctx : EMPTY_OBJ ,
223
221
data : EMPTY_OBJ ,
224
222
props : EMPTY_OBJ ,
225
223
attrs : EMPTY_OBJ ,
@@ -258,9 +256,9 @@ export function createComponentInstance(
258
256
emit : null as any // to be set immediately
259
257
}
260
258
if ( __DEV__ ) {
261
- instance . proxyTarget = createDevProxyTarget ( instance )
259
+ instance . ctx = createRenderContext ( instance )
262
260
} else {
263
- instance . proxyTarget = { _ : instance }
261
+ instance . ctx = { _ : instance }
264
262
}
265
263
instance . root = parent ? parent . root : instance
266
264
instance . emit = emit . bind ( null , instance )
@@ -335,9 +333,9 @@ function setupStatefulComponent(
335
333
// 0. create render proxy property access cache
336
334
instance . accessCache = { }
337
335
// 1. create public instance / render proxy
338
- instance . proxy = new Proxy ( instance . proxyTarget , PublicInstanceProxyHandlers )
336
+ instance . proxy = new Proxy ( instance . ctx , PublicInstanceProxyHandlers )
339
337
if ( __DEV__ ) {
340
- exposePropsOnDevProxyTarget ( instance )
338
+ exposePropsOnRenderContext ( instance )
341
339
}
342
340
// 2. call setup()
343
341
const { setup } = Component
@@ -399,7 +397,7 @@ export function handleSetupResult(
399
397
// assuming a render function compiled from template is present.
400
398
instance . setupState = reactive ( setupResult )
401
399
if ( __DEV__ ) {
402
- exposeSetupStateOnDevProxyTarget ( instance )
400
+ exposeSetupStateOnRenderContext ( instance )
403
401
}
404
402
} else if ( __DEV__ && setupResult !== undefined ) {
405
403
warn (
@@ -469,7 +467,7 @@ function finishComponentSetup(
469
467
// also only allows a whitelist of globals to fallthrough.
470
468
if ( instance . render . _rc ) {
471
469
instance . withProxy = new Proxy (
472
- instance . proxyTarget ,
470
+ instance . ctx ,
473
471
RuntimeCompiledPublicInstanceProxyHandlers
474
472
)
475
473
}
0 commit comments