MCPcopy Create free account
hub / github.com/TruthHun/BookStack / updateDOMProps

Function updateDOMProps

static/vuejs/vue.runtime.js:5462–5503  ·  view source on GitHub ↗
(oldVnode, vnode)

Source from the content-addressed store, hash-verified

5460/* */
5461
5462function updateDOMProps (oldVnode, vnode) {
5463 if (!oldVnode.data.domProps && !vnode.data.domProps) {
5464 return
5465 }
5466 var key, cur;
5467 var elm = vnode.elm;
5468 var oldProps = oldVnode.data.domProps || {};
5469 var props = vnode.data.domProps || {};
5470 // clone observed objects, as the user probably wants to mutate it
5471 if (props.__ob__) {
5472 props = vnode.data.domProps = extend({}, props);
5473 }
5474
5475 for (key in oldProps) {
5476 if (props[key] == null) {
5477 elm[key] = '';
5478 }
5479 }
5480 for (key in props) {
5481 cur = props[key];
5482 // ignore children if the node has textContent or innerHTML,
5483 // as these will throw away existing DOM nodes and cause removal errors
5484 // on subsequent patches (#3360)
5485 if (key === 'textContent' || key === 'innerHTML') {
5486 if (vnode.children) { vnode.children.length = 0; }
5487 if (cur === oldProps[key]) { continue }
5488 }
5489
5490 if (key === 'value') {
5491 // store value as _value as well since
5492 // non-string values will be stringified
5493 elm._value = cur;
5494 // avoid resetting cursor position when value is the same
5495 var strCur = cur == null ? '' : String(cur);
5496 if (shouldUpdateValue(elm, vnode, strCur)) {
5497 elm.value = strCur;
5498 }
5499 } else {
5500 elm[key] = cur;
5501 }
5502 }
5503}
5504
5505// check platforms/web/util/attrs.js acceptValue
5506

Callers

nothing calls this directly

Calls 2

extendFunction · 0.70
shouldUpdateValueFunction · 0.70

Tested by

no test coverage detected