Home / File/ ReactDOMShorthandCSSPropertyCollision-test.js — react Source File

ReactDOMShorthandCSSPropertyCollision-test.js — react Source File

Architecture documentation for ReactDOMShorthandCSSPropertyCollision-test.js, a javascript file in the react codebase.

Entity Profile

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 */

'use strict';

describe('ReactDOMShorthandCSSPropertyCollision', () => {
  let act;

  let React;
  let ReactDOMClient;
  let assertConsoleErrorDev;

  beforeEach(() => {
    jest.resetModules();

    act = require('internal-test-utils').act;
    React = require('react');
    ReactDOMClient = require('react-dom/client');
    assertConsoleErrorDev =
      require('internal-test-utils').assertConsoleErrorDev;
  });

  it('should warn for conflicting CSS shorthand updates', async () => {
    const container = document.createElement('div');
    const root = ReactDOMClient.createRoot(container);
    await act(() => {
      root.render(<div style={{font: 'foo', fontStyle: 'bar'}} />);
    });
    await act(() => {
      root.render(<div style={{font: 'foo'}} />);
    });
    assertConsoleErrorDev([
      'Removing a style property during rerender (fontStyle) ' +
        'when a conflicting property is set (font) 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.' +
        '\n    in div (at **)',
    ]);

    // These updates are OK and don't warn:
    await act(() => {
      root.render(<div style={{font: 'qux', fontStyle: 'bar'}} />);
    });
    await act(() => {
      root.render(<div style={{font: 'foo', fontStyle: 'baz'}} />);
    });

    await act(() => {
      root.render(<div style={{font: 'qux', fontStyle: 'baz'}} />);
    });
    assertConsoleErrorDev([
      'Updating a style property during rerender (font) when ' +
        'a conflicting property is set (fontStyle) can lead to styling ' +
// ... (108 more lines)

Frequently Asked Questions

What does ReactDOMShorthandCSSPropertyCollision-test.js do?
ReactDOMShorthandCSSPropertyCollision-test.js is a source file in the react codebase, written in javascript.
Where is ReactDOMShorthandCSSPropertyCollision-test.js in the architecture?
ReactDOMShorthandCSSPropertyCollision-test.js is located at packages/react-dom/src/__tests__/ReactDOMShorthandCSSPropertyCollision-test.js (directory: packages/react-dom/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free