fix(custom-element): fix event listeners with capital letter event names on custom elements
close https://github.com/vuejs/docs/issues/1708 close https://github.com/vuejs/docs/pull/1890
This commit is contained in:
@@ -5,14 +5,21 @@ import { warn } from '../warning'
|
||||
* For prefixing keys in v-on="obj" with "on"
|
||||
* @private
|
||||
*/
|
||||
export function toHandlers(obj: Record<string, any>): Record<string, any> {
|
||||
export function toHandlers(
|
||||
obj: Record<string, any>,
|
||||
preserveCaseIfNecessary?: boolean
|
||||
): Record<string, any> {
|
||||
const ret: Record<string, any> = {}
|
||||
if (__DEV__ && !isObject(obj)) {
|
||||
warn(`v-on with no argument expects an object value.`)
|
||||
return ret
|
||||
}
|
||||
for (const key in obj) {
|
||||
ret[toHandlerKey(key)] = obj[key]
|
||||
ret[
|
||||
preserveCaseIfNecessary && /[A-Z]/.test(key)
|
||||
? `on:${key}`
|
||||
: toHandlerKey(key)
|
||||
] = obj[key]
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user