Skip to content

chore(runtime-core): remove attrsProxy and slotsProxy from instance #11390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ export interface ComponentInternalInstance {
refs: Data
emit: EmitFn

attrsProxy: Data | null
slotsProxy: Slots | null

/**
* used for keeping track of .once event handlers on components
* @internal
Expand Down Expand Up @@ -599,9 +596,6 @@ export function createComponentInstance(
setupState: EMPTY_OBJ,
setupContext: null,

attrsProxy: null,
slotsProxy: null,

// suspense related
suspense,
suspenseId: suspense ? suspense.pendingId : 0,
Expand Down Expand Up @@ -1042,15 +1036,12 @@ const attrsProxyHandlers = __DEV__
* Dev-only
*/
function getSlotsProxy(instance: ComponentInternalInstance): Slots {
return (
instance.slotsProxy ||
(instance.slotsProxy = new Proxy(instance.slots, {
get(target, key: string) {
track(instance, TrackOpTypes.GET, '$slots')
return target[key]
},
}))
)
return new Proxy(instance.slots, {
get(target, key: string) {
track(instance, TrackOpTypes.GET, '$slots')
return target[key]
},
})
}

export function createSetupContext(
Expand Down Expand Up @@ -1084,6 +1075,7 @@ export function createSetupContext(
// We use getters in dev in case libs like test-utils overwrite instance
// properties (overwrites should not be done in prod)
let attrsProxy: Data
let slotsProxy: Slots
return Object.freeze({
get attrs() {
return (
Expand All @@ -1092,7 +1084,7 @@ export function createSetupContext(
)
},
get slots() {
return getSlotsProxy(instance)
return slotsProxy || (slotsProxy = getSlotsProxy(instance))
},
get emit() {
return (event: string, ...args: any[]) => instance.emit(event, ...args)
Expand Down