fix(runtime-core): fix user attched public instance properties that start with "$"
This commit is contained in:
parent
99fd158d09
commit
d7ca1c5c6e
@ -117,6 +117,11 @@ describe('component: proxy', () => {
|
|||||||
instanceProxy.foo = 1
|
instanceProxy.foo = 1
|
||||||
expect(instanceProxy.foo).toBe(1)
|
expect(instanceProxy.foo).toBe(1)
|
||||||
expect(instance!.ctx.foo).toBe(1)
|
expect(instance!.ctx.foo).toBe(1)
|
||||||
|
|
||||||
|
// should also allow properties that start with $
|
||||||
|
const obj = (instanceProxy.$store = {})
|
||||||
|
expect(instanceProxy.$store).toBe(obj)
|
||||||
|
expect(instance!.ctx.$store).toBe(obj)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('globalProperties', () => {
|
test('globalProperties', () => {
|
||||||
|
@ -184,6 +184,10 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||||||
(cssModule = cssModule[key])
|
(cssModule = cssModule[key])
|
||||||
) {
|
) {
|
||||||
return cssModule
|
return cssModule
|
||||||
|
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
||||||
|
// user may set custom properties to `this` that start with `$`
|
||||||
|
accessCache![key] = AccessTypes.CONTEXT
|
||||||
|
return ctx[key]
|
||||||
} else if (
|
} else if (
|
||||||
// global properties
|
// global properties
|
||||||
((globalProperties = appContext.config.globalProperties),
|
((globalProperties = appContext.config.globalProperties),
|
||||||
|
Loading…
Reference in New Issue
Block a user