Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test some performance stuff #4522

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/create-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export function createVNode(type, props, key, ref, original) {
return vnode;
}

// @ts-ignore
export const EMPTY_VNODE = createVNode(null, {});
EMPTY_VNODE._children = [];

export function createRef() {
return { current: null };
}
Expand Down
8 changes: 4 additions & 4 deletions src/diff/children.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { diff, unmount, applyRef } from './index';
import { createVNode, Fragment } from '../create-element';
import { EMPTY_OBJ, EMPTY_ARR, INSERT_VNODE, MATCHED } from '../constants';
import { createVNode, Fragment, EMPTY_VNODE } from '../create-element';
import { EMPTY_ARR, INSERT_VNODE, MATCHED } from '../constants';
import { isArray } from '../util';
import { getDomSibling } from '../component';

Expand Down Expand Up @@ -67,9 +67,9 @@ export function diffChildren(
// At this point, constructNewChildrenArray has assigned _index to be the
// matchingIndex for this VNode's oldVNode (or -1 if there is no oldVNode).
if (childVNode._index === -1) {
oldVNode = EMPTY_OBJ;
oldVNode = EMPTY_VNODE;
} else {
oldVNode = oldChildren[childVNode._index] || EMPTY_OBJ;
oldVNode = oldChildren[childVNode._index] || EMPTY_VNODE;
}

// Update childVNode._index to its final index
Expand Down
3 changes: 2 additions & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
EMPTY_ARR,
EMPTY_OBJ,
MODE_HYDRATE,
MODE_SUSPENDED,
Expand Down Expand Up @@ -498,7 +499,7 @@ function diffElementNodes(
dom.innerHTML = newHtml.__html;
}

newVNode._children = [];
newVNode._children = EMPTY_ARR;
} else {
if (oldHtml) dom.innerHTML = '';

Expand Down
5 changes: 4 additions & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ export function setProperty(dom, name, value, oldValue, namespace) {

if (typeof value == 'function') {
// never serialize functions as attribute values
} else if (value != null && (value !== false || name[4] === '-')) {
} else if (
value != null &&
(value !== false || (name.length > 4 && name[4] === '-'))
) {
dom.setAttribute(name, name == 'popover' && value == true ? '' : value);
} else {
dom.removeAttribute(name);
Expand Down
4 changes: 2 additions & 2 deletions src/render.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EMPTY_OBJ } from './constants';
import { commitRoot, diff } from './diff/index';
import { createElement, Fragment } from './create-element';
import { createElement, Fragment, EMPTY_VNODE } from './create-element';
import options from './options';
import { slice } from './util';

Expand Down Expand Up @@ -39,7 +39,7 @@ export function render(vnode, parentDom, replaceNode) {
// Determine the new vnode tree and store it on the DOM element on
// our custom `_children` property.
vnode,
oldVNode || EMPTY_OBJ,
oldVNode || EMPTY_VNODE,
EMPTY_OBJ,
parentDom.namespaceURI,
!isHydrating && replaceNode
Expand Down