wip: compare perf

This commit is contained in:
Evan You 2019-05-26 15:38:55 +08:00
parent b3f8b5ae0a
commit 3f3e42b8cb
3 changed files with 4 additions and 4 deletions

View File

@ -193,7 +193,7 @@ export function createRenderer(options: RendererOptions) {
if (patchFlag & CLASS) { if (patchFlag & CLASS) {
// TODO handle full class API, potentially optimize at compilation stage? // TODO handle full class API, potentially optimize at compilation stage?
if (oldProps.class !== newProps.class) { if (oldProps.class !== newProps.class) {
el.className = newProps.class hostPatchProp(el, 'class', newProps.class, null, false)
} }
} }
@ -201,7 +201,7 @@ export function createRenderer(options: RendererOptions) {
// this flag is matched when the element has dynamic style bindings // this flag is matched when the element has dynamic style bindings
// TODO separate static and dynamic styles? // TODO separate static and dynamic styles?
if (patchFlag & STYLE) { if (patchFlag & STYLE) {
hostPatchProp(el, 'style', oldProps.style, newProps.style, false) hostPatchProp(el, 'style', newProps.style, oldProps.style, false)
} }
// props // props

View File

@ -9,8 +9,8 @@ import { VNode } from '@vue/runtime-core'
export function patchProp( export function patchProp(
el: Element, el: Element,
key: string, key: string,
prevValue: any,
nextValue: any, nextValue: any,
prevValue: any,
isSVG: boolean, isSVG: boolean,
prevChildren?: VNode[], prevChildren?: VNode[],
unmountChildren?: any unmountChildren?: any

View File

@ -6,7 +6,7 @@ const svgNS = 'http://www.w3.org/2000/svg'
export const DOMRendererOptions: RendererOptions = { export const DOMRendererOptions: RendererOptions = {
patchProp, patchProp,
insert: (parent: Node, child: Node, anchor?: Node) => { insert: (child: Node, parent: Node, anchor?: Node) => {
if (anchor != null) { if (anchor != null) {
parent.insertBefore(child, anchor) parent.insertBefore(child, anchor)
} else { } else {