Skip to content

Commit

Permalink
fix(runtime-core): always check props presence in public instance proxy
Browse files Browse the repository at this point in the history
When the there are props merged from mixins or extends, the component itself
may not have a props property.

fix #1236 where merged props are not exposed in production
  • Loading branch information
yyx990803 committed Jun 26, 2020
1 parent 5453e79 commit e0d19a6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/runtime-core/src/componentProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
// is the multiple hasOwn() calls. It's much faster to do a simple property
// access on a plain object, so we use an accessCache object (with null
// prototype) to memoize what access type a key corresponds to.
let normalizedProps
if (key[0] !== '$') {
const n = accessCache![key]
if (n !== undefined) {
Expand All @@ -245,8 +246,8 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
} else if (
// only cache other properties when instance has declared (thus stable)
// props
type.props &&
hasOwn(normalizePropsOptions(type)[0]!, key)
(normalizedProps = normalizePropsOptions(type)[0]) &&
hasOwn(normalizedProps, key)
) {
accessCache![key] = AccessTypes.PROPS
return props![key]
Expand Down Expand Up @@ -352,11 +353,13 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
}: ComponentRenderContext,
key: string
) {
let normalizedProps
return (
accessCache![key] !== undefined ||
(data !== EMPTY_OBJ && hasOwn(data, key)) ||
(setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
(type.props && hasOwn(normalizePropsOptions(type)[0]!, key)) ||
((normalizedProps = normalizePropsOptions(type)[0]) &&
hasOwn(normalizedProps, key)) ||
hasOwn(ctx, key) ||
hasOwn(publicPropertiesMap, key) ||
hasOwn(appContext.config.globalProperties, key)
Expand Down

0 comments on commit e0d19a6

Please sign in to comment.