Browse Source

refactor: extend dom-props update skip to more all keys except value

dev
Evan You 6 years ago
parent
commit
770c6ed64f
  1. 13
      src/platforms/web/runtime/modules/dom-props.js

13
src/platforms/web/runtime/modules/dom-props.js

@ -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
}

Loading…
Cancel
Save