Skip to content

Commit

Permalink
refactor: simplify conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 21, 2019
1 parent 7ec4627 commit cd3d202
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/platforms/web/runtime/modules/dom-props.js
Expand Up @@ -38,14 +38,6 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
}
}

// skip the update if old and new VDOM state is the same.
// the only exception is `value` where the DOM value may be temporarily
// out of sync with VDOM state due to focus, composition and modifiers.
// This also covers #4521 by skipping the unnecesarry `checked` update.
if (key !== 'value' && cur === oldProps[key]) {
continue
}

if (key === 'value') {
// store value as _value as well since
// non-string values will be stringified
Expand All @@ -66,7 +58,13 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
while (svg.firstChild) {
elm.appendChild(svg.firstChild)
}
} else {
} else if (
// skip the update if old and new VDOM state is the same.
// `value` is handled separately because the DOM value may be temporarily
// out of sync with VDOM state due to focus, composition and modifiers.
// This #4521 by skipping the unnecesarry `checked` update.
cur !== oldProps[key]
) {
elm[key] = cur
}
}
Expand Down

0 comments on commit cd3d202

Please sign in to comment.