Home / Function/ getPropertyValueForStyleName() — react Function Reference

getPropertyValueForStyleName() — react Function Reference

Architecture documentation for the getPropertyValueForStyleName() function in utils.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  04af48c3_3770_c4af_79c9_cf6a01202fbf["getPropertyValueForStyleName()"]
  19f40fb1_960e_960b_4570_41c17da62024["utils.js"]
  04af48c3_3770_c4af_79c9_cf6a01202fbf -->|defined in| 19f40fb1_960e_960b_4570_41c17da62024
  9b921ff1_2315_6e2b_a7c8_e34fae825797["crawlObjectProperties()"]
  9b921ff1_2315_6e2b_a7c8_e34fae825797 -->|calls| 04af48c3_3770_c4af_79c9_cf6a01202fbf
  style 04af48c3_3770_c4af_79c9_cf6a01202fbf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/backend/StyleX/utils.js lines 83–130

function getPropertyValueForStyleName(styleName: string): string | null {
  if (cachedStyleNameToValueMap.has(styleName)) {
    return ((cachedStyleNameToValueMap.get(styleName): any): string);
  }

  for (
    let styleSheetIndex = 0;
    styleSheetIndex < document.styleSheets.length;
    styleSheetIndex++
  ) {
    const styleSheet = ((document.styleSheets[
      styleSheetIndex
    ]: any): CSSStyleSheet);
    let rules: CSSRuleList | null = null;
    // this might throw if CORS rules are enforced https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
    try {
      rules = styleSheet.cssRules;
    } catch (_e) {
      continue;
    }

    for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {
      if (!(rules[ruleIndex] instanceof CSSStyleRule)) {
        continue;
      }
      const rule = ((rules[ruleIndex]: any): CSSStyleRule);
      const {cssText, selectorText, style} = rule;

      if (selectorText != null) {
        if (selectorText.startsWith(`.${styleName}`)) {
          const match = cssText.match(/{ *([a-z\-]+):/);
          if (match !== null) {
            const property = match[1];
            const value = style.getPropertyValue(property);

            cachedStyleNameToValueMap.set(styleName, value);

            return value;
          } else {
            return null;
          }
        }
      }
    }
  }

  return null;
}

Domain

Subdomains

Frequently Asked Questions

What does getPropertyValueForStyleName() do?
getPropertyValueForStyleName() is a function in the react codebase, defined in packages/react-devtools-shared/src/backend/StyleX/utils.js.
Where is getPropertyValueForStyleName() defined?
getPropertyValueForStyleName() is defined in packages/react-devtools-shared/src/backend/StyleX/utils.js at line 83.
What calls getPropertyValueForStyleName()?
getPropertyValueForStyleName() is called by 1 function(s): crawlObjectProperties.

Analyze Your Own Codebase

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

Try Supermodel Free