}
const instance = render(demo as any, {}, '#host')
- const { change } = instance.proxy as any
+ const { change } = instance.setupState as any
expect(calls).toEqual(['pre 0', 'sync 0', 'render 0'])
calls.length = 0
parent: ComponentInternalInstance | null
- // TODO: type
- proxy: Data | null
-
// state
props: Data
setupState: Data
// resolved props and emits options
propsOptions: normalizePropsOptions(component),
// emitsOptions: normalizeEmitsOptions(type, appContext), // TODO:
- proxy: null,
// state
props: EMPTY_OBJ,
+++ /dev/null
-import { hasOwn } from '@vue/shared'
-import { type ComponentInternalInstance } from './component'
-
-export interface ComponentRenderContext {
- [key: string]: any
- _: ComponentInternalInstance
-}
-
-export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
- get({ _: instance }: ComponentRenderContext, key: string) {
- let normalizedProps
- const { setupState, props } = instance
- if (hasOwn(setupState, key)) {
- return setupState[key]
- } else if (
- (normalizedProps = instance.propsOptions[0]) &&
- hasOwn(normalizedProps, key)
- ) {
- return props![key]
- }
- },
-}
) {
if (instance) {
let cur = instance.parent
- // the exposed instance is the render proxy to keep it consistent with 2.x
- const exposedInstance = ('proxy' in instance && instance.proxy) || null
// in production the hook receives only the error code
const errorInfo = __DEV__
? ErrorTypeStrings[type]
const errorCapturedHooks = 'ec' in cur ? cur.ec : null
if (errorCapturedHooks) {
for (let i = 0; i < errorCapturedHooks.length; i++) {
- if (
- errorCapturedHooks[i](err, exposedInstance, errorInfo) === false
- ) {
+ if (errorCapturedHooks[i](err, instance, errorInfo) === false) {
return
}
}
import { initProps } from './componentProps'
import { invokeDirectiveHook } from './directive'
import { insert, remove } from './dom'
-import { PublicInstanceProxyHandlers } from './componentPublicInstance'
export type Block = Node | Fragment | Block[]
export type ParentBlock = ParentNode | Node[]
const setupFn =
typeof component === 'function' ? component : component.setup
- instance.proxy = markRaw(
- new Proxy({ _: instance }, PublicInstanceProxyHandlers),
- )
const state = setupFn && setupFn(props, ctx)
let block: Block | null = null
if (state && '__isScriptSetup' in state) {
const currentlyRenderingActivity = isRenderingActivity
isRenderingActivity = true
try {
- block = component.render(instance.proxy)
+ block = component.render(instance.setupState)
} finally {
isRenderingActivity = currentlyRenderingActivity
}