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
  a13dc9cc_24b7_ee02_c711_52c1500ce296["setAttr()"]
  260c9082_4eba_7d9d_1e58_10f6149dde5e["updateAttrs()"]
  260c9082_4eba_7d9d_1e58_10f6149dde5e -->|calls| a13dc9cc_24b7_ee02_c711_52c1500ce296
  c7a14743_134c_7cfc_7023_433336707c47["baseSetAttr()"]
  a13dc9cc_24b7_ee02_c711_52c1500ce296 -->|calls| c7a14743_134c_7cfc_7023_433336707c47
  style a13dc9cc_24b7_ee02_c711_52c1500ce296 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