|
|
@@ -274,6 +274,8 @@ export interface ComponentRenderContext {
|
|
|
_: ComponentInternalInstance
|
|
|
}
|
|
|
|
|
|
+export const isReservedPrefix = (key: string) => key === '_' || key === '$'
|
|
|
+
|
|
|
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|
|
get({ _: instance }: ComponentRenderContext, key: string) {
|
|
|
const { ctx, setupState, data, props, accessCache, type, appContext } =
|
|
|
@@ -385,11 +387,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|
|
// to infinite warning loop
|
|
|
key.indexOf('__v') !== 0)
|
|
|
) {
|
|
|
- if (
|
|
|
- data !== EMPTY_OBJ &&
|
|
|
- (key[0] === '$' || key[0] === '_') &&
|
|
|
- hasOwn(data, key)
|
|
|
- ) {
|
|
|
+ if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
|
|
warn(
|
|
|
`Property ${JSON.stringify(
|
|
|
key
|
|
|
@@ -571,7 +569,7 @@ export function exposeSetupStateOnRenderContext(
|
|
|
const { ctx, setupState } = instance
|
|
|
Object.keys(toRaw(setupState)).forEach(key => {
|
|
|
if (!setupState.__isScriptSetup) {
|
|
|
- if (key[0] === '$' || key[0] === '_') {
|
|
|
+ if (isReservedPrefix(key[0])) {
|
|
|
warn(
|
|
|
`setup() return property ${JSON.stringify(
|
|
|
key
|