Merge pull request #102 from yyx990803/master

Return early in module update functions
pull/128/head
Simon Friis Vindum 9 years ago committed by GitHub
commit 6c41430677

@ -12,7 +12,11 @@ for(var i=0, len = booleanAttrs.length; i < len; i++) {
function updateAttrs(oldVnode, vnode) {
var key, cur, old, elm = vnode.elm,
oldAttrs = oldVnode.data.attrs || {}, attrs = vnode.data.attrs || {};
oldAttrs = oldVnode.data.attrs, attrs = vnode.data.attrs;
if (!oldAttrs && !attrs) return;
oldAttrs = oldAttrs || {};
attrs = attrs || {};
// update modified attributes, add new attributes
for (key in attrs) {

@ -1,7 +1,12 @@
function updateClass(oldVnode, vnode) {
var cur, name, elm = vnode.elm,
oldClass = oldVnode.data.class || {},
klass = vnode.data.class || {};
oldClass = oldVnode.data.class,
klass = vnode.data.class;
if (!oldClass && !klass) return;
oldClass = oldClass || {};
klass = klass || {};
for (name in oldClass) {
if (!klass[name]) {
elm.classList.remove(name);

@ -1,9 +1,13 @@
function updateDataset(oldVnode, vnode) {
var elm = vnode.elm,
oldDataset = oldVnode.data.dataset || {},
dataset = vnode.data.dataset || {},
oldDataset = oldVnode.data.dataset,
dataset = vnode.data.dataset,
key
if (!oldDataset && !dataset) return;
oldDataset = oldDataset || {};
dataset = dataset || {};
for (key in oldDataset) {
if (!dataset[key]) {
delete elm.dataset[key];

@ -17,8 +17,12 @@ function fnInvoker(o) {
function updateEventListeners(oldVnode, vnode) {
var name, cur, old, elm = vnode.elm,
oldOn = oldVnode.data.on || {}, on = vnode.data.on;
if (!on) return;
oldOn = oldVnode.data.on, on = vnode.data.on;
if (!on && !oldOn) return;
on = on || {};
oldOn = oldOn || {};
for (name in on) {
cur = on[name];
old = oldOn[name];

@ -1,6 +1,11 @@
function updateProps(oldVnode, vnode) {
var key, cur, old, elm = vnode.elm,
oldProps = oldVnode.data.props || {}, props = vnode.data.props || {};
oldProps = oldVnode.data.props, props = vnode.data.props;
if (!oldProps && !props) return;
oldProps = oldProps || {};
props = props || {};
for (key in oldProps) {
if (!props[key]) {
delete elm[key];

@ -7,9 +7,14 @@ function setNextFrame(obj, prop, val) {
function updateStyle(oldVnode, vnode) {
var cur, name, elm = vnode.elm,
oldStyle = oldVnode.data.style || {},
style = vnode.data.style || {},
oldHasDel = 'delayed' in oldStyle;
oldStyle = oldVnode.data.style,
style = vnode.data.style;
if (!oldStyle && !style) return;
oldStyle = oldStyle || {};
style = style || {};
var oldHasDel = 'delayed' in oldStyle;
for (name in oldStyle) {
if (!style[name]) {
elm.style[name] = '';

Loading…
Cancel
Save