Home / Function/ validateShorthandPropertyCollisionInDev() — react Function Reference

validateShorthandPropertyCollisionInDev() — react Function Reference

Architecture documentation for the validateShorthandPropertyCollisionInDev() function in CSSPropertyOperations.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  db812c8f_ddfe_4781_b849_4e6ff94d7b5f["validateShorthandPropertyCollisionInDev()"]
  e3e314a2_4cee_1a10_2d68_791d5d66f89e["CSSPropertyOperations.js"]
  db812c8f_ddfe_4781_b849_4e6ff94d7b5f -->|defined in| e3e314a2_4cee_1a10_2d68_791d5d66f89e
  236c422d_d866_d548_e097_3cec99530791["setValueForStyles()"]
  236c422d_d866_d548_e097_3cec99530791 -->|calls| db812c8f_ddfe_4781_b849_4e6ff94d7b5f
  5ca9f93d_b533_9077_5b39_fae400ae83d2["expandShorthandMap()"]
  db812c8f_ddfe_4781_b849_4e6ff94d7b5f -->|calls| 5ca9f93d_b533_9077_5b39_fae400ae83d2
  c56231db_5fae_0e69_9419_72df968843ac["isValueEmpty()"]
  db812c8f_ddfe_4781_b849_4e6ff94d7b5f -->|calls| c56231db_5fae_0e69_9419_72df968843ac
  style db812c8f_ddfe_4781_b849_4e6ff94d7b5f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/client/CSSPropertyOperations.js lines 205–259

function validateShorthandPropertyCollisionInDev(prevStyles, nextStyles) {
  if (__DEV__) {
    if (!nextStyles) {
      return;
    }

    // Compute the diff as it would happen elsewhere.
    const expandedUpdates = {};
    if (prevStyles) {
      for (const key in prevStyles) {
        if (prevStyles.hasOwnProperty(key) && !nextStyles.hasOwnProperty(key)) {
          const longhands = shorthandToLonghand[key] || [key];
          for (let i = 0; i < longhands.length; i++) {
            expandedUpdates[longhands[i]] = key;
          }
        }
      }
    }
    for (const key in nextStyles) {
      if (
        nextStyles.hasOwnProperty(key) &&
        (!prevStyles || prevStyles[key] !== nextStyles[key])
      ) {
        const longhands = shorthandToLonghand[key] || [key];
        for (let i = 0; i < longhands.length; i++) {
          expandedUpdates[longhands[i]] = key;
        }
      }
    }

    const expandedStyles = expandShorthandMap(nextStyles);
    const warnedAbout = {};
    for (const key in expandedUpdates) {
      const originalKey = expandedUpdates[key];
      const correctOriginalKey = expandedStyles[key];
      if (correctOriginalKey && originalKey !== correctOriginalKey) {
        const warningKey = originalKey + ',' + correctOriginalKey;
        if (warnedAbout[warningKey]) {
          continue;
        }
        warnedAbout[warningKey] = true;
        console.error(
          '%s a style property during rerender (%s) when a ' +
            'conflicting property is set (%s) can lead to styling bugs. To ' +
            "avoid this, don't mix shorthand and non-shorthand properties " +
            'for the same value; instead, replace the shorthand with ' +
            'separate values.',
          isValueEmpty(nextStyles[originalKey]) ? 'Removing' : 'Updating',
          originalKey,
          correctOriginalKey,
        );
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does validateShorthandPropertyCollisionInDev() do?
validateShorthandPropertyCollisionInDev() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/CSSPropertyOperations.js.
Where is validateShorthandPropertyCollisionInDev() defined?
validateShorthandPropertyCollisionInDev() is defined in packages/react-dom-bindings/src/client/CSSPropertyOperations.js at line 205.
What does validateShorthandPropertyCollisionInDev() call?
validateShorthandPropertyCollisionInDev() calls 2 function(s): expandShorthandMap, isValueEmpty.
What calls validateShorthandPropertyCollisionInDev()?
validateShorthandPropertyCollisionInDev() is called by 1 function(s): setValueForStyles.

Analyze Your Own Codebase

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

Try Supermodel Free