From: Evan You Date: Thu, 24 Oct 2019 01:51:01 +0000 (-0400) Subject: feat(props): kebab -> camel prop case support in full build X-Git-Tag: v3.0.0-alpha.0~325 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2917fef96554f99a751feb972c4b2793cc734a1;p=thirdparty%2Fvuejs%2Fcore.git feat(props): kebab -> camel prop case support in full build --- diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index a8146b499f..acd6471d5b 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -128,12 +128,13 @@ export function resolveProps( for (const key in rawProps) { // key, ref are reserved if (isReservedProp(key)) continue + const camelKey = __RUNTIME_COMPILE__ ? camelize(key) : key // any non-declared data are put into a separate `attrs` object // for spreading - if (hasDeclaredProps && !hasOwn(options, key)) { - ;(attrs || (attrs = {}))[key] = rawProps[key] + if (hasDeclaredProps && !hasOwn(options, camelKey)) { + ;(attrs || (attrs = {}))[camelKey] = rawProps[key] } else { - setProp(key, rawProps[key]) + setProp(camelKey, rawProps[key]) } } } @@ -163,7 +164,11 @@ export function resolveProps( } // runtime validation if (__DEV__ && rawProps) { - validateProp(key, toRaw(rawProps[key]), opt, isAbsent) + let rawValue = rawProps[key] + if (__RUNTIME_COMPILE__ && !(key in rawProps)) { + rawValue = rawProps[hyphenate(key)] + } + validateProp(key, toRaw(rawValue), opt, isAbsent) } } } else {