refactor: use faster key check

This commit is contained in:
Evan You
2018-10-17 12:20:54 -04:00
parent 30404ec546
commit 1c42c96d1a
5 changed files with 14 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import { patchStyle } from './modules/style'
import { patchAttr } from './modules/attrs'
import { patchDOMProp } from './modules/props'
import { patchEvent } from './modules/events'
import { onRE } from '@vue/shared'
import { isOn } from '@vue/shared'
// value, checked, selected & muted
// plus anything with upperCase letter in it are always patched as properties
@@ -29,13 +29,8 @@ export function patchData(
patchStyle(el, prevValue, nextValue, nextVNode.data)
break
default:
if (onRE.test(key)) {
patchEvent(
el,
key.replace(onRE, '').toLowerCase(),
prevValue,
nextValue
)
if (isOn(key)) {
patchEvent(el, key.slice(2).toLowerCase(), prevValue, nextValue)
} else if (domPropsRE.test(key)) {
patchDOMProp(
el,

View File

@@ -1,13 +1,13 @@
import { VNode } from '@vue/core'
import { handleDelegatedEvent } from './modules/events'
import { onRE } from '@vue/shared'
import { isOn } from '@vue/shared'
export function teardownVNode(vnode: VNode) {
const { el, data } = vnode
if (data != null) {
for (const key in data) {
if (onRE.test(key)) {
handleDelegatedEvent(el, key.toLowerCase().slice(2), null)
if (isOn(key)) {
handleDelegatedEvent(el, key.slice(2).toLowerCase(), null)
}
}
}