Home / File/ domEnvironment.js — react Source File

domEnvironment.js — react Source File

Architecture documentation for domEnvironment.js, a javascript file in the react codebase. 0 imports, 3 dependents.

File javascript BabelCompiler Optimization 3 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  c03693b0_2482_9a7d_a058_7ba891e5839d["domEnvironment.js"]
  d4066e75_dcea_2912_73ff_88e30b9530d2["domEventSequences.js"]
  d4066e75_dcea_2912_73ff_88e30b9530d2 --> c03693b0_2482_9a7d_a058_7ba891e5839d
  cfa588b4_57a7_0b0e_ec6d_2d8b58107071["index.js"]
  cfa588b4_57a7_0b0e_ec6d_2d8b58107071 --> c03693b0_2482_9a7d_a058_7ba891e5839d
  e8ddf5ea_829d_30ec_14cf_70bc1d21a7a6["testHelpers.js"]
  e8ddf5ea_829d_30ec_14cf_70bc1d21a7a6 --> c03693b0_2482_9a7d_a058_7ba891e5839d
  style c03693b0_2482_9a7d_a058_7ba891e5839d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

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';

/**
 * Change environment support for PointerEvent.
 */

function emptyFunction() {}

export function hasPointerEvent() {
  return global != null && global.PointerEvent != null;
}

export function setPointerEvent(bool) {
  const pointerCaptureFn = name => id => {
    if (typeof id !== 'number') {
      if (__DEV__) {
        console.error('A pointerId must be passed to "%s"', name);
      }
    }
  };
  global.PointerEvent = bool ? emptyFunction : undefined;
  global.HTMLElement.prototype.setPointerCapture = bool
    ? pointerCaptureFn('setPointerCapture')
    : undefined;
  global.HTMLElement.prototype.releasePointerCapture = bool
    ? pointerCaptureFn('releasePointerCapture')
    : undefined;
}

/**
 * Change environment host platform.
 */

const platformGetter = jest.spyOn(global.navigator, 'platform', 'get');

export const platform = {
  clear() {
    platformGetter.mockClear();
  },
  get() {
    return global.navigator.platform === 'MacIntel' ? 'mac' : 'windows';
  },
  set(name: 'mac' | 'windows') {
    switch (name) {
      case 'mac': {
        platformGetter.mockReturnValue('MacIntel');
        break;
      }
      case 'windows': {
        platformGetter.mockReturnValue('Win32');
        break;
      }
      default: {
        break;
      }
    }
  },
};

Domain

Subdomains

Frequently Asked Questions

What does domEnvironment.js do?
domEnvironment.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in domEnvironment.js?
domEnvironment.js defines 5 function(s): emptyFunction, hasPointerEvent, platform.clear, platform.get, setPointerEvent.
What files import domEnvironment.js?
domEnvironment.js is imported by 3 file(s): domEventSequences.js, index.js, testHelpers.js.
Where is domEnvironment.js in the architecture?
domEnvironment.js is located at packages/dom-event-testing-library/domEnvironment.js (domain: BabelCompiler, subdomain: Optimization, directory: packages/dom-event-testing-library).

Analyze Your Own Codebase

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

Try Supermodel Free