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

Function updateDOMProps

static/vuejs/vue.common.js:5916–5957  ·  view source on GitHub ↗
(oldVnode, vnode)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

extendFunction · 0.70
shouldUpdateValueFunction · 0.70

Tested by

no test coverage detected