feat(compile-core): handle falsy dynamic args for v-on and v-bind (#2393)

fix #2388
This commit is contained in:
ᴜɴвʏтᴇ
2020-10-20 05:15:53 +08:00
committed by GitHub
parent 7390487c7d
commit 052a621762
15 changed files with 96 additions and 71 deletions

View File

@@ -94,7 +94,8 @@ export const isIntegerKey = (key: unknown) =>
'' + parseInt(key, 10) === key
export const isReservedProp = /*#__PURE__*/ makeMap(
'key,ref,' +
// the leading comma is intentional so empty string "" is also included
',key,ref,' +
'onVnodeBeforeMount,onVnodeMounted,' +
'onVnodeBeforeUpdate,onVnodeUpdated,' +
'onVnodeBeforeUnmount,onVnodeUnmounted'
@@ -122,19 +123,22 @@ const hyphenateRE = /\B([A-Z])/g
/**
* @private
*/
export const hyphenate = cacheStringFunction(
(str: string): string => {
return str.replace(hyphenateRE, '-$1').toLowerCase()
}
export const hyphenate = cacheStringFunction((str: string) =>
str.replace(hyphenateRE, '-$1').toLowerCase()
)
/**
* @private
*/
export const capitalize = cacheStringFunction(
(str: string): string => {
return str.charAt(0).toUpperCase() + str.slice(1)
}
(str: string) => str.charAt(0).toUpperCase() + str.slice(1)
)
/**
* @private
*/
export const toHandlerKey = cacheStringFunction(
(str: string) => (str ? `on${capitalize(str)}` : ``)
)
// compare whether a value has changed, accounting for NaN.