Ver código fonte

fix(runtime-core): properly capitalize v-on object keys (#1358)

Cathrine Vaage 6 anos atrás
pai
commit
250eb4a5bc

+ 2 - 2
packages/runtime-core/__tests__/helpers/toHandlers.spec.ts

@@ -18,8 +18,8 @@ describe('toHandlers', () => {
     const change = () => {}
 
     expect(toHandlers({ input, change })).toStrictEqual({
-      oninput: input,
-      onchange: change
+      onInput: input,
+      onChange: change
     })
   })
 })

+ 2 - 2
packages/runtime-core/src/helpers/toHandlers.ts

@@ -1,4 +1,4 @@
-import { isObject } from '@vue/shared'
+import { isObject, capitalize } from '@vue/shared'
 import { warn } from '../warning'
 
 /**
@@ -12,7 +12,7 @@ export function toHandlers(obj: Record<string, any>): Record<string, any> {
     return ret
   }
   for (const key in obj) {
-    ret[`on${key}`] = obj[key]
+    ret[`on${capitalize(key)}`] = obj[key]
   }
   return ret
 }