fix: nativeOn should be able to be passed down multiple times
This commit is contained in:
parent
848b92070b
commit
03390f80a7
@ -89,16 +89,14 @@ export function resolveProps(
|
|||||||
// separate `attrs` object, which can then be merged onto child component
|
// separate `attrs` object, which can then be merged onto child component
|
||||||
// root. in addition, if the component has explicitly declared props, then
|
// root. in addition, if the component has explicitly declared props, then
|
||||||
// any non-matching props are extracted into `attrs` as well.
|
// any non-matching props are extracted into `attrs` as well.
|
||||||
let isNativeOn
|
|
||||||
if (
|
if (
|
||||||
key === 'class' ||
|
key === 'class' ||
|
||||||
key === 'style' ||
|
key === 'style' ||
|
||||||
vnodeHookRE.test(key) ||
|
vnodeHookRE.test(key) ||
|
||||||
(isNativeOn = nativeOnRE.test(key)) ||
|
nativeOnRE.test(key) ||
|
||||||
(hasDeclaredProps && !options.hasOwnProperty(key))
|
(hasDeclaredProps && !options.hasOwnProperty(key))
|
||||||
) {
|
) {
|
||||||
const newKey = isNativeOn ? 'on' + key.slice(8) : key
|
;(attrs || (attrs = {}))[key] = rawData[key]
|
||||||
;(attrs || (attrs = {}))[newKey] = rawData[key]
|
|
||||||
} else {
|
} else {
|
||||||
props[key] = rawData[key]
|
props[key] = rawData[key]
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { patchAttr } from './modules/attrs'
|
|||||||
import { patchDOMProp } from './modules/props'
|
import { patchDOMProp } from './modules/props'
|
||||||
import { patchEvent } from './modules/events'
|
import { patchEvent } from './modules/events'
|
||||||
|
|
||||||
export const onRE = /^on/
|
export const onRE = /^on|^nativeOn/
|
||||||
const domPropsRE = /^domProps/
|
const domPropsRE = /^domProps/
|
||||||
|
|
||||||
export function patchData(
|
export function patchData(
|
||||||
@ -28,7 +28,12 @@ export function patchData(
|
|||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if (onRE.test(key)) {
|
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)) {
|
} else if (domPropsRE.test(key)) {
|
||||||
patchDOMProp(
|
patchDOMProp(
|
||||||
el,
|
el,
|
||||||
|
Loading…
Reference in New Issue
Block a user