123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
- (global = global || self, factory(global.ReactTestUtils = {}, global.React, global.ReactDOM));
- }(this, (function (exports, React, ReactDOM) { 'use strict';
- var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
- var _assign = ReactInternals.assign;
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-
-
-
-
- function warn(format) {
- {
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
- printWarning('warn', format, args);
- }
- }
- function error(format) {
- {
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
- args[_key2 - 1] = arguments[_key2];
- }
- printWarning('error', format, args);
- }
- }
- function printWarning(level, format, args) {
-
-
- {
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
- var stack = ReactDebugCurrentFrame.getStackAddendum();
- if (stack !== '') {
- format += '%s';
- args = args.concat([stack]);
- }
- var argsWithFormat = args.map(function (item) {
- return '' + item;
- });
- argsWithFormat.unshift('Warning: ' + format);
-
-
- Function.prototype.apply.call(console[level], console, argsWithFormat);
- }
- }
-
- function get(key) {
- return key._reactInternals;
- }
-
-
-
-
-
- var REACT_ELEMENT_TYPE = 0xeac7;
- var REACT_PORTAL_TYPE = 0xeaca;
- var REACT_FRAGMENT_TYPE = 0xeacb;
- var REACT_STRICT_MODE_TYPE = 0xeacc;
- var REACT_PROFILER_TYPE = 0xead2;
- var REACT_PROVIDER_TYPE = 0xeacd;
- var REACT_CONTEXT_TYPE = 0xeace;
- var REACT_FORWARD_REF_TYPE = 0xead0;
- var REACT_SUSPENSE_TYPE = 0xead1;
- var REACT_SUSPENSE_LIST_TYPE = 0xead8;
- var REACT_MEMO_TYPE = 0xead3;
- var REACT_LAZY_TYPE = 0xead4;
- var REACT_BLOCK_TYPE = 0xead9;
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
- var REACT_SCOPE_TYPE = 0xead7;
- var REACT_OPAQUE_ID_TYPE = 0xeae0;
- var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
- var REACT_OFFSCREEN_TYPE = 0xeae2;
- var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
- if (typeof Symbol === 'function' && Symbol.for) {
- var symbolFor = Symbol.for;
- REACT_ELEMENT_TYPE = symbolFor('react.element');
- REACT_PORTAL_TYPE = symbolFor('react.portal');
- REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
- REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
- REACT_PROFILER_TYPE = symbolFor('react.profiler');
- REACT_PROVIDER_TYPE = symbolFor('react.provider');
- REACT_CONTEXT_TYPE = symbolFor('react.context');
- REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
- REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
- REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
- REACT_MEMO_TYPE = symbolFor('react.memo');
- REACT_LAZY_TYPE = symbolFor('react.lazy');
- REACT_BLOCK_TYPE = symbolFor('react.block');
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
- REACT_SCOPE_TYPE = symbolFor('react.scope');
- REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
- REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
- REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
- REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
- }
- var FunctionComponent = 0;
- var ClassComponent = 1;
- var HostRoot = 3;
- var HostComponent = 5;
- var HostText = 6;
-
- var NoFlags =
-
- 0;
- var Placement =
-
- 2;
- var Hydrating =
-
- 1024;
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
- function getNearestMountedFiber(fiber) {
- var node = fiber;
- var nearestMounted = fiber;
- if (!fiber.alternate) {
-
-
- var nextNode = node;
- do {
- node = nextNode;
- if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
-
-
-
- nearestMounted = node.return;
- }
- nextNode = node.return;
- } while (nextNode);
- } else {
- while (node.return) {
- node = node.return;
- }
- }
- if (node.tag === HostRoot) {
-
-
- return nearestMounted;
- }
-
- return null;
- }
- function assertIsMounted(fiber) {
- if (!(getNearestMountedFiber(fiber) === fiber)) {
- {
- throw Error( "Unable to find node on an unmounted component." );
- }
- }
- }
- function findCurrentFiberUsingSlowPath(fiber) {
- var alternate = fiber.alternate;
- if (!alternate) {
-
- var nearestMounted = getNearestMountedFiber(fiber);
- if (!(nearestMounted !== null)) {
- {
- throw Error( "Unable to find node on an unmounted component." );
- }
- }
- if (nearestMounted !== fiber) {
- return null;
- }
- return fiber;
- }
-
-
- var a = fiber;
- var b = alternate;
- while (true) {
- var parentA = a.return;
- if (parentA === null) {
-
- break;
- }
- var parentB = parentA.alternate;
- if (parentB === null) {
-
-
-
-
- var nextParent = parentA.return;
- if (nextParent !== null) {
- a = b = nextParent;
- continue;
- }
- break;
- }
-
-
- if (parentA.child === parentB.child) {
- var child = parentA.child;
- while (child) {
- if (child === a) {
-
- assertIsMounted(parentA);
- return fiber;
- }
- if (child === b) {
-
- assertIsMounted(parentA);
- return alternate;
- }
- child = child.sibling;
- }
-
- {
- {
- throw Error( "Unable to find node on an unmounted component." );
- }
- }
- }
- if (a.return !== b.return) {
-
-
-
-
- a = parentA;
- b = parentB;
- } else {
-
-
-
-
-
- var didFindChild = false;
- var _child = parentA.child;
- while (_child) {
- if (_child === a) {
- didFindChild = true;
- a = parentA;
- b = parentB;
- break;
- }
- if (_child === b) {
- didFindChild = true;
- b = parentA;
- a = parentB;
- break;
- }
- _child = _child.sibling;
- }
- if (!didFindChild) {
-
- _child = parentB.child;
- while (_child) {
- if (_child === a) {
- didFindChild = true;
- a = parentB;
- b = parentA;
- break;
- }
- if (_child === b) {
- didFindChild = true;
- b = parentB;
- a = parentA;
- break;
- }
- _child = _child.sibling;
- }
- if (!didFindChild) {
- {
- throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." );
- }
- }
- }
- }
- if (!(a.alternate === b)) {
- {
- throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." );
- }
- }
- }
-
- if (!(a.tag === HostRoot)) {
- {
- throw Error( "Unable to find node on an unmounted component." );
- }
- }
- if (a.stateNode.current === a) {
-
- return fiber;
- }
- return alternate;
- }
-
- function getEventCharCode(nativeEvent) {
- var charCode;
- var keyCode = nativeEvent.keyCode;
- if ('charCode' in nativeEvent) {
- charCode = nativeEvent.charCode;
- if (charCode === 0 && keyCode === 13) {
- charCode = 13;
- }
- } else {
-
- charCode = keyCode;
- }
-
- if (charCode === 10) {
- charCode = 13;
- }
-
- if (charCode >= 32 || charCode === 13) {
- return charCode;
- }
- return 0;
- }
- function functionThatReturnsTrue() {
- return true;
- }
- function functionThatReturnsFalse() {
- return false;
- }
-
- function createSyntheticEvent(Interface) {
-
- function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
- this._reactName = reactName;
- this._targetInst = targetInst;
- this.type = reactEventType;
- this.nativeEvent = nativeEvent;
- this.target = nativeEventTarget;
- this.currentTarget = null;
- for (var _propName in Interface) {
- if (!Interface.hasOwnProperty(_propName)) {
- continue;
- }
- var normalize = Interface[_propName];
- if (normalize) {
- this[_propName] = normalize(nativeEvent);
- } else {
- this[_propName] = nativeEvent[_propName];
- }
- }
- var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
- if (defaultPrevented) {
- this.isDefaultPrevented = functionThatReturnsTrue;
- } else {
- this.isDefaultPrevented = functionThatReturnsFalse;
- }
- this.isPropagationStopped = functionThatReturnsFalse;
- return this;
- }
- _assign(SyntheticBaseEvent.prototype, {
- preventDefault: function () {
- this.defaultPrevented = true;
- var event = this.nativeEvent;
- if (!event) {
- return;
- }
- if (event.preventDefault) {
- event.preventDefault();
- } else if (typeof event.returnValue !== 'unknown') {
- event.returnValue = false;
- }
- this.isDefaultPrevented = functionThatReturnsTrue;
- },
- stopPropagation: function () {
- var event = this.nativeEvent;
- if (!event) {
- return;
- }
- if (event.stopPropagation) {
- event.stopPropagation();
- } else if (typeof event.cancelBubble !== 'unknown') {
-
-
-
-
-
- event.cancelBubble = true;
- }
- this.isPropagationStopped = functionThatReturnsTrue;
- },
-
- persist: function () {
- },
-
- isPersistent: functionThatReturnsTrue
- });
- return SyntheticBaseEvent;
- }
-
- var EventInterface = {
- eventPhase: 0,
- bubbles: 0,
- cancelable: 0,
- timeStamp: function (event) {
- return event.timeStamp || Date.now();
- },
- defaultPrevented: 0,
- isTrusted: 0
- };
- var SyntheticEvent = createSyntheticEvent(EventInterface);
- var UIEventInterface = _assign({}, EventInterface, {
- view: 0,
- detail: 0
- });
- var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
- var lastMovementX;
- var lastMovementY;
- var lastMouseEvent;
- function updateMouseMovementPolyfillState(event) {
- if (event !== lastMouseEvent) {
- if (lastMouseEvent && event.type === 'mousemove') {
- lastMovementX = event.screenX - lastMouseEvent.screenX;
- lastMovementY = event.screenY - lastMouseEvent.screenY;
- } else {
- lastMovementX = 0;
- lastMovementY = 0;
- }
- lastMouseEvent = event;
- }
- }
-
- var MouseEventInterface = _assign({}, UIEventInterface, {
- screenX: 0,
- screenY: 0,
- clientX: 0,
- clientY: 0,
- pageX: 0,
- pageY: 0,
- ctrlKey: 0,
- shiftKey: 0,
- altKey: 0,
- metaKey: 0,
- getModifierState: getEventModifierState,
- button: 0,
- buttons: 0,
- relatedTarget: function (event) {
- if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement;
- return event.relatedTarget;
- },
- movementX: function (event) {
- if ('movementX' in event) {
- return event.movementX;
- }
- updateMouseMovementPolyfillState(event);
- return lastMovementX;
- },
- movementY: function (event) {
- if ('movementY' in event) {
- return event.movementY;
- }
-
-
- return lastMovementY;
- }
- });
- var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
-
- var DragEventInterface = _assign({}, MouseEventInterface, {
- dataTransfer: 0
- });
- var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
-
- var FocusEventInterface = _assign({}, UIEventInterface, {
- relatedTarget: 0
- });
- var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
-
- var AnimationEventInterface = _assign({}, EventInterface, {
- animationName: 0,
- elapsedTime: 0,
- pseudoElement: 0
- });
- var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
-
- var ClipboardEventInterface = _assign({}, EventInterface, {
- clipboardData: function (event) {
- return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
- }
- });
- var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
-
- var CompositionEventInterface = _assign({}, EventInterface, {
- data: 0
- });
- var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
-
- var normalizeKey = {
- Esc: 'Escape',
- Spacebar: ' ',
- Left: 'ArrowLeft',
- Up: 'ArrowUp',
- Right: 'ArrowRight',
- Down: 'ArrowDown',
- Del: 'Delete',
- Win: 'OS',
- Menu: 'ContextMenu',
- Apps: 'ContextMenu',
- Scroll: 'ScrollLock',
- MozPrintableKey: 'Unidentified'
- };
-
- var translateToKey = {
- '8': 'Backspace',
- '9': 'Tab',
- '12': 'Clear',
- '13': 'Enter',
- '16': 'Shift',
- '17': 'Control',
- '18': 'Alt',
- '19': 'Pause',
- '20': 'CapsLock',
- '27': 'Escape',
- '32': ' ',
- '33': 'PageUp',
- '34': 'PageDown',
- '35': 'End',
- '36': 'Home',
- '37': 'ArrowLeft',
- '38': 'ArrowUp',
- '39': 'ArrowRight',
- '40': 'ArrowDown',
- '45': 'Insert',
- '46': 'Delete',
- '112': 'F1',
- '113': 'F2',
- '114': 'F3',
- '115': 'F4',
- '116': 'F5',
- '117': 'F6',
- '118': 'F7',
- '119': 'F8',
- '120': 'F9',
- '121': 'F10',
- '122': 'F11',
- '123': 'F12',
- '144': 'NumLock',
- '145': 'ScrollLock',
- '224': 'Meta'
- };
-
- function getEventKey(nativeEvent) {
- if (nativeEvent.key) {
-
-
-
-
- var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
- if (key !== 'Unidentified') {
- return key;
- }
- }
- if (nativeEvent.type === 'keypress') {
- var charCode = getEventCharCode(nativeEvent);
-
- return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
- }
- if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
-
-
- return translateToKey[nativeEvent.keyCode] || 'Unidentified';
- }
- return '';
- }
-
- var modifierKeyToProp = {
- Alt: 'altKey',
- Control: 'ctrlKey',
- Meta: 'metaKey',
- Shift: 'shiftKey'
- };
-
-
- function modifierStateGetter(keyArg) {
- var syntheticEvent = this;
- var nativeEvent = syntheticEvent.nativeEvent;
- if (nativeEvent.getModifierState) {
- return nativeEvent.getModifierState(keyArg);
- }
- var keyProp = modifierKeyToProp[keyArg];
- return keyProp ? !!nativeEvent[keyProp] : false;
- }
- function getEventModifierState(nativeEvent) {
- return modifierStateGetter;
- }
-
- var KeyboardEventInterface = _assign({}, UIEventInterface, {
- key: getEventKey,
- code: 0,
- location: 0,
- ctrlKey: 0,
- shiftKey: 0,
- altKey: 0,
- metaKey: 0,
- repeat: 0,
- locale: 0,
- getModifierState: getEventModifierState,
-
- charCode: function (event) {
-
-
-
-
- if (event.type === 'keypress') {
- return getEventCharCode(event);
- }
- return 0;
- },
- keyCode: function (event) {
-
-
-
-
-
-
- if (event.type === 'keydown' || event.type === 'keyup') {
- return event.keyCode;
- }
- return 0;
- },
- which: function (event) {
-
-
- if (event.type === 'keypress') {
- return getEventCharCode(event);
- }
- if (event.type === 'keydown' || event.type === 'keyup') {
- return event.keyCode;
- }
- return 0;
- }
- });
- var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
-
- var PointerEventInterface = _assign({}, MouseEventInterface, {
- pointerId: 0,
- width: 0,
- height: 0,
- pressure: 0,
- tangentialPressure: 0,
- tiltX: 0,
- tiltY: 0,
- twist: 0,
- pointerType: 0,
- isPrimary: 0
- });
- var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
-
- var TouchEventInterface = _assign({}, UIEventInterface, {
- touches: 0,
- targetTouches: 0,
- changedTouches: 0,
- altKey: 0,
- metaKey: 0,
- ctrlKey: 0,
- shiftKey: 0,
- getModifierState: getEventModifierState
- });
- var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
-
- var TransitionEventInterface = _assign({}, EventInterface, {
- propertyName: 0,
- elapsedTime: 0,
- pseudoElement: 0
- });
- var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
-
- var WheelEventInterface = _assign({}, MouseEventInterface, {
- deltaX: function (event) {
- return 'deltaX' in event ? event.deltaX :
- 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
- },
- deltaY: function (event) {
- return 'deltaY' in event ? event.deltaY :
- 'wheelDeltaY' in event ? -event.wheelDeltaY :
- 'wheelDelta' in event ? -event.wheelDelta : 0;
- },
- deltaZ: 0,
-
-
-
-
- deltaMode: 0
- });
- var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
-
- var ELEMENT_NODE = 1;
- var didWarnAboutMessageChannel = false;
- var enqueueTaskImpl = null;
- function enqueueTask(task) {
- if (enqueueTaskImpl === null) {
- try {
-
-
- var requireString = ('require' + Math.random()).slice(0, 7);
- var nodeRequire = module && module[requireString];
-
- enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
- } catch (_err) {
-
-
-
- enqueueTaskImpl = function (callback) {
- {
- if (didWarnAboutMessageChannel === false) {
- didWarnAboutMessageChannel = true;
- if (typeof MessageChannel === 'undefined') {
- error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
- }
- }
- }
- var channel = new MessageChannel();
- channel.port1.onmessage = callback;
- channel.port2.postMessage(undefined);
- };
- }
- }
- return enqueueTaskImpl(task);
- }
- var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
- var _ReactInternals$Sched = ReactInternals$1.Scheduler,
- unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback,
- unstable_now = _ReactInternals$Sched.unstable_now,
- unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback,
- unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield,
- unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint,
- unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode,
- unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority,
- unstable_next = _ReactInternals$Sched.unstable_next,
- unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution,
- unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution,
- unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel,
- unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority,
- unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority,
- unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority,
- unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority,
- unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority,
- unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate,
- unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting;
- var EventInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
-
-
-
-
- var flushPassiveEffects = EventInternals[5];
- var IsThisRendererActing = EventInternals[6];
- var batchedUpdates = ReactDOM.unstable_batchedUpdates;
- var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
-
-
-
-
-
-
-
-
- var isSchedulerMocked = typeof unstable_flushAllWithoutAsserting === 'function';
- var flushWork = unstable_flushAllWithoutAsserting || function () {
- var didFlushWork = false;
- while (flushPassiveEffects()) {
- didFlushWork = true;
- }
- return didFlushWork;
- };
- function flushWorkAndMicroTasks(onDone) {
- try {
- flushWork();
- enqueueTask(function () {
- if (flushWork()) {
- flushWorkAndMicroTasks(onDone);
- } else {
- onDone();
- }
- });
- } catch (err) {
- onDone(err);
- }
- }
-
- var actingUpdatesScopeDepth = 0;
- function act(callback) {
- var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
- actingUpdatesScopeDepth++;
- var previousIsSomeRendererActing = IsSomeRendererActing.current;
- var previousIsThisRendererActing = IsThisRendererActing.current;
- IsSomeRendererActing.current = true;
- IsThisRendererActing.current = true;
- function onDone() {
- actingUpdatesScopeDepth--;
- IsSomeRendererActing.current = previousIsSomeRendererActing;
- IsThisRendererActing.current = previousIsThisRendererActing;
- {
- if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
-
- error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
- }
- }
- }
- var result;
- try {
- result = batchedUpdates(callback);
- } catch (error) {
-
- onDone();
- throw error;
- }
- if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
-
-
- var called = false;
- {
- if (typeof Promise !== 'undefined') {
-
- Promise.resolve().then(function () {}).then(function () {
- if (called === false) {
- error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, interleaving multiple act ' + 'calls and mixing their scopes. You should - await act(async () => ...);');
- }
- });
- }
- }
-
-
- return {
- then: function (resolve, reject) {
- called = true;
- result.then(function () {
- if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
- onDone();
- resolve();
- return;
- }
-
- flushWorkAndMicroTasks(function (err) {
- onDone();
- if (err) {
- reject(err);
- } else {
- resolve();
- }
- });
- }, function (err) {
- onDone();
- reject(err);
- });
- }
- };
- } else {
- {
- if (result !== undefined) {
- error('The callback passed to act(...) function ' + 'must return undefined, or a Promise. You returned %s', result);
- }
- }
- try {
- if (actingUpdatesScopeDepth === 1 && (isSchedulerMocked === false || previousIsSomeRendererActing === false)) {
-
-
- flushWork();
- }
- onDone();
- } catch (err) {
- onDone();
- throw err;
- }
- return {
- then: function (resolve) {
- {
- error('Do not await the result of calling act(...) with sync logic, it is not a Promise.');
- }
- resolve();
- }
- };
- }
- }
- var EventInternals$1 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
-
-
-
-
-
- var IsThisRendererActing$1 = EventInternals$1[6];
- var batchedUpdates$1 = ReactDOM.unstable_batchedUpdates;
- var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing;
-
-
-
-
-
- var actingUpdatesScopeDepth$1 = 0;
- function unstable_concurrentAct(scope) {
- if (unstable_flushAllWithoutAsserting === undefined) {
- throw Error('This version of `act` requires a special mock build of Scheduler.');
- }
- if (setTimeout._isMockFunction !== true) {
- throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
- }
- var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth$1;
- var previousIsSomeRendererActing = IsSomeRendererActing$1.current;
- var previousIsThisRendererActing = IsThisRendererActing$1.current;
- IsSomeRendererActing$1.current = true;
- IsThisRendererActing$1.current = true;
- actingUpdatesScopeDepth$1++;
- var unwind = function () {
- actingUpdatesScopeDepth$1--;
- IsSomeRendererActing$1.current = previousIsSomeRendererActing;
- IsThisRendererActing$1.current = previousIsThisRendererActing;
- {
- if (actingUpdatesScopeDepth$1 > previousActingUpdatesScopeDepth) {
-
-
- error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
- }
- }
- };
-
-
- try {
- var thenable = batchedUpdates$1(scope);
- if (typeof thenable === 'object' && thenable !== null && typeof thenable.then === 'function') {
- return {
- then: function (resolve, reject) {
- thenable.then(function () {
- flushActWork(function () {
- unwind();
- resolve();
- }, function (error) {
- unwind();
- reject(error);
- });
- }, function (error) {
- unwind();
- reject(error);
- });
- }
- };
- } else {
- try {
-
-
- var didFlushWork;
- do {
- didFlushWork = unstable_flushAllWithoutAsserting();
- } while (didFlushWork);
- } finally {
- unwind();
- }
- }
- } catch (error) {
- unwind();
- throw error;
- }
- }
- function flushActWork(resolve, reject) {
-
-
- jest.runOnlyPendingTimers();
- enqueueTask(function () {
- try {
- var didFlushWork = unstable_flushAllWithoutAsserting();
- if (didFlushWork) {
- flushActWork(resolve, reject);
- } else {
- resolve();
- }
- } catch (error) {
- reject(error);
- }
- });
- }
- function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
- var funcArgs = Array.prototype.slice.call(arguments, 3);
- try {
- func.apply(context, funcArgs);
- } catch (error) {
- this.onError(error);
- }
- }
- var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
- var fakeNode = document.createElement('react');
- invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) {
-
-
-
-
- if (!(typeof document !== 'undefined')) {
- {
- throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." );
- }
- }
- var evt = document.createEvent('Event');
- var didCall = false;
-
-
-
-
-
- var didError = true;
-
-
- var windowEvent = window.event;
-
- var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
- function restoreAfterDispatch() {
-
-
-
-
- fakeNode.removeEventListener(evtType, callCallback, false);
-
-
-
- if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
- window.event = windowEvent;
- }
- }
-
-
- var funcArgs = Array.prototype.slice.call(arguments, 3);
- function callCallback() {
- didCall = true;
- restoreAfterDispatch();
- func.apply(context, funcArgs);
- didError = false;
- }
-
-
-
-
-
-
-
-
-
-
- var error;
- var didSetError = false;
- var isCrossOriginError = false;
- function handleWindowError(event) {
- error = event.error;
- didSetError = true;
- if (error === null && event.colno === 0 && event.lineno === 0) {
- isCrossOriginError = true;
- }
- if (event.defaultPrevented) {
-
-
-
- if (error != null && typeof error === 'object') {
- try {
- error._suppressLogging = true;
- } catch (inner) {
- }
- }
- }
- }
- var evtType = "react-" + (name ? name : 'invokeguardedcallback');
- window.addEventListener('error', handleWindowError);
- fakeNode.addEventListener(evtType, callCallback, false);
-
- evt.initEvent(evtType, false, false);
- fakeNode.dispatchEvent(evt);
- if (windowEventDescriptor) {
- Object.defineProperty(window, 'event', windowEventDescriptor);
- }
- if (didCall && didError) {
- if (!didSetError) {
-
- error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
- } else if (isCrossOriginError) {
- error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.');
- }
- this.onError(error);
- }
- window.removeEventListener('error', handleWindowError);
- if (!didCall) {
-
-
-
-
- restoreAfterDispatch();
- return invokeGuardedCallbackProd.apply(this, arguments);
- }
- };
- }
- }
- var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
- var hasError = false;
- var caughtError = null;
- var hasRethrowError = false;
- var rethrowError = null;
- var reporter = {
- onError: function (error) {
- hasError = true;
- caughtError = error;
- }
- };
-
- function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
- hasError = false;
- caughtError = null;
- invokeGuardedCallbackImpl$1.apply(reporter, arguments);
- }
-
- function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
- invokeGuardedCallback.apply(this, arguments);
- if (hasError) {
- var error = clearCaughtError();
- if (!hasRethrowError) {
- hasRethrowError = true;
- rethrowError = error;
- }
- }
- }
-
- function rethrowCaughtError() {
- if (hasRethrowError) {
- var error = rethrowError;
- hasRethrowError = false;
- rethrowError = null;
- throw error;
- }
- }
- function clearCaughtError() {
- if (hasError) {
- var error = caughtError;
- hasError = false;
- caughtError = null;
- return error;
- } else {
- {
- {
- throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." );
- }
- }
- }
- }
- var EventInternals$2 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
- var getInstanceFromNode = EventInternals$2[0];
- var getNodeFromInstance = EventInternals$2[1];
- var getFiberCurrentPropsFromNode = EventInternals$2[2];
- var enqueueStateRestore = EventInternals$2[3];
- var restoreStateIfNeeded = EventInternals$2[4];
-
-
- function Event(suffix) {}
- var hasWarnedAboutDeprecatedMockComponent = false;
-
- function findAllInRenderedFiberTreeInternal(fiber, test) {
- if (!fiber) {
- return [];
- }
- var currentParent = findCurrentFiberUsingSlowPath(fiber);
- if (!currentParent) {
- return [];
- }
- var node = currentParent;
- var ret = [];
- while (true) {
- if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
- var publicInst = node.stateNode;
- if (test(publicInst)) {
- ret.push(publicInst);
- }
- }
- if (node.child) {
- node.child.return = node;
- node = node.child;
- continue;
- }
- if (node === currentParent) {
- return ret;
- }
- while (!node.sibling) {
- if (!node.return || node.return === currentParent) {
- return ret;
- }
- node = node.return;
- }
- node.sibling.return = node.return;
- node = node.sibling;
- }
- }
- function validateClassInstance(inst, methodName) {
- if (!inst) {
-
- return;
- }
- if (get(inst)) {
-
- return;
- }
- var received;
- var stringified = '' + inst;
- if (Array.isArray(inst)) {
- received = 'an array';
- } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
- received = 'a DOM node';
- } else if (stringified === '[object Object]') {
- received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
- } else {
- received = stringified;
- }
- {
- {
- throw Error( methodName + "(...): the first argument must be a React class instance. Instead received: " + received + "." );
- }
- }
- }
-
- function renderIntoDocument(element) {
- var div = document.createElement('div');
-
-
-
-
- return ReactDOM.render(element, div);
- }
- function isElement(element) {
- return React.isValidElement(element);
- }
- function isElementOfType(inst, convenienceConstructor) {
- return React.isValidElement(inst) && inst.type === convenienceConstructor;
- }
- function isDOMComponent(inst) {
- return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
- }
- function isDOMComponentElement(inst) {
- return !!(inst && React.isValidElement(inst) && !!inst.tagName);
- }
- function isCompositeComponent(inst) {
- if (isDOMComponent(inst)) {
-
-
- return false;
- }
- return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
- }
- function isCompositeComponentWithType(inst, type) {
- if (!isCompositeComponent(inst)) {
- return false;
- }
- var internalInstance = get(inst);
- var constructor = internalInstance.type;
- return constructor === type;
- }
- function findAllInRenderedTree(inst, test) {
- validateClassInstance(inst, 'findAllInRenderedTree');
- if (!inst) {
- return [];
- }
- var internalInstance = get(inst);
- return findAllInRenderedFiberTreeInternal(internalInstance, test);
- }
-
- function scryRenderedDOMComponentsWithClass(root, classNames) {
- validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
- return findAllInRenderedTree(root, function (inst) {
- if (isDOMComponent(inst)) {
- var className = inst.className;
- if (typeof className !== 'string') {
-
- className = inst.getAttribute('class') || '';
- }
- var classList = className.split(/\s+/);
- if (!Array.isArray(classNames)) {
- if (!(classNames !== undefined)) {
- {
- throw Error( "TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument." );
- }
- }
- classNames = classNames.split(/\s+/);
- }
- return classNames.every(function (name) {
- return classList.indexOf(name) !== -1;
- });
- }
- return false;
- });
- }
-
- function findRenderedDOMComponentWithClass(root, className) {
- validateClassInstance(root, 'findRenderedDOMComponentWithClass');
- var all = scryRenderedDOMComponentsWithClass(root, className);
- if (all.length !== 1) {
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
- }
- return all[0];
- }
-
- function scryRenderedDOMComponentsWithTag(root, tagName) {
- validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
- return findAllInRenderedTree(root, function (inst) {
- return isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
- });
- }
-
- function findRenderedDOMComponentWithTag(root, tagName) {
- validateClassInstance(root, 'findRenderedDOMComponentWithTag');
- var all = scryRenderedDOMComponentsWithTag(root, tagName);
- if (all.length !== 1) {
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
- }
- return all[0];
- }
-
- function scryRenderedComponentsWithType(root, componentType) {
- validateClassInstance(root, 'scryRenderedComponentsWithType');
- return findAllInRenderedTree(root, function (inst) {
- return isCompositeComponentWithType(inst, componentType);
- });
- }
-
- function findRenderedComponentWithType(root, componentType) {
- validateClassInstance(root, 'findRenderedComponentWithType');
- var all = scryRenderedComponentsWithType(root, componentType);
- if (all.length !== 1) {
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
- }
- return all[0];
- }
-
- function mockComponent(module, mockTagName) {
- {
- if (!hasWarnedAboutDeprecatedMockComponent) {
- hasWarnedAboutDeprecatedMockComponent = true;
- warn('ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://reactjs.org/link/test-utils-mock-component for more information.');
- }
- }
- mockTagName = mockTagName || module.mockTagName || 'div';
- module.prototype.render.mockImplementation(function () {
- return React.createElement(mockTagName, null, this.props.children);
- });
- return this;
- }
- function nativeTouchData(x, y) {
- return {
- touches: [{
- pageX: x,
- pageY: y
- }]
- };
- }
-
-
-
- function executeDispatch(event, listener, inst) {
- var type = event.type || 'unknown-event';
- event.currentTarget = getNodeFromInstance(inst);
- invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
- event.currentTarget = null;
- }
-
- function executeDispatchesInOrder(event) {
- var dispatchListeners = event._dispatchListeners;
- var dispatchInstances = event._dispatchInstances;
- if (Array.isArray(dispatchListeners)) {
- for (var i = 0; i < dispatchListeners.length; i++) {
- if (event.isPropagationStopped()) {
- break;
- }
- executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
- }
- } else if (dispatchListeners) {
- executeDispatch(event, dispatchListeners, dispatchInstances);
- }
- event._dispatchListeners = null;
- event._dispatchInstances = null;
- }
-
- var executeDispatchesAndRelease = function (event) {
- if (event) {
- executeDispatchesInOrder(event);
- if (!event.isPersistent()) {
- event.constructor.release(event);
- }
- }
- };
- function isInteractive(tag) {
- return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
- }
- function getParent(inst) {
- do {
- inst = inst.return;
-
-
-
-
- } while (inst && inst.tag !== HostComponent);
- if (inst) {
- return inst;
- }
- return null;
- }
-
- function traverseTwoPhase(inst, fn, arg) {
- var path = [];
- while (inst) {
- path.push(inst);
- inst = getParent(inst);
- }
- var i;
- for (i = path.length; i-- > 0;) {
- fn(path[i], 'captured', arg);
- }
- for (i = 0; i < path.length; i++) {
- fn(path[i], 'bubbled', arg);
- }
- }
- function shouldPreventMouseEvent(name, type, props) {
- switch (name) {
- case 'onClick':
- case 'onClickCapture':
- case 'onDoubleClick':
- case 'onDoubleClickCapture':
- case 'onMouseDown':
- case 'onMouseDownCapture':
- case 'onMouseMove':
- case 'onMouseMoveCapture':
- case 'onMouseUp':
- case 'onMouseUpCapture':
- case 'onMouseEnter':
- return !!(props.disabled && isInteractive(type));
- default:
- return false;
- }
- }
-
- function getListener(inst, registrationName) {
-
-
- var stateNode = inst.stateNode;
- if (!stateNode) {
-
- return null;
- }
- var props = getFiberCurrentPropsFromNode(stateNode);
- if (!props) {
-
- return null;
- }
- var listener = props[registrationName];
- if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
- return null;
- }
- if (!(!listener || typeof listener === 'function')) {
- {
- throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." );
- }
- }
- return listener;
- }
- function listenerAtPhase(inst, event, propagationPhase) {
- var registrationName = event._reactName;
- if (propagationPhase === 'captured') {
- registrationName += 'Capture';
- }
- return getListener(inst, registrationName);
- }
- function accumulateDispatches(inst, ignoredDirection, event) {
- if (inst && event && event._reactName) {
- var registrationName = event._reactName;
- var listener = getListener(inst, registrationName);
- if (listener) {
- if (event._dispatchListeners == null) {
- event._dispatchListeners = [];
- }
- if (event._dispatchInstances == null) {
- event._dispatchInstances = [];
- }
- event._dispatchListeners.push(listener);
- event._dispatchInstances.push(inst);
- }
- }
- }
- function accumulateDirectionalDispatches(inst, phase, event) {
- {
- if (!inst) {
- error('Dispatching inst must not be null');
- }
- }
- var listener = listenerAtPhase(inst, event, phase);
- if (listener) {
- if (event._dispatchListeners == null) {
- event._dispatchListeners = [];
- }
- if (event._dispatchInstances == null) {
- event._dispatchInstances = [];
- }
- event._dispatchListeners.push(listener);
- event._dispatchInstances.push(inst);
- }
- }
- function accumulateDirectDispatchesSingle(event) {
- if (event && event._reactName) {
- accumulateDispatches(event._targetInst, null, event);
- }
- }
- function accumulateTwoPhaseDispatchesSingle(event) {
- if (event && event._reactName) {
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
- }
- }
- var Simulate = {};
- var directDispatchEventTypes = new Set(['mouseEnter', 'mouseLeave', 'pointerEnter', 'pointerLeave']);
-
- function makeSimulator(eventType) {
- return function (domNode, eventData) {
- if (!!React.isValidElement(domNode)) {
- {
- throw Error( "TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering." );
- }
- }
- if (!!isCompositeComponent(domNode)) {
- {
- throw Error( "TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead." );
- }
- }
- var reactName = 'on' + eventType[0].toUpperCase() + eventType.slice(1);
- var fakeNativeEvent = new Event();
- fakeNativeEvent.target = domNode;
- fakeNativeEvent.type = eventType.toLowerCase();
- var targetInst = getInstanceFromNode(domNode);
- var event = new SyntheticEvent(reactName, fakeNativeEvent.type, targetInst, fakeNativeEvent, domNode);
-
- event.persist();
- _assign(event, eventData);
- if (directDispatchEventTypes.has(eventType)) {
- accumulateDirectDispatchesSingle(event);
- } else {
- accumulateTwoPhaseDispatchesSingle(event);
- }
- ReactDOM.unstable_batchedUpdates(function () {
-
-
- enqueueStateRestore(domNode);
- executeDispatchesAndRelease(event);
- rethrowCaughtError();
- });
- restoreStateIfNeeded();
- };
- }
- var simulatedEventTypes = ['blur', 'cancel', 'click', 'close', 'contextMenu', 'copy', 'cut', 'auxClick', 'doubleClick', 'dragEnd', 'dragStart', 'drop', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'mouseDown', 'mouseUp', 'paste', 'pause', 'play', 'pointerCancel', 'pointerDown', 'pointerUp', 'rateChange', 'reset', 'seeked', 'submit', 'touchCancel', 'touchEnd', 'touchStart', 'volumeChange', 'drag', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'mouseMove', 'mouseOut', 'mouseOver', 'pointerMove', 'pointerOut', 'pointerOver', 'scroll', 'toggle', 'touchMove', 'wheel', 'abort', 'animationEnd', 'animationIteration', 'animationStart', 'canPlay', 'canPlayThrough', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'gotPointerCapture', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'lostPointerCapture', 'playing', 'progress', 'seeking', 'stalled', 'suspend', 'timeUpdate', 'transitionEnd', 'waiting', 'mouseEnter', 'mouseLeave', 'pointerEnter', 'pointerLeave', 'change', 'select', 'beforeInput', 'compositionEnd', 'compositionStart', 'compositionUpdate'];
- function buildSimulators() {
- simulatedEventTypes.forEach(function (eventType) {
- Simulate[eventType] = makeSimulator(eventType);
- });
- }
- buildSimulators();
- exports.Simulate = Simulate;
- exports.act = act;
- exports.findAllInRenderedTree = findAllInRenderedTree;
- exports.findRenderedComponentWithType = findRenderedComponentWithType;
- exports.findRenderedDOMComponentWithClass = findRenderedDOMComponentWithClass;
- exports.findRenderedDOMComponentWithTag = findRenderedDOMComponentWithTag;
- exports.isCompositeComponent = isCompositeComponent;
- exports.isCompositeComponentWithType = isCompositeComponentWithType;
- exports.isDOMComponent = isDOMComponent;
- exports.isDOMComponentElement = isDOMComponentElement;
- exports.isElement = isElement;
- exports.isElementOfType = isElementOfType;
- exports.mockComponent = mockComponent;
- exports.nativeTouchData = nativeTouchData;
- exports.renderIntoDocument = renderIntoDocument;
- exports.scryRenderedComponentsWithType = scryRenderedComponentsWithType;
- exports.scryRenderedDOMComponentsWithClass = scryRenderedDOMComponentsWithClass;
- exports.scryRenderedDOMComponentsWithTag = scryRenderedDOMComponentsWithTag;
- exports.traverseTwoPhase = traverseTwoPhase;
- exports.unstable_concurrentAct = unstable_concurrentAct;
- })));
|