From aac7805b3a42aaa26c851b9fe1c707a33b1b7a38 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 16 Oct 2018 15:53:23 -0400 Subject: [PATCH] refactor: use shared util, remove unused regex --- packages/core/src/vdom.ts | 11 +++-------- packages/renderer-dom/src/patchData.ts | 3 +-- packages/renderer-dom/src/teardownVNode.ts | 2 +- packages/shared/src/index.ts | 2 -- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/core/src/vdom.ts b/packages/core/src/vdom.ts index dededddd..7ebcb600 100644 --- a/packages/core/src/vdom.ts +++ b/packages/core/src/vdom.ts @@ -5,16 +5,11 @@ import { } from './component' import { VNodeFlags, ChildrenFlags } from './flags' import { createComponentClassFromOptions } from './componentUtils' -import { - handlersRE, - EMPTY_OBJ, - isObject, - isArray, - isFunction, - isString -} from '@vue/shared' +import { EMPTY_OBJ, isObject, isArray, isFunction, isString } from '@vue/shared' import { RawChildrenType, RawSlots } from './h' +const handlersRE = /^on|^vnode/ + // Vue core is platform agnostic, so we are not using Element for "DOM" nodes. export interface RenderNode { vnode?: VNode | null diff --git a/packages/renderer-dom/src/patchData.ts b/packages/renderer-dom/src/patchData.ts index f6244cd4..64eb1617 100644 --- a/packages/renderer-dom/src/patchData.ts +++ b/packages/renderer-dom/src/patchData.ts @@ -4,8 +4,7 @@ import { patchStyle } from './modules/style' import { patchAttr } from './modules/attrs' import { patchDOMProp } from './modules/props' import { patchEvent } from './modules/events' - -export const onRE = /^on/ +import { onRE } from '@vue/shared' // value, checked, selected & muted // plus anything with upperCase letter in it are always patched as properties diff --git a/packages/renderer-dom/src/teardownVNode.ts b/packages/renderer-dom/src/teardownVNode.ts index 89d2fec6..322182e0 100644 --- a/packages/renderer-dom/src/teardownVNode.ts +++ b/packages/renderer-dom/src/teardownVNode.ts @@ -1,6 +1,6 @@ import { VNode } from '@vue/core' import { handleDelegatedEvent } from './modules/events' -import { onRE } from './patchData' +import { onRE } from '@vue/shared' export function teardownVNode(vnode: VNode) { const { el, data } = vnode diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 798f0961..cec53c72 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -3,8 +3,6 @@ export const EMPTY_OBJ: { readonly [key: string]: any } = Object.freeze({}) export const NOOP = () => {} export const onRE = /^on/ -export const vnodeHookRE = /^vnode/ -export const handlersRE = /^on|^vnode/ export const reservedPropRE = /^(?:key|ref|slots)$|^vnode/ export const isArray = Array.isArray