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

Function updateDOMProps

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

Source from the content-addressed store, hash-verified

5912/* */
5913
5914function updateDOMProps (oldVnode, vnode) {
5915 if (!oldVnode.data.domProps && !vnode.data.domProps) {
5916 return
5917 }
5918 var key, cur;
5919 var elm = vnode.elm;
5920 var oldProps = oldVnode.data.domProps || {};
5921 var props = vnode.data.domProps || {};
5922 // clone observed objects, as the user probably wants to mutate it
5923 if (props.__ob__) {
5924 props = vnode.data.domProps = extend({}, props);
5925 }
5926
5927 for (key in oldProps) {
5928 if (props[key] == null) {
5929 elm[key] = '';
5930 }
5931 }
5932 for (key in props) {
5933 cur = props[key];
5934 // ignore children if the node has textContent or innerHTML,
5935 // as these will throw away existing DOM nodes and cause removal errors
5936 // on subsequent patches (#3360)
5937 if (key === 'textContent' || key === 'innerHTML') {
5938 if (vnode.children) { vnode.children.length = 0; }
5939 if (cur === oldProps[key]) { continue }
5940 }
5941
5942 if (key === 'value') {
5943 // store value as _value as well since
5944 // non-string values will be stringified
5945 elm._value = cur;
5946 // avoid resetting cursor position when value is the same
5947 var strCur = cur == null ? '' : String(cur);
5948 if (shouldUpdateValue(elm, vnode, strCur)) {
5949 elm.value = strCur;
5950 }
5951 } else {
5952 elm[key] = cur;
5953 }
5954 }
5955}
5956
5957// check platforms/web/util/attrs.js acceptValue
5958

Callers

nothing calls this directly

Calls 2

extendFunction · 0.70
shouldUpdateValueFunction · 0.70

Tested by

no test coverage detected