Home / File/ domEvents.js — react Source File

domEvents.js — react Source File

Architecture documentation for domEvents.js, a javascript file in the react codebase. 1 imports, 2 dependents.

File javascript BabelCompiler Entrypoint 1 imports 2 dependents 39 functions

Entity Profile

Dependency Diagram

graph LR
  fd9d5c95_e738_dee5_e510_e7b1e9e4ea39["domEvents.js"]
  f4316f6a_6bd2_2c45_d5ba_4eca3b37ec0d["constants.js"]
  fd9d5c95_e738_dee5_e510_e7b1e9e4ea39 --> f4316f6a_6bd2_2c45_d5ba_4eca3b37ec0d
  d4066e75_dcea_2912_73ff_88e30b9530d2["domEventSequences.js"]
  d4066e75_dcea_2912_73ff_88e30b9530d2 --> fd9d5c95_e738_dee5_e510_e7b1e9e4ea39
  cfa588b4_57a7_0b0e_ec6d_2d8b58107071["index.js"]
  cfa588b4_57a7_0b0e_ec6d_2d8b58107071 --> fd9d5c95_e738_dee5_e510_e7b1e9e4ea39
  style fd9d5c95_e738_dee5_e510_e7b1e9e4ea39 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';

import {
  buttonType,
  buttonsType,
  defaultPointerSize,
  defaultBrowserChromeSize,
} from './constants';

/**
 * Native event object mocks for higher-level events.
 *
 * 1. Each event type defines the exact object that it accepts. This ensures
 * that no arbitrary properties can be assigned to events, and the properties
 * that don't exist on specific event types (e.g., 'pointerType') are not added
 * to the respective native event.
 *
 * 2. Properties that cannot be relied on due to inconsistent browser support (e.g., 'x' and 'y') are not
 * added to the native event. Others that shouldn't be arbitrarily customized (e.g., 'screenX')
 * are automatically inferred from associated values.
 *
 * 3. PointerEvent and TouchEvent fields are normalized (e.g., 'rotationAngle' -> 'twist')
 */

function emptyFunction() {}

function createEvent(type, data = {}) {
  const event = document.createEvent('CustomEvent');
  event.initCustomEvent(type, true, true);
  if (data != null) {
    Object.keys(data).forEach(key => {
      const value = data[key];
      if (key === 'timeStamp' && !value) {
        return;
      }
      Object.defineProperty(event, key, {value});
    });
  }
  return event;
}

function createGetModifierState(keyArg, data) {
  if (keyArg === 'Alt') {
    return data.altKey || false;
  }
  if (keyArg === 'Control') {
    return data.ctrlKey || false;
  }
  if (keyArg === 'Meta') {
    return data.metaKey || false;
  }
// ... (383 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does domEvents.js do?
domEvents.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in domEvents.js?
domEvents.js defines 39 function(s): blur, click, contextmenu, createEvent, createGetModifierState, createKeyboardEvent, createMouseEvent, createPointerEvent, createTouchEvent, dragstart, and 29 more.
What does domEvents.js depend on?
domEvents.js imports 1 module(s): constants.js.
What files import domEvents.js?
domEvents.js is imported by 2 file(s): domEventSequences.js, index.js.
Where is domEvents.js in the architecture?
domEvents.js is located at packages/dom-event-testing-library/domEvents.js (domain: BabelCompiler, subdomain: Entrypoint, 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