From: Evan You Date: Fri, 6 Dec 2024 14:07:21 +0000 (+0800) Subject: wip: fix props/attrs bugs X-Git-Tag: v3.6.0-alpha.1~16^2~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=685f7820a16cf7fd70e1ee990cff3794c06ebcc2;p=thirdparty%2Fvuejs%2Fcore.git wip: fix props/attrs bugs --- diff --git a/packages/runtime-vapor/src/componentProps.ts b/packages/runtime-vapor/src/componentProps.ts index 9410982d96..120c9d1398 100644 --- a/packages/runtime-vapor/src/componentProps.ts +++ b/packages/runtime-vapor/src/componentProps.ts @@ -39,16 +39,16 @@ export function getPropsProxyHandlers( } const propsOptions = normalizePropsOptions(comp)[0] const emitsOptions = normalizeEmitsOptions(comp) - const isProp = propsOptions ? (key: string) => hasOwn(propsOptions, key) : NO + const isProp = propsOptions + ? (key: string) => hasOwn(propsOptions, camelize(key)) + : NO const isAttr = propsOptions ? (key: string) => key !== '$' && !isProp(key) && !isEmitListener(emitsOptions, key) : YES const getProp = (instance: VaporComponentInstance, key: string) => { - if (key === '$' || !isProp(key)) { - return - } + if (!isProp(key)) return const rawProps = instance.rawProps const dynamicSources = rawProps.$ if (dynamicSources) { @@ -88,6 +88,7 @@ export function getPropsProxyHandlers( undefined, instance, resolveDefault, + true, ) } @@ -128,7 +129,7 @@ export function getPropsProxyHandlers( } } if (hasOwn(target, key)) { - return target[key] + return target[key]() } } @@ -220,9 +221,9 @@ export function hasFallthroughAttrs( return true } else { // check if rawProps contains any keys not declared - const propsOptions = normalizePropsOptions(comp)[0] + const propsOptions = normalizePropsOptions(comp)[0]! for (const key in rawProps) { - if (!hasOwn(propsOptions!, key)) { + if (!hasOwn(propsOptions, camelize(key))) { return true } }