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

Function updateDOMProps

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

extendFunction · 0.70
shouldUpdateValueFunction · 0.70

Tested by

no test coverage detected