File tree 5 files changed +23
-16
lines changed
5 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export const TO_DISPLAY_STRING = Symbol(__DEV__ ? `toDisplayString` : ``)
22
22
export const MERGE_PROPS = Symbol ( __DEV__ ? `mergeProps` : `` )
23
23
export const TO_HANDLERS = Symbol ( __DEV__ ? `toHandlers` : `` )
24
24
export const CAMELIZE = Symbol ( __DEV__ ? `camelize` : `` )
25
+ export const CAPITALIZE = Symbol ( __DEV__ ? `capitalize` : `` )
25
26
export const SET_BLOCK_TRACKING = Symbol ( __DEV__ ? `setBlockTracking` : `` )
26
27
export const PUSH_SCOPE_ID = Symbol ( __DEV__ ? `pushScopeId` : `` )
27
28
export const POP_SCOPE_ID = Symbol ( __DEV__ ? `popScopeId` : `` )
@@ -54,6 +55,7 @@ export const helperNameMap: any = {
54
55
[ MERGE_PROPS ] : `mergeProps` ,
55
56
[ TO_HANDLERS ] : `toHandlers` ,
56
57
[ CAMELIZE ] : `camelize` ,
58
+ [ CAPITALIZE ] : `capitalize` ,
57
59
[ SET_BLOCK_TRACKING ] : `setBlockTracking` ,
58
60
[ PUSH_SCOPE_ID ] : `pushScopeId` ,
59
61
[ POP_SCOPE_ID ] : `popScopeId` ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { createCompilerError, ErrorCodes } from '../errors'
14
14
import { processExpression } from './transformExpression'
15
15
import { validateBrowserExpression } from '../validateExpression'
16
16
import { isMemberExpression , hasScopeRef } from '../utils'
17
+ import { CAPITALIZE } from '../runtimeHelpers'
17
18
18
19
const fnExpRE = / ^ ( [ \w $ _ ] + | \( [ ^ ) ] * ?\) ) \s * = > | ^ f u n c t i o n (?: \s + [ \w $ ] + ) ? \s * \( /
19
20
@@ -47,12 +48,16 @@ export const transformOn: DirectiveTransform = (
47
48
: capitalize ( rawName )
48
49
eventName = createSimpleExpression ( `on${ normalizedName } ` , true , arg . loc )
49
50
} else {
50
- eventName = createCompoundExpression ( [ `"on" + (` , arg , `)` ] )
51
+ eventName = createCompoundExpression ( [
52
+ `"on" + ${ context . helperString ( CAPITALIZE ) } (` ,
53
+ arg ,
54
+ `)`
55
+ ] )
51
56
}
52
57
} else {
53
58
// already a compound expression.
54
59
eventName = arg
55
- eventName . children . unshift ( `"on" + (` )
60
+ eventName . children . unshift ( `"on" + ${ context . helperString ( CAPITALIZE ) } (` )
56
61
eventName . children . push ( `)` )
57
62
}
58
63
Original file line number Diff line number Diff line change @@ -225,19 +225,7 @@ export {
225
225
createCommentVNode ,
226
226
createStaticVNode
227
227
} from './vnode'
228
-
229
- // a bit of ceremony to mark these internal only here because we need to include
230
- // them in @vue /shared's typings
231
- import { toDisplayString , camelize } from '@vue/shared'
232
- /**
233
- * @private
234
- */
235
- const _toDisplayString = toDisplayString
236
- /**
237
- * @private
238
- */
239
- const _camelize = camelize
240
- export { _toDisplayString as toDisplayString , _camelize as camelize }
228
+ export { toDisplayString , camelize , capitalize } from '@vue/shared'
241
229
242
230
// For test-utils
243
231
export { transformVNodeArgs } from './vnode'
Original file line number Diff line number Diff line change @@ -94,19 +94,28 @@ const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
94
94
}
95
95
96
96
const camelizeRE = / - ( \w ) / g
97
+ /**
98
+ * @private
99
+ */
97
100
export const camelize = cacheStringFunction (
98
101
( str : string ) : string => {
99
102
return str . replace ( camelizeRE , ( _ , c ) => ( c ? c . toUpperCase ( ) : '' ) )
100
103
}
101
104
)
102
105
103
106
const hyphenateRE = / \B ( [ A - Z ] ) / g
107
+ /**
108
+ * @private
109
+ */
104
110
export const hyphenate = cacheStringFunction (
105
111
( str : string ) : string => {
106
112
return str . replace ( hyphenateRE , '-$1' ) . toLowerCase ( )
107
113
}
108
114
)
109
115
116
+ /**
117
+ * @private
118
+ */
110
119
export const capitalize = cacheStringFunction (
111
120
( str : string ) : string => {
112
121
return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 )
Original file line number Diff line number Diff line change 1
1
import { isArray , isObject , isPlainObject } from './index'
2
2
3
- // For converting {{ interpolation }} values to displayed strings.
3
+ /**
4
+ * For converting {{ interpolation }} values to displayed strings.
5
+ * @private
6
+ */
4
7
export const toDisplayString = ( val : unknown ) : string => {
5
8
return val == null
6
9
? ''
You can’t perform that action at this time.
0 commit comments