import { createRenderer, h } from '@vue/core'
const { render } = createRenderer({
- queueJob,
nodeOps,
patchData,
teardownVNode
-import { EMPTY_OBJ } from './utils'
+import { EMPTY_OBJ, nativeOnRE } from './utils'
import {
Component,
ComponentClass,
if (
key === 'class' ||
key === 'style' ||
- (isNativeOn = key.startsWith('nativeOn')) ||
+ (isNativeOn = nativeOnRE.test(key)) ||
(hasDeclaredProps && !options.hasOwnProperty(key))
) {
const newKey = isNativeOn ? 'on' + key.slice(8) : key
export const NOOP = () => {}
-export const isReservedProp = (key: string): boolean => {
- switch (key) {
- case 'key':
- case 'ref':
- case 'slots':
- return true
- default:
- return key.startsWith('nativeOn')
- }
-}
+export const onRE = /^on/
+export const nativeOnRE = /^nativeOn/
+
+const reserveRE = /^(?:key|ref|slots)$|^nativeOn/
+export const isReservedProp = (key: string): boolean => reserveRE.test(key)
export function normalizeStyle(
value: any
} from './component'
import { VNodeFlags, ChildrenFlags } from './flags'
import { createComponentClassFromOptions } from './componentUtils'
-import { normalizeClass, normalizeStyle } from './utils'
+import { normalizeClass, normalizeStyle, onRE, nativeOnRE } from './utils'
// Vue core is platform agnostic, so we are not using Element for "DOM" nodes.
export interface RenderNode {
clonedData.class = normalizeClass([clonedData.class, extraData.class])
} else if (key === 'style') {
clonedData.style = normalizeStyle([clonedData.style, extraData.style])
- } else if (key.startsWith('on')) {
+ } else if (onRE.test(key) || nativeOnRE.test(key)) {
const existing = clonedData[key]
clonedData[key] = existing
? [].concat(existing, extraData[key])
import { patchDOMProp } from './modules/props'
import { patchEvent } from './modules/events'
+export const onRE = /^on/
+const domPropsRE = /^domProps/
+
export function patchData(
el: Element,
key: string,
patchStyle(el, prevValue, nextValue, nextVNode.data)
break
default:
- if (key.startsWith('on')) {
+ if (onRE.test(key)) {
patchEvent(el, key.toLowerCase().slice(2), prevValue, nextValue)
- } else if (key.startsWith('domProps')) {
+ } else if (domPropsRE.test(key)) {
patchDOMProp(
el,
key[8].toLowerCase() + key.slice(9),
import { VNode } from '@vue/core'
import { handleDelegatedEvent } from './modules/events'
+import { onRE } from './patchData'
export function teardownVNode(vnode: VNode) {
const { el, data } = vnode
if (data != null) {
for (const key in data) {
- if (key.startsWith('on')) {
+ if (onRE.test(key)) {
handleDelegatedEvent(el, key.toLowerCase().slice(2), null)
}
}