refactor: use faster key check
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user