mirror of https://github.com/vuejs/core.git
chore: remove refs from setupContext
explicit refs should be preferred
This commit is contained in:
parent
4abd8d29ef
commit
40ccbdeaac
|
@ -414,7 +414,7 @@ function finishComponentSetup(
|
||||||
export const SetupProxySymbol = Symbol()
|
export const SetupProxySymbol = Symbol()
|
||||||
|
|
||||||
const SetupProxyHandlers: { [key: string]: ProxyHandler<any> } = {}
|
const SetupProxyHandlers: { [key: string]: ProxyHandler<any> } = {}
|
||||||
;['attrs', 'slots', 'refs'].forEach((type: string) => {
|
;['attrs', 'slots'].forEach((type: string) => {
|
||||||
SetupProxyHandlers[type] = {
|
SetupProxyHandlers[type] = {
|
||||||
get: (instance, key) => instance[type][key],
|
get: (instance, key) => instance[type][key],
|
||||||
has: (instance, key) => key === SetupProxySymbol || key in instance[type],
|
has: (instance, key) => key === SetupProxySymbol || key in instance[type],
|
||||||
|
@ -429,12 +429,11 @@ const SetupProxyHandlers: { [key: string]: ProxyHandler<any> } = {}
|
||||||
|
|
||||||
function createSetupContext(instance: ComponentInternalInstance): SetupContext {
|
function createSetupContext(instance: ComponentInternalInstance): SetupContext {
|
||||||
const context = {
|
const context = {
|
||||||
// attrs, slots & refs are non-reactive, but they need to always expose
|
// attrs & slots are non-reactive, but they need to always expose
|
||||||
// the latest values (instance.xxx may get replaced during updates) so we
|
// the latest values (instance.xxx may get replaced during updates) so we
|
||||||
// need to expose them through a proxy
|
// need to expose them through a proxy
|
||||||
attrs: new Proxy(instance, SetupProxyHandlers.attrs),
|
attrs: new Proxy(instance, SetupProxyHandlers.attrs),
|
||||||
slots: new Proxy(instance, SetupProxyHandlers.slots),
|
slots: new Proxy(instance, SetupProxyHandlers.slots),
|
||||||
refs: new Proxy(instance, SetupProxyHandlers.refs),
|
|
||||||
emit: instance.emit
|
emit: instance.emit
|
||||||
}
|
}
|
||||||
return __DEV__ ? Object.freeze(context) : context
|
return __DEV__ ? Object.freeze(context) : context
|
||||||
|
|
Loading…
Reference in New Issue