feat(props): kebab -> camel prop case support in full build

This commit is contained in:
Evan You 2019-10-23 21:51:01 -04:00
parent af5a8e1154
commit e2917fef96

View File

@ -128,12 +128,13 @@ export function resolveProps(
for (const key in rawProps) { for (const key in rawProps) {
// key, ref are reserved // key, ref are reserved
if (isReservedProp(key)) continue if (isReservedProp(key)) continue
const camelKey = __RUNTIME_COMPILE__ ? camelize(key) : key
// any non-declared data are put into a separate `attrs` object // any non-declared data are put into a separate `attrs` object
// for spreading // for spreading
if (hasDeclaredProps && !hasOwn(options, key)) { if (hasDeclaredProps && !hasOwn(options, camelKey)) {
;(attrs || (attrs = {}))[key] = rawProps[key] ;(attrs || (attrs = {}))[camelKey] = rawProps[key]
} else { } else {
setProp(key, rawProps[key]) setProp(camelKey, rawProps[key])
} }
} }
} }
@ -163,7 +164,11 @@ export function resolveProps(
} }
// runtime validation // runtime validation
if (__DEV__ && rawProps) { 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 { } else {