export const MERGE_PROPS = Symbol(__DEV__ ? `mergeProps` : ``)
export const TO_HANDLERS = Symbol(__DEV__ ? `toHandlers` : ``)
export const CAMELIZE = Symbol(__DEV__ ? `camelize` : ``)
+export const CAPITALIZE = Symbol(__DEV__ ? `capitalize` : ``)
export const SET_BLOCK_TRACKING = Symbol(__DEV__ ? `setBlockTracking` : ``)
export const PUSH_SCOPE_ID = Symbol(__DEV__ ? `pushScopeId` : ``)
export const POP_SCOPE_ID = Symbol(__DEV__ ? `popScopeId` : ``)
[MERGE_PROPS]: `mergeProps`,
[TO_HANDLERS]: `toHandlers`,
[CAMELIZE]: `camelize`,
+ [CAPITALIZE]: `capitalize`,
[SET_BLOCK_TRACKING]: `setBlockTracking`,
[PUSH_SCOPE_ID]: `pushScopeId`,
[POP_SCOPE_ID]: `popScopeId`,
import { processExpression } from './transformExpression'
import { validateBrowserExpression } from '../validateExpression'
import { isMemberExpression, hasScopeRef } from '../utils'
+import { CAPITALIZE } from '../runtimeHelpers'
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/
: capitalize(rawName)
eventName = createSimpleExpression(`on${normalizedName}`, true, arg.loc)
} else {
- eventName = createCompoundExpression([`"on" + (`, arg, `)`])
+ eventName = createCompoundExpression([
+ `"on" + ${context.helperString(CAPITALIZE)}(`,
+ arg,
+ `)`
+ ])
}
} else {
// already a compound expression.
eventName = arg
- eventName.children.unshift(`"on" + (`)
+ eventName.children.unshift(`"on" + ${context.helperString(CAPITALIZE)}(`)
eventName.children.push(`)`)
}
createCommentVNode,
createStaticVNode
} from './vnode'
-
-// a bit of ceremony to mark these internal only here because we need to include
-// them in @vue/shared's typings
-import { toDisplayString, camelize } from '@vue/shared'
-/**
- * @private
- */
-const _toDisplayString = toDisplayString
-/**
- * @private
- */
-const _camelize = camelize
-export { _toDisplayString as toDisplayString, _camelize as camelize }
+export { toDisplayString, camelize, capitalize } from '@vue/shared'
// For test-utils
export { transformVNodeArgs } from './vnode'
}
const camelizeRE = /-(\w)/g
+/**
+ * @private
+ */
export const camelize = cacheStringFunction(
(str: string): string => {
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''))
)
const hyphenateRE = /\B([A-Z])/g
+/**
+ * @private
+ */
export const hyphenate = cacheStringFunction(
(str: string): string => {
return str.replace(hyphenateRE, '-$1').toLowerCase()
}
)
+/**
+ * @private
+ */
export const capitalize = cacheStringFunction(
(str: string): string => {
return str.charAt(0).toUpperCase() + str.slice(1)
import { isArray, isObject, isPlainObject } from './index'
-// For converting {{ interpolation }} values to displayed strings.
+/**
+ * For converting {{ interpolation }} values to displayed strings.
+ * @private
+ */
export const toDisplayString = (val: unknown): string => {
return val == null
? ''