Skip to content

Commit e0d19a6

Browse files
committed
fix(runtime-core): always check props presence in public instance proxy
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
1 parent 5453e79 commit e0d19a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/runtime-core/src/componentProxy.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
222222
// is the multiple hasOwn() calls. It's much faster to do a simple property
223223
// access on a plain object, so we use an accessCache object (with null
224224
// prototype) to memoize what access type a key corresponds to.
225+
let normalizedProps
225226
if (key[0] !== '$') {
226227
const n = accessCache![key]
227228
if (n !== undefined) {
@@ -245,8 +246,8 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
245246
} else if (
246247
// only cache other properties when instance has declared (thus stable)
247248
// props
248-
type.props &&
249-
hasOwn(normalizePropsOptions(type)[0]!, key)
249+
(normalizedProps = normalizePropsOptions(type)[0]) &&
250+
hasOwn(normalizedProps, key)
250251
) {
251252
accessCache![key] = AccessTypes.PROPS
252253
return props![key]
@@ -352,11 +353,13 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
352353
}: ComponentRenderContext,
353354
key: string
354355
) {
356+
let normalizedProps
355357
return (
356358
accessCache![key] !== undefined ||
357359
(data !== EMPTY_OBJ && hasOwn(data, key)) ||
358360
(setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
359-
(type.props && hasOwn(normalizePropsOptions(type)[0]!, key)) ||
361+
((normalizedProps = normalizePropsOptions(type)[0]) &&
362+
hasOwn(normalizedProps, key)) ||
360363
hasOwn(ctx, key) ||
361364
hasOwn(publicPropertiesMap, key) ||
362365
hasOwn(appContext.config.globalProperties, key)

0 commit comments

Comments
 (0)