Home / Function/ setAttr() — vue Function Reference

setAttr() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f98c4ea9_22dc_9cb8_d81c_0505f3a992ae["setAttr()"]
  c5d4449b_b590_4e29_f364_15e43415b270["updateAttrs()"]
  c5d4449b_b590_4e29_f364_15e43415b270 -->|calls| f98c4ea9_22dc_9cb8_d81c_0505f3a992ae
  4180f176_2eb5_ecee_e037_3c4080629fcc["baseSetAttr()"]
  f98c4ea9_22dc_9cb8_d81c_0505f3a992ae -->|calls| 4180f176_2eb5_ecee_e037_3c4080629fcc
  style f98c4ea9_22dc_9cb8_d81c_0505f3a992ae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/platforms/web/runtime/modules/attrs.ts lines 57–82

function setAttr(el: Element, key: string, value: any, isInPre?: any) {
  if (isInPre || el.tagName.indexOf('-') > -1) {
    baseSetAttr(el, key, value)
  } else if (isBooleanAttr(key)) {
    // set attribute for blank value
    // e.g. <option disabled>Select one</option>
    if (isFalsyAttrValue(value)) {
      el.removeAttribute(key)
    } else {
      // technically allowfullscreen is a boolean attribute for <iframe>,
      // but Flash expects a value of "true" when used on <embed> tag
      value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key
      el.setAttribute(key, value)
    }
  } else if (isEnumeratedAttr(key)) {
    el.setAttribute(key, convertEnumeratedValue(key, value))
  } else if (isXlink(key)) {
    if (isFalsyAttrValue(value)) {
      el.removeAttributeNS(xlinkNS, getXlinkProp(key))
    } else {
      el.setAttributeNS(xlinkNS, key, value)
    }
  } else {
    baseSetAttr(el, key, value)
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does setAttr() do?
setAttr() is a function in the vue codebase.
What does setAttr() call?
setAttr() calls 1 function(s): baseSetAttr.
What calls setAttr()?
setAttr() is called by 1 function(s): updateAttrs.

Analyze Your Own Codebase

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

Try Supermodel Free