Home / Function/ updateAttrs() — vue Function Reference

updateAttrs() — vue Function Reference

Architecture documentation for the updateAttrs() function in attrs.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  c5d4449b_b590_4e29_f364_15e43415b270["updateAttrs()"]
  2be3818d_a4f3_495c_543c_ee071b428982["isDef()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| 2be3818d_a4f3_495c_543c_ee071b428982
  a1f5b8ca_b6d5_6b24_155e_038685c97c85["isUndef()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| a1f5b8ca_b6d5_6b24_155e_038685c97c85
  7b3aa424_9089_4803_a4c7_86c4f80ba973["isTrue()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| 7b3aa424_9089_4803_a4c7_86c4f80ba973
  7a0093e3_a58a_af71_971f_488b65897e74["extend()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| 7a0093e3_a58a_af71_971f_488b65897e74
  f98c4ea9_22dc_9cb8_d81c_0505f3a992ae["setAttr()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| f98c4ea9_22dc_9cb8_d81c_0505f3a992ae
  style c5d4449b_b590_4e29_f364_15e43415b270 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/platforms/web/runtime/modules/attrs.ts lines 16–55

function updateAttrs(oldVnode: VNodeWithData, vnode: VNodeWithData) {
  const opts = vnode.componentOptions
  if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
    return
  }
  if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
    return
  }
  let key, cur, old
  const elm = vnode.elm
  const oldAttrs = oldVnode.data.attrs || {}
  let attrs: any = vnode.data.attrs || {}
  // clone observed objects, as the user probably wants to mutate it
  if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
    attrs = vnode.data.attrs = extend({}, attrs)
  }

  for (key in attrs) {
    cur = attrs[key]
    old = oldAttrs[key]
    if (old !== cur) {
      setAttr(elm, key, cur, vnode.data.pre)
    }
  }
  // #4391: in IE9, setting type can reset value for input[type=radio]
  // #6666: IE/Edge forces progress value down to 1 before setting a max
  /* istanbul ignore if */
  if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
    setAttr(elm, 'value', attrs.value)
  }
  for (key in oldAttrs) {
    if (isUndef(attrs[key])) {
      if (isXlink(key)) {
        elm.removeAttributeNS(xlinkNS, getXlinkProp(key))
      } else if (!isEnumeratedAttr(key)) {
        elm.removeAttribute(key)
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does updateAttrs() do?
updateAttrs() is a function in the vue codebase.
What does updateAttrs() call?
updateAttrs() calls 5 function(s): extend, isDef, isTrue, isUndef, setAttr.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free