updateDOMProps() — vue Function Reference
Architecture documentation for the updateDOMProps() function in dom-props.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 41b4aabc_5688_13d3_ac57_899492a8af0c["updateDOMProps()"] 299f2646_f776_9b7d_1179_7b9087b1e66c["isUndef()"] 41b4aabc_5688_13d3_ac57_899492a8af0c -->|calls| 299f2646_f776_9b7d_1179_7b9087b1e66c 5b855538_2046_796e_16f9_7327a61399cb["isDef()"] 41b4aabc_5688_13d3_ac57_899492a8af0c -->|calls| 5b855538_2046_796e_16f9_7327a61399cb c0051429_b95b_daa0_fc77_989c8344497d["isTrue()"] 41b4aabc_5688_13d3_ac57_899492a8af0c -->|calls| c0051429_b95b_daa0_fc77_989c8344497d 133969d0_a7bd_f1c5_46a3_9fb8fd249583["extend()"] 41b4aabc_5688_13d3_ac57_899492a8af0c -->|calls| 133969d0_a7bd_f1c5_46a3_9fb8fd249583 cfd60e3b_7f4b_6778_ee1c_4172f3425a17["shouldUpdateValue()"] 41b4aabc_5688_13d3_ac57_899492a8af0c -->|calls| cfd60e3b_7f4b_6778_ee1c_4172f3425a17 style 41b4aabc_5688_13d3_ac57_899492a8af0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/platforms/web/runtime/modules/dom-props.ts lines 7–79
function updateDOMProps(oldVnode: VNodeWithData, vnode: VNodeWithData) {
if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
return
}
let key, cur
const elm: any = vnode.elm
const oldProps = oldVnode.data.domProps || {}
let props = vnode.data.domProps || {}
// clone observed objects, as the user probably wants to mutate it
if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
props = vnode.data.domProps = extend({}, props)
}
for (key in oldProps) {
if (!(key in props)) {
elm[key] = ''
}
}
for (key in props) {
cur = props[key]
// ignore children if the node has textContent or innerHTML,
// as these will throw away existing DOM nodes and cause removal errors
// on subsequent patches (#3360)
if (key === 'textContent' || key === 'innerHTML') {
if (vnode.children) vnode.children.length = 0
if (cur === oldProps[key]) continue
// #6601 work around Chrome version <= 55 bug where single textNode
// replaced by innerHTML/textContent retains its parentNode property
if (elm.childNodes.length === 1) {
elm.removeChild(elm.childNodes[0])
}
}
if (key === 'value' && elm.tagName !== 'PROGRESS') {
// store value as _value as well since
// non-string values will be stringified
elm._value = cur
// avoid resetting cursor position when value is the same
const strCur = isUndef(cur) ? '' : String(cur)
if (shouldUpdateValue(elm, strCur)) {
elm.value = strCur
}
} else if (
key === 'innerHTML' &&
isSVG(elm.tagName) &&
isUndef(elm.innerHTML)
) {
// IE doesn't support innerHTML for SVG elements
svgContainer = svgContainer || document.createElement('div')
svgContainer.innerHTML = `<svg>${cur}</svg>`
const svg = svgContainer.firstChild
while (elm.firstChild) {
elm.removeChild(elm.firstChild)
}
while (svg.firstChild) {
elm.appendChild(svg.firstChild)
}
} else if (
// skip the update if old and new VDOM state is the same.
// `value` is handled separately because the DOM value may be temporarily
// out of sync with VDOM state due to focus, composition and modifiers.
// This #4521 by skipping the unnecessary `checked` update.
cur !== oldProps[key]
) {
// some property updates can throw
// e.g. `value` on <progress> w/ non-finite value
try {
elm[key] = cur
} catch (e: any) {}
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does updateDOMProps() do?
updateDOMProps() is a function in the vue codebase.
What does updateDOMProps() call?
updateDOMProps() calls 5 function(s): extend, isDef, isTrue, isUndef, shouldUpdateValue.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free