]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: nativeOn should be able to be passed down multiple times
authorEvan You <yyx990803@gmail.com>
Thu, 4 Oct 2018 20:10:46 +0000 (16:10 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 4 Oct 2018 20:10:46 +0000 (16:10 -0400)
packages/core/src/componentProps.ts
packages/renderer-dom/src/patchData.ts

index 31eea6a288d767ec8b569d955d460adf7c7df4da..d76b711a367f5e12f97f16a841e1e0cd3ec89e50 100644 (file)
@@ -89,16 +89,14 @@ export function resolveProps(
       // separate `attrs` object, which can then be merged onto child component
       // root. in addition, if the component has explicitly declared props, then
       // any non-matching props are extracted into `attrs` as well.
-      let isNativeOn
       if (
         key === 'class' ||
         key === 'style' ||
         vnodeHookRE.test(key) ||
-        (isNativeOn = nativeOnRE.test(key)) ||
+        nativeOnRE.test(key) ||
         (hasDeclaredProps && !options.hasOwnProperty(key))
       ) {
-        const newKey = isNativeOn ? 'on' + key.slice(8) : key
-        ;(attrs || (attrs = {}))[newKey] = rawData[key]
+        ;(attrs || (attrs = {}))[key] = rawData[key]
       } else {
         props[key] = rawData[key]
       }
index 803cfee1fb5e8a270850906ce3966ca77ce34d78..fef6ce5618ed330eb3bfc678504cbc74329724c3 100644 (file)
@@ -5,7 +5,7 @@ import { patchAttr } from './modules/attrs'
 import { patchDOMProp } from './modules/props'
 import { patchEvent } from './modules/events'
 
-export const onRE = /^on/
+export const onRE = /^on|^nativeOn/
 const domPropsRE = /^domProps/
 
 export function patchData(
@@ -28,7 +28,12 @@ export function patchData(
       break
     default:
       if (onRE.test(key)) {
-        patchEvent(el, key.toLowerCase().slice(2), prevValue, nextValue)
+        patchEvent(
+          el,
+          key.replace(onRE, '').toLowerCase(),
+          prevValue,
+          nextValue
+        )
       } else if (domPropsRE.test(key)) {
         patchDOMProp(
           el,