Home / File/ BeforeInputEventPlugin.js — react Source File

BeforeInputEventPlugin.js — react Source File

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

File javascript BabelCompiler Validation 15 imports 1 dependents 12 functions

Entity Profile

Dependency Diagram

graph LR
  a235366c_1abe_162c_b9bf_7fbbfb597584["BeforeInputEventPlugin.js"]
  4e9925e9_ca97_8d79_6ffa_a9347d262615["DOMEventNames.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 4e9925e9_ca97_8d79_6ffa_a9347d262615
  441cc620_4cb4_9cec_2f7a_93b0594f4707["PluginModuleType.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 441cc620_4cb4_9cec_2f7a_93b0594f4707
  816b54e5_c63c_f8b2_68e8_0c637e281f03["DOMPluginEventSystem.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 816b54e5_c63c_f8b2_68e8_0c637e281f03
  e8ab76a4_05c2_cc4f_1bc2_aec96b5daa8c["EventSystemFlags.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> e8ab76a4_05c2_cc4f_1bc2_aec96b5daa8c
  3632e1a4_9237_b583_7260_c67d392d0405["ReactSyntheticEventType.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 3632e1a4_9237_b583_7260_c67d392d0405
  e1c602b7_5988_fa00_bb9f_269d66d38107["EventRegistry.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> e1c602b7_5988_fa00_bb9f_269d66d38107
  db2a0ac3_1faf_8e02_55e8_f299ce8da5e9["registerTwoPhaseEvent"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> db2a0ac3_1faf_8e02_55e8_f299ce8da5e9
  b23498c7_3fdf_15b2_7f8a_9e06622117b9["FallbackCompositionState.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> b23498c7_3fdf_15b2_7f8a_9e06622117b9
  93a4e6e5_b972_95b0_67a9_2e1ed302966b["getData"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 93a4e6e5_b972_95b0_67a9_2e1ed302966b
  e7d2980c_707d_e850_f4ab_158c0cbdccf5["initialize"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> e7d2980c_707d_e850_f4ab_158c0cbdccf5
  d8007def_cbde_a682_08cc_9711ffa76b29["reset"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> d8007def_cbde_a682_08cc_9711ffa76b29
  9c3d71d9_41af_c5e7_cd35_d25bbf6cf606["SyntheticEvent.js"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 9c3d71d9_41af_c5e7_cd35_d25bbf6cf606
  dd9eb6ac_296c_ca63_51dd_da82f645aaaa["accumulateTwoPhaseListeners"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> dd9eb6ac_296c_ca63_51dd_da82f645aaaa
  42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"]
  a235366c_1abe_162c_b9bf_7fbbfb597584 --> 42892443_e223_3da0_aeb9_e1b32a408fb0
  style a235366c_1abe_162c_b9bf_7fbbfb597584 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.
 *
 * @flow
 */

import type {DOMEventName} from '../../events/DOMEventNames';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import type {AnyNativeEvent} from '../../events/PluginModuleType';
import type {DispatchQueue} from '../DOMPluginEventSystem';
import type {EventSystemFlags} from '../EventSystemFlags';
import type {ReactSyntheticEvent} from '../ReactSyntheticEventType';

import {canUseDOM} from 'shared/ExecutionEnvironment';

import {registerTwoPhaseEvent} from '../EventRegistry';
import {
  getData as FallbackCompositionStateGetData,
  initialize as FallbackCompositionStateInitialize,
  reset as FallbackCompositionStateReset,
} from '../FallbackCompositionState';
import {
  SyntheticCompositionEvent,
  SyntheticInputEvent,
} from '../SyntheticEvent';
import {accumulateTwoPhaseListeners} from '../DOMPluginEventSystem';

const END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
const START_KEYCODE = 229;

const canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;

let documentMode = null;
if (canUseDOM && 'documentMode' in document) {
  documentMode = document.documentMode;
}

// Webkit offers a very useful `textInput` event that can be used to
// directly represent `beforeInput`. The IE `textinput` event is not as
// useful, so we don't use it.
const canUseTextInputEvent =
  canUseDOM && 'TextEvent' in window && !documentMode;

// In IE9+, we have access to composition events, but the data supplied
// by the native compositionend event may be incorrect. Japanese ideographic
// spaces, for instance (\u3000) are not recorded correctly.
const useFallbackCompositionData =
  canUseDOM &&
  (!canUseCompositionEvent ||
    (documentMode && documentMode > 8 && documentMode <= 11));

const SPACEBAR_CODE = 32;
const SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);

function registerEvents() {
  registerTwoPhaseEvent('onBeforeInput', [
    'compositionend',
// ... (401 more lines)

Domain

Subdomains

Frequently Asked Questions

What does BeforeInputEventPlugin.js do?
BeforeInputEventPlugin.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in BeforeInputEventPlugin.js?
BeforeInputEventPlugin.js defines 12 function(s): extractBeforeInputEvent, extractCompositionEvent, extractEvents, getCompositionEventType, getDataFromCustomEvent, getFallbackBeforeInputChars, getNativeBeforeInputChars, isFallbackCompositionEnd, isFallbackCompositionStart, isKeypressCommand, and 2 more.
What does BeforeInputEventPlugin.js depend on?
BeforeInputEventPlugin.js imports 15 module(s): DOMEventNames.js, DOMPluginEventSystem.js, EventRegistry.js, EventSystemFlags.js, ExecutionEnvironment, FallbackCompositionState.js, PluginModuleType.js, ReactInternalTypes, and 7 more.
What files import BeforeInputEventPlugin.js?
BeforeInputEventPlugin.js is imported by 1 file(s): DOMPluginEventSystem.js.
Where is BeforeInputEventPlugin.js in the architecture?
BeforeInputEventPlugin.js is located at packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/events/plugins).

Analyze Your Own Codebase

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

Try Supermodel Free