Home / Function/ getValueForAttributeOnCustomComponent() — react Function Reference

getValueForAttributeOnCustomComponent() — react Function Reference

Architecture documentation for the getValueForAttributeOnCustomComponent() function in DOMPropertyOperations.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  384f9fa9_8448_66ce_0422_34f51fe0d9cd["getValueForAttributeOnCustomComponent()"]
  390123a6_56c3_29ed_a331_44deb86078d6["DOMPropertyOperations.js"]
  384f9fa9_8448_66ce_0422_34f51fe0d9cd -->|defined in| 390123a6_56c3_29ed_a331_44deb86078d6
  b3ccac7d_1304_9653_2f32_5c5e2bbc637e["diffHydratedCustomComponent()"]
  b3ccac7d_1304_9653_2f32_5c5e2bbc637e -->|calls| 384f9fa9_8448_66ce_0422_34f51fe0d9cd
  328a0fd1_037f_e628_5343_b37fc3e7b33b["isAttributeNameSafe()"]
  384f9fa9_8448_66ce_0422_34f51fe0d9cd -->|calls| 328a0fd1_037f_e628_5343_b37fc3e7b33b
  style 384f9fa9_8448_66ce_0422_34f51fe0d9cd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/client/DOMPropertyOperations.js lines 56–96

export function getValueForAttributeOnCustomComponent(
  node: Element,
  name: string,
  expected: mixed,
): mixed {
  if (__DEV__) {
    if (!isAttributeNameSafe(name)) {
      return;
    }
    if (!node.hasAttribute(name)) {
      // shouldRemoveAttribute
      switch (typeof expected) {
        case 'symbol':
        case 'object':
          // Symbols and objects are ignored when they're emitted so
          // it would be expected that they end up not having an attribute.
          return expected;
        case 'function':
          return expected;
        case 'boolean':
          if (expected === false) {
            return expected;
          }
      }
      return expected === undefined ? undefined : null;
    }
    const value = node.getAttribute(name);

    if (value === '' && expected === true) {
      return true;
    }

    if (__DEV__) {
      checkAttributeStringCoercion(expected, name);
    }
    if (value === '' + (expected: any)) {
      return expected;
    }
    return value;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does getValueForAttributeOnCustomComponent() do?
getValueForAttributeOnCustomComponent() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/DOMPropertyOperations.js.
Where is getValueForAttributeOnCustomComponent() defined?
getValueForAttributeOnCustomComponent() is defined in packages/react-dom-bindings/src/client/DOMPropertyOperations.js at line 56.
What does getValueForAttributeOnCustomComponent() call?
getValueForAttributeOnCustomComponent() calls 1 function(s): isAttributeNameSafe.
What calls getValueForAttributeOnCustomComponent()?
getValueForAttributeOnCustomComponent() is called by 1 function(s): diffHydratedCustomComponent.

Analyze Your Own Codebase

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

Try Supermodel Free