PERF: Dirty checking was broken and re-rendering too often

This commit is contained in:
Robin Ward 2017-05-11 16:19:53 -04:00
parent ea0ecb67f3
commit f3c535b945
1 changed files with 10 additions and 4 deletions

View File

@ -12,7 +12,10 @@ const _registry = {};
let _dirty = {};
export function keyDirty(key, options) {
_dirty[key] = options || {};
options = options || {};
options.dirty = true;
_dirty[key] = options;
}
export function renderedKey(key) {
@ -194,14 +197,17 @@ export default class Widget {
}
if (prev) {
const dirtyOpts = _dirty[prev.key] || {};
const dirtyOpts = _dirty[prev.key] || { dirty: false };
if (prev.shadowTree) {
this.shadowTree = true;
if (!dirtyOpts && !_dirty['*']) {
if (!dirtyOpts.dirty && !_dirty['*']) {
return prev.vnode;
}
}
renderedKey(prev.key);
if (prev.key) {
renderedKey(prev.key);
}
const refreshAction = dirtyOpts.onRefresh;
if (refreshAction) {