Skip to content

Commit

Permalink
refactor: extend dom-props update skip to more all keys except value
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 24, 2019
1 parent 1868561 commit 770c6ed
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/platforms/web/runtime/modules/dom-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
}
}

// #4521: if a click event triggers update before the change event is
// dispatched on a checkbox/radio input, the input's checked state will
// be reset and fail to trigger another update.
// The root cause here is that browsers may fire microtasks in between click/change.
// In Chrome / Firefox, click event fires before change, thus having this problem.
// In Safari / Edge, the order is opposite.
// Note: in Edge, if you click too fast, only the click event would fire twice.
if (key === 'checked' && cur === oldProps[key]) {
// 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
}

Expand Down

0 comments on commit 770c6ed

Please sign in to comment.