From 03390f80a782841131f31ed3872c92fc8ed4af19 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 4 Oct 2018 16:10:46 -0400 Subject: [PATCH] fix: nativeOn should be able to be passed down multiple times --- packages/core/src/componentProps.ts | 6 ++---- packages/renderer-dom/src/patchData.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/src/componentProps.ts b/packages/core/src/componentProps.ts index 31eea6a2..d76b711a 100644 --- a/packages/core/src/componentProps.ts +++ b/packages/core/src/componentProps.ts @@ -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] } diff --git a/packages/renderer-dom/src/patchData.ts b/packages/renderer-dom/src/patchData.ts index 803cfee1..fef6ce56 100644 --- a/packages/renderer-dom/src/patchData.ts +++ b/packages/renderer-dom/src/patchData.ts @@ -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,