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
  dd3dbfa6_5933_1dab_3be6_41a5ba041cab["setAttr()"]
  c25982c8_2ef6_052e_8f6b_374c617a6efc["attrs.ts"]
  dd3dbfa6_5933_1dab_3be6_41a5ba041cab -->|defined in| c25982c8_2ef6_052e_8f6b_374c617a6efc
  680592c8_1c16_02fb_0095_5b9bfc426622["updateAttrs()"]
  680592c8_1c16_02fb_0095_5b9bfc426622 -->|calls| dd3dbfa6_5933_1dab_3be6_41a5ba041cab
  9c48cd24_b10e_8b44_6072_7c383dba9ab0["baseSetAttr()"]
  dd3dbfa6_5933_1dab_3be6_41a5ba041cab -->|calls| 9c48cd24_b10e_8b44_6072_7c383dba9ab0
  style dd3dbfa6_5933_1dab_3be6_41a5ba041cab 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, defined in src/platforms/web/runtime/modules/attrs.ts.
Where is setAttr() defined?
setAttr() is defined in src/platforms/web/runtime/modules/attrs.ts at line 57.
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