feat(sfc): useAttrs + useSlots

Deprecate useContext
This commit is contained in:
Evan You
2021-06-22 21:00:26 -04:00
parent 6f6f0cf5dc
commit 63e9e2e9aa
2 changed files with 20 additions and 5 deletions

View File

@@ -815,11 +815,9 @@ export function finishComponentSetup(
}
}
const attrHandlers: ProxyHandler<Data> = {
const attrDevProxyHandlers: ProxyHandler<Data> = {
get: (target, key: string) => {
if (__DEV__) {
markAttrsAccessed()
}
markAttrsAccessed()
return target[key]
},
set: () => {
@@ -847,7 +845,7 @@ export function createSetupContext(
// properties (overwrites should not be done in prod)
return Object.freeze({
get attrs() {
return new Proxy(instance.attrs, attrHandlers)
return new Proxy(instance.attrs, attrDevProxyHandlers)
},
get slots() {
return shallowReadonly(instance.slots)