aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react-dom/cjs/react-dom-test-utils.development.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/react-dom/cjs/react-dom-test-utils.development.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/react-dom/cjs/react-dom-test-utils.development.js')
-rw-r--r--node_modules/react-dom/cjs/react-dom-test-utils.development.js710
1 files changed, 469 insertions, 241 deletions
diff --git a/node_modules/react-dom/cjs/react-dom-test-utils.development.js b/node_modules/react-dom/cjs/react-dom-test-utils.development.js
index 7296e0eab..b34468c84 100644
--- a/node_modules/react-dom/cjs/react-dom-test-utils.development.js
+++ b/node_modules/react-dom/cjs/react-dom-test-utils.development.js
@@ -1,7 +1,7 @@
-/** @license React v16.2.0
+/** @license React v16.5.2
* react-dom-test-utils.development.js
*
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@@ -18,18 +18,141 @@ if (process.env.NODE_ENV !== "production") {
var _assign = require('object-assign');
var React = require('react');
var ReactDOM = require('react-dom');
-var invariant = require('fbjs/lib/invariant');
-var warning = require('fbjs/lib/warning');
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
/**
- * WARNING: DO NOT manually require this module.
- * This is a replacement for `invariant(...)` used by the error code system
- * and will _only_ be required by the corresponding babel pass.
- * It always throws.
+ * Use invariant() to assert state which your program assumes to be true.
+ *
+ * Provide sprintf-style format (only %s is supported) and arguments
+ * to provide information about what broke and what you were
+ * expecting.
+ *
+ * The invariant message will be stripped in production, but the invariant
+ * will remain to ensure logic does not differ in production.
+ */
+
+var validateFormat = function () {};
+
+{
+ validateFormat = function (format) {
+ if (format === undefined) {
+ throw new Error('invariant requires an error message argument');
+ }
+ };
+}
+
+function invariant(condition, format, a, b, c, d, e, f) {
+ validateFormat(format);
+
+ if (!condition) {
+ var error = void 0;
+ if (format === undefined) {
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
+ } else {
+ var args = [a, b, c, d, e, f];
+ var argIndex = 0;
+ error = new Error(format.replace(/%s/g, function () {
+ return args[argIndex++];
+ }));
+ error.name = 'Invariant Violation';
+ }
+
+ error.framesToPop = 1; // we don't care about invariant's own frame
+ throw error;
+ }
+}
+
+// Relying on the `invariant()` implementation lets us
+// preserve the format and params in the www builds.
+
+/**
+ * Similar to invariant but only logs a warning if the condition is not met.
+ * This can be used to log issues in development environments in critical
+ * paths. Removing the logging code for production environments will keep the
+ * same logic and follow the same code paths.
*/
+var warningWithoutStack = function () {};
+
+{
+ warningWithoutStack = function (condition, format) {
+ for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
+ args[_key - 2] = arguments[_key];
+ }
+
+ if (format === undefined) {
+ throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
+ }
+ if (args.length > 8) {
+ // Check before the condition to catch violations early.
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
+ }
+ if (condition) {
+ return;
+ }
+ if (typeof console !== 'undefined') {
+ var _args$map = args.map(function (item) {
+ return '' + item;
+ }),
+ a = _args$map[0],
+ b = _args$map[1],
+ c = _args$map[2],
+ d = _args$map[3],
+ e = _args$map[4],
+ f = _args$map[5],
+ g = _args$map[6],
+ h = _args$map[7];
+
+ var message = 'Warning: ' + format;
+
+ // We intentionally don't use spread (or .apply) because it breaks IE9:
+ // https://github.com/facebook/react/issues/13610
+ switch (args.length) {
+ case 0:
+ console.error(message);
+ break;
+ case 1:
+ console.error(message, a);
+ break;
+ case 2:
+ console.error(message, a, b);
+ break;
+ case 3:
+ console.error(message, a, b, c);
+ break;
+ case 4:
+ console.error(message, a, b, c, d);
+ break;
+ case 5:
+ console.error(message, a, b, c, d, e);
+ break;
+ case 6:
+ console.error(message, a, b, c, d, e, f);
+ break;
+ case 7:
+ console.error(message, a, b, c, d, e, f, g);
+ break;
+ case 8:
+ console.error(message, a, b, c, d, e, f, g, h);
+ break;
+ default:
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
+ }
+ }
+ try {
+ // --- Welcome to debugging React ---
+ // This error was thrown as a convenience so that you can use this stack
+ // to find the callsite that caused this warning to fire.
+ var argIndex = 0;
+ var _message = 'Warning: ' + format.replace(/%s/g, function () {
+ return args[argIndex++];
+ });
+ throw new Error(_message);
+ } catch (x) {}
+ };
+}
+
+var warningWithoutStack$1 = warningWithoutStack;
+
/**
* `ReactInstanceMap` maintains a mapping from a public facing stateful
* instance (key) and the internal representation (value). This allows public
@@ -51,32 +174,42 @@ function get(key) {
return key._reactInternalFiber;
}
-var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
+var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-var ReactCurrentOwner = ReactInternals.ReactCurrentOwner;
-var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
+// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
+// nor polyfill, then a plain number is used for performance.
-// Before we know whether it is functional or class
-var FunctionalComponent = 1;
+var FunctionalComponent = 0;
+var FunctionalComponentLazy = 1;
var ClassComponent = 2;
-var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
+var ClassComponentLazy = 3;
+ // Before we know whether it is functional or class
+var HostRoot = 5; // Root of a host tree. Could be nested inside another node.
// A subtree. Could be an entry point to a different renderer.
-var HostComponent = 5;
-var HostText = 6;
+var HostComponent = 7;
+var HostText = 8;
+
+// Don't change these two values. They're used by React Dev Tools.
+var NoEffect = /* */0;
-// Don't change these two values:
-var NoEffect = 0; // 0b00000000
- // 0b00000001
// You can change the rest (and add more).
-var Placement = 2; // 0b00000010
- // 0b00000100
- // 0b00000110
- // 0b00001000
- // 0b00010000
- // 0b00100000
- // 0b01000000
- // 0b10000000
+var Placement = /* */2;
+
+
+
+
+
+
+
+
+
+// Update & Callback & Ref & Snapshot
+
+
+// Union of all host effects
+
+var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
var MOUNTING = 1;
var MOUNTED = 2;
@@ -90,15 +223,15 @@ function isFiberMountedImpl(fiber) {
if ((node.effectTag & Placement) !== NoEffect) {
return MOUNTING;
}
- while (node['return']) {
- node = node['return'];
+ while (node.return) {
+ node = node.return;
if ((node.effectTag & Placement) !== NoEffect) {
return MOUNTING;
}
}
} else {
- while (node['return']) {
- node = node['return'];
+ while (node.return) {
+ node = node.return;
}
}
if (node.tag === HostRoot) {
@@ -136,7 +269,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
var a = fiber;
var b = alternate;
while (true) {
- var parentA = a['return'];
+ var parentA = a.return;
var parentB = parentA ? parentA.alternate : null;
if (!parentA || !parentB) {
// We're at the root.
@@ -166,7 +299,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
invariant(false, 'Unable to find node on an unmounted component.');
}
- if (a['return'] !== b['return']) {
+ if (a.return !== b.return) {
// The return pointer of A and the return pointer of B point to different
// fibers. We assume that return pointers never criss-cross, so A must
// belong to the child set of A.return, and B must belong to the child
@@ -233,12 +366,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
/* eslint valid-typeof: 0 */
-var didWarnForAddedNewProperty = false;
-var isProxySupported = typeof Proxy === 'function';
var EVENT_POOL_SIZE = 10;
-var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
-
/**
* @interface Event
* @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -247,7 +376,9 @@ var EventInterface = {
type: null,
target: null,
// currentTarget is set when dispatching; no use in copying it here
- currentTarget: emptyFunction.thatReturnsNull,
+ currentTarget: function () {
+ return null;
+ },
eventPhase: null,
bubbles: null,
cancelable: null,
@@ -258,6 +389,14 @@ var EventInterface = {
isTrusted: null
};
+function functionThatReturnsTrue() {
+ return true;
+}
+
+function functionThatReturnsFalse() {
+ return false;
+}
+
/**
* Synthetic events are dispatched by event plugins, typically in response to a
* top-level event delegation handler.
@@ -282,6 +421,8 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
delete this.nativeEvent;
delete this.preventDefault;
delete this.stopPropagation;
+ delete this.isDefaultPrevented;
+ delete this.isPropagationStopped;
}
this.dispatchConfig = dispatchConfig;
@@ -310,11 +451,11 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
if (defaultPrevented) {
- this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
+ this.isDefaultPrevented = functionThatReturnsTrue;
} else {
- this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
+ this.isDefaultPrevented = functionThatReturnsFalse;
}
- this.isPropagationStopped = emptyFunction.thatReturnsFalse;
+ this.isPropagationStopped = functionThatReturnsFalse;
return this;
}
@@ -331,7 +472,7 @@ _assign(SyntheticEvent.prototype, {
} else if (typeof event.returnValue !== 'unknown') {
event.returnValue = false;
}
- this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
+ this.isDefaultPrevented = functionThatReturnsTrue;
},
stopPropagation: function () {
@@ -351,7 +492,7 @@ _assign(SyntheticEvent.prototype, {
event.cancelBubble = true;
}
- this.isPropagationStopped = emptyFunction.thatReturnsTrue;
+ this.isPropagationStopped = functionThatReturnsTrue;
},
/**
@@ -360,7 +501,7 @@ _assign(SyntheticEvent.prototype, {
* won't be added back into the pool.
*/
persist: function () {
- this.isPersistent = emptyFunction.thatReturnsTrue;
+ this.isPersistent = functionThatReturnsTrue;
},
/**
@@ -368,7 +509,7 @@ _assign(SyntheticEvent.prototype, {
*
* @return {boolean} True if this should not be released, false otherwise.
*/
- isPersistent: emptyFunction.thatReturnsFalse,
+ isPersistent: functionThatReturnsFalse,
/**
* `PooledClass` looks for `destructor` on each instance it releases.
@@ -380,13 +521,19 @@ _assign(SyntheticEvent.prototype, {
Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
}
}
- for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
- this[shouldBeReleasedProperties[i]] = null;
- }
+ this.dispatchConfig = null;
+ this._targetInst = null;
+ this.nativeEvent = null;
+ this.isDefaultPrevented = functionThatReturnsFalse;
+ this.isPropagationStopped = functionThatReturnsFalse;
+ this._dispatchListeners = null;
+ this._dispatchInstances = null;
{
Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction));
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction));
+ Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
+ Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
}
}
});
@@ -395,53 +542,27 @@ SyntheticEvent.Interface = EventInterface;
/**
* Helper to reduce boilerplate when creating subclasses.
- *
- * @param {function} Class
- * @param {?object} Interface
*/
-SyntheticEvent.augmentClass = function (Class, Interface) {
+SyntheticEvent.extend = function (Interface) {
var Super = this;
var E = function () {};
E.prototype = Super.prototype;
var prototype = new E();
+ function Class() {
+ return Super.apply(this, arguments);
+ }
_assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
Class.Interface = _assign({}, Super.Interface, Interface);
- Class.augmentClass = Super.augmentClass;
+ Class.extend = Super.extend;
addEventPoolingTo(Class);
-};
-/** Proxying after everything set on SyntheticEvent
- * to resolve Proxy issue on some WebKit browsers
- * in which some Event properties are set to undefined (GH#10010)
- */
-{
- if (isProxySupported) {
- /*eslint-disable no-func-assign */
- SyntheticEvent = new Proxy(SyntheticEvent, {
- construct: function (target, args) {
- return this.apply(target, Object.create(target.prototype), args);
- },
- apply: function (constructor, that, args) {
- return new Proxy(constructor.apply(that, args), {
- set: function (target, prop, value) {
- if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
- warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.');
- didWarnForAddedNewProperty = true;
- }
- target[prop] = value;
- return true;
- }
- });
- }
- });
- /*eslint-enable no-func-assign */
- }
-}
+ return Class;
+};
addEventPoolingTo(SyntheticEvent);
@@ -475,7 +596,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
function warn(action, result) {
var warningCondition = false;
- warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result);
+ !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
}
}
@@ -491,7 +612,7 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
function releasePooledEvent(event) {
var EventConstructor = this;
- !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
+ !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
event.destructor();
if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
EventConstructor.eventPool.push(event);
@@ -504,7 +625,74 @@ function addEventPoolingTo(EventConstructor) {
EventConstructor.release = releasePooledEvent;
}
-var SyntheticEvent$1 = SyntheticEvent;
+/**
+ * Forked from fbjs/warning:
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
+ *
+ * Only change is we use console.warn instead of console.error,
+ * and do nothing when 'console' is not supported.
+ * This really simplifies the code.
+ * ---
+ * Similar to invariant but only logs a warning if the condition is not met.
+ * This can be used to log issues in development environments in critical
+ * paths. Removing the logging code for production environments will keep the
+ * same logic and follow the same code paths.
+ */
+
+var lowPriorityWarning = function () {};
+
+{
+ var printWarning = function (format) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ var argIndex = 0;
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
+ return args[argIndex++];
+ });
+ if (typeof console !== 'undefined') {
+ console.warn(message);
+ }
+ try {
+ // --- Welcome to debugging React ---
+ // This error was thrown as a convenience so that you can use this stack
+ // to find the callsite that caused this warning to fire.
+ throw new Error(message);
+ } catch (x) {}
+ };
+
+ lowPriorityWarning = function (condition, format) {
+ if (format === undefined) {
+ throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
+ }
+ if (!condition) {
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
+ args[_key2 - 2] = arguments[_key2];
+ }
+
+ printWarning.apply(undefined, [format].concat(args));
+ }
+ };
+}
+
+var lowPriorityWarning$1 = lowPriorityWarning;
+
+/**
+ * HTML nodeType values that represent the type of the node
+ */
+
+var ELEMENT_NODE = 1;
+
+// Do not uses the below two methods directly!
+// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
+// (It is the only module that is allowed to access these methods.)
+
+function unsafeCastStringToDOMTopLevelType(topLevelType) {
+ return topLevelType;
+}
+
+var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
/**
* Generate a mapping of standard vendor prefixes using the defined style property and event name.
@@ -519,8 +707,6 @@ function makePrefixMap(styleProp, eventName) {
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
prefixes['Webkit' + styleProp] = 'webkit' + eventName;
prefixes['Moz' + styleProp] = 'moz' + eventName;
- prefixes['ms' + styleProp] = 'MS' + eventName;
- prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
return prefixes;
}
@@ -548,7 +734,7 @@ var style = {};
/**
* Bootstrap if a DOM exists.
*/
-if (ExecutionEnvironment.canUseDOM) {
+if (canUseDOM) {
style = document.createElement('div').style;
// On some platforms, in particular some releases of Android 4.x,
@@ -588,109 +774,152 @@ function getVendorPrefixedEventName(eventName) {
}
}
- return '';
+ return eventName;
}
/**
- * Types of raw signals from the browser caught at the top level.
- *
- * For events like 'submit' which don't consistently bubble (which we
- * trap at a lower node than `document`), binding at `document` would
- * cause duplicate events so we don't include them here.
+ * To identify top level events in ReactDOM, we use constants defined by this
+ * module. This is the only module that uses the unsafe* methods to express
+ * that the constants actually correspond to the browser event names. This lets
+ * us save some bundle size by avoiding a top level type -> event name map.
+ * The rest of ReactDOM code should import top level types from this file.
*/
-var topLevelTypes$1 = {
- topAbort: 'abort',
- topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend',
- topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration',
- topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart',
- topBlur: 'blur',
- topCancel: 'cancel',
- topCanPlay: 'canplay',
- topCanPlayThrough: 'canplaythrough',
- topChange: 'change',
- topClick: 'click',
- topClose: 'close',
- topCompositionEnd: 'compositionend',
- topCompositionStart: 'compositionstart',
- topCompositionUpdate: 'compositionupdate',
- topContextMenu: 'contextmenu',
- topCopy: 'copy',
- topCut: 'cut',
- topDoubleClick: 'dblclick',
- topDrag: 'drag',
- topDragEnd: 'dragend',
- topDragEnter: 'dragenter',
- topDragExit: 'dragexit',
- topDragLeave: 'dragleave',
- topDragOver: 'dragover',
- topDragStart: 'dragstart',
- topDrop: 'drop',
- topDurationChange: 'durationchange',
- topEmptied: 'emptied',
- topEncrypted: 'encrypted',
- topEnded: 'ended',
- topError: 'error',
- topFocus: 'focus',
- topInput: 'input',
- topKeyDown: 'keydown',
- topKeyPress: 'keypress',
- topKeyUp: 'keyup',
- topLoadedData: 'loadeddata',
- topLoad: 'load',
- topLoadedMetadata: 'loadedmetadata',
- topLoadStart: 'loadstart',
- topMouseDown: 'mousedown',
- topMouseMove: 'mousemove',
- topMouseOut: 'mouseout',
- topMouseOver: 'mouseover',
- topMouseUp: 'mouseup',
- topPaste: 'paste',
- topPause: 'pause',
- topPlay: 'play',
- topPlaying: 'playing',
- topProgress: 'progress',
- topRateChange: 'ratechange',
- topScroll: 'scroll',
- topSeeked: 'seeked',
- topSeeking: 'seeking',
- topSelectionChange: 'selectionchange',
- topStalled: 'stalled',
- topSuspend: 'suspend',
- topTextInput: 'textInput',
- topTimeUpdate: 'timeupdate',
- topToggle: 'toggle',
- topTouchCancel: 'touchcancel',
- topTouchEnd: 'touchend',
- topTouchMove: 'touchmove',
- topTouchStart: 'touchstart',
- topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend',
- topVolumeChange: 'volumechange',
- topWaiting: 'waiting',
- topWheel: 'wheel'
-};
-
-var BrowserEventConstants = {
- topLevelTypes: topLevelTypes$1
-};
+var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
+var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
+var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
+var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
+var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
+var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
+var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
+var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
+var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
+var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
+var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
+var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
+var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
+var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
+var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
+var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
+var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
+var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
+
+var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
+var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
+var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
+var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
+var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
+var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
+var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
+var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
+var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
+var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
+var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
+var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
+var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
+var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
+
+var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
+
+var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
+var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
+var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
+var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
+var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
+var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
+var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
+
+var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
+var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
+var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
+var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
+var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
+var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
+var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
+var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
+var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
+
+
+
+
+
+
+
+
+var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
+var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
+
+var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
+var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
+var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
+var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
+var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
+
+var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
+var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
+var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
+var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
+var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
+var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
+var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
+var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
+var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
+var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
+var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
+var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
+
+// List of events that need to be individually attached to media elements.
+// Note that events in this list will *not* be listened to at the top level
+// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
var findDOMNode = ReactDOM.findDOMNode;
-var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-var EventPluginHub = _ReactDOM$__SECRET_IN.EventPluginHub;
-var EventPluginRegistry = _ReactDOM$__SECRET_IN.EventPluginRegistry;
-var EventPropagators = _ReactDOM$__SECRET_IN.EventPropagators;
-var ReactControlledComponent = _ReactDOM$__SECRET_IN.ReactControlledComponent;
-var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree;
-var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener;
+// Keep in sync with ReactDOMUnstableNativeDependencies.js
+// and ReactDOM.js:
+
+var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
+var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
+var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
+var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
+var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
+var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4];
+var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5];
+var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6];
+var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
+var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
+var dispatchEvent = _ReactDOM$__SECRET_IN[9];
+var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
-var topLevelTypes = BrowserEventConstants.topLevelTypes;
-
function Event(suffix) {}
+var hasWarnedAboutDeprecatedMockComponent = false;
+
/**
* @class ReactTestUtils
*/
+/**
+ * Simulates a top level event being dispatched from a raw event that occurred
+ * on an `Element` node.
+ * @param {number} topLevelType A number from `TopLevelEventTypes`
+ * @param {!Element} node The dom to simulate an event occurring on.
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
+ */
+function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
+ fakeNativeEvent.target = node;
+ dispatchEvent(topLevelType, fakeNativeEvent);
+}
+
+/**
+ * Simulates a top level event being dispatched from a raw event that occurred
+ * on the `ReactDOMComponent` `comp`.
+ * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
+ * @param {!ReactDOMComponent} comp
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
+ */
+function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
+ simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
+}
+
function findAllInRenderedFiberTreeInternal(fiber, test) {
if (!fiber) {
return [];
@@ -702,14 +931,14 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
var node = currentParent;
var ret = [];
while (true) {
- if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionalComponent) {
+ if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === ClassComponentLazy || node.tag === FunctionalComponent || node.tag === FunctionalComponentLazy) {
var publicInst = node.stateNode;
if (test(publicInst)) {
ret.push(publicInst);
}
}
if (node.child) {
- node.child['return'] = node;
+ node.child.return = node;
node = node.child;
continue;
}
@@ -717,16 +946,39 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
return ret;
}
while (!node.sibling) {
- if (!node['return'] || node['return'] === currentParent) {
+ if (!node.return || node.return === currentParent) {
return ret;
}
- node = node['return'];
+ node = node.return;
}
- node.sibling['return'] = node['return'];
+ node.sibling.return = node.return;
node = node.sibling;
}
}
+function validateClassInstance(inst, methodName) {
+ if (!inst) {
+ // This is probably too relaxed but it's existing behavior.
+ return;
+ }
+ if (get(inst)) {
+ // This is a public instance indeed.
+ return;
+ }
+ var received = void 0;
+ 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;
+ }
+ invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
+}
+
/**
* Utilities for making it easy to test React components.
*
@@ -756,7 +1008,7 @@ var ReactTestUtils = {
},
isDOMComponent: function (inst) {
- return !!(inst && inst.nodeType === 1 && inst.tagName);
+ return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
},
isDOMComponentElement: function (inst) {
@@ -782,10 +1034,10 @@ var ReactTestUtils = {
},
findAllInRenderedTree: function (inst, test) {
+ validateClassInstance(inst, 'findAllInRenderedTree');
if (!inst) {
return [];
}
- !ReactTestUtils.isCompositeComponent(inst) ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : void 0;
var internalInstance = get(inst);
return findAllInRenderedFiberTreeInternal(internalInstance, test);
},
@@ -796,6 +1048,7 @@ var ReactTestUtils = {
* @return {array} an array of all the matches.
*/
scryRenderedDOMComponentsWithClass: function (root, classNames) {
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
if (ReactTestUtils.isDOMComponent(inst)) {
var className = inst.className;
@@ -824,6 +1077,7 @@ var ReactTestUtils = {
* @return {!ReactDOMComponent} The one match.
*/
findRenderedDOMComponentWithClass: function (root, className) {
+ validateClassInstance(root, 'findRenderedDOMComponentWithClass');
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
@@ -837,6 +1091,7 @@ var ReactTestUtils = {
* @return {array} an array of all the matches.
*/
scryRenderedDOMComponentsWithTag: function (root, tagName) {
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
@@ -849,6 +1104,7 @@ var ReactTestUtils = {
* @return {!ReactDOMComponent} The one match.
*/
findRenderedDOMComponentWithTag: function (root, tagName) {
+ validateClassInstance(root, 'findRenderedDOMComponentWithTag');
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
@@ -861,6 +1117,7 @@ var ReactTestUtils = {
* @return {array} an array of all the matches.
*/
scryRenderedComponentsWithType: function (root, componentType) {
+ validateClassInstance(root, 'scryRenderedComponentsWithType');
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
@@ -873,6 +1130,7 @@ var ReactTestUtils = {
* @return {!ReactComponent} The one match.
*/
findRenderedComponentWithType: function (root, componentType) {
+ validateClassInstance(root, 'findRenderedComponentWithType');
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
@@ -894,6 +1152,11 @@ var ReactTestUtils = {
* @return {object} the ReactTestUtils object (for chaining)
*/
mockComponent: function (module, mockTagName) {
+ if (!hasWarnedAboutDeprecatedMockComponent) {
+ hasWarnedAboutDeprecatedMockComponent = true;
+ lowPriorityWarning$1(false, 'ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://fb.me/test-utils-mock-component for more information.');
+ }
+
mockTagName = mockTagName || module.mockTagName || 'div';
module.prototype.render.mockImplementation(function () {
@@ -903,29 +1166,6 @@ var ReactTestUtils = {
return this;
},
- /**
- * Simulates a top level event being dispatched from a raw event that occurred
- * on an `Element` node.
- * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`
- * @param {!Element} node The dom to simulate an event occurring on.
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
- */
- simulateNativeEventOnNode: function (topLevelType, node, fakeNativeEvent) {
- fakeNativeEvent.target = node;
- ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
- },
-
- /**
- * Simulates a top level event being dispatched from a raw event that occurred
- * on the `ReactDOMComponent` `comp`.
- * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
- * @param {!ReactDOMComponent} comp
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
- */
- simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
- ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
- },
-
nativeTouchData: function (x, y) {
return {
touches: [{ pageX: x, pageY: y }]
@@ -949,7 +1189,7 @@ function makeSimulator(eventType) {
!!React.isValidElement(domNode) ? invariant(false, '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.') : void 0;
!!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, '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.') : void 0;
- var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType];
+ var dispatchConfig = eventNameDispatchConfigs[eventType];
var fakeNativeEvent = new Event();
fakeNativeEvent.target = domNode;
@@ -957,8 +1197,8 @@ function makeSimulator(eventType) {
// We don't use SyntheticEvent.getPooled in order to not have to worry about
// properly destroying any properties assigned from `eventData` upon release
- var targetInst = ReactDOMComponentTree.getInstanceFromNode(domNode);
- var event = new SyntheticEvent$1(dispatchConfig, targetInst, fakeNativeEvent, domNode);
+ var targetInst = getInstanceFromNode(domNode);
+ var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
// Since we aren't using pooling, always persist the event. This will make
// sure it's marked and won't warn when setting additional properties.
@@ -966,27 +1206,26 @@ function makeSimulator(eventType) {
_assign(event, eventData);
if (dispatchConfig.phasedRegistrationNames) {
- EventPropagators.accumulateTwoPhaseDispatches(event);
+ accumulateTwoPhaseDispatches(event);
} else {
- EventPropagators.accumulateDirectDispatches(event);
+ accumulateDirectDispatches(event);
}
ReactDOM.unstable_batchedUpdates(function () {
// Normally extractEvent enqueues a state restore, but we'll just always
// do that since we we're by-passing it here.
- ReactControlledComponent.enqueueStateRestore(domNode);
-
- EventPluginHub.enqueueEvents(event);
- EventPluginHub.processEventQueue(true);
+ enqueueStateRestore(domNode);
+ runEventsInBatch(event, true);
});
+ restoreStateIfNeeded();
};
}
function buildSimulators() {
ReactTestUtils.Simulate = {};
- var eventType;
- for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
+ var eventType = void 0;
+ for (eventType in eventNameDispatchConfigs) {
/**
* @param {!Element|ReactDOMComponent} domComponentOrNode
* @param {?object} eventData Fake event data to use in SyntheticEvent.
@@ -995,18 +1234,6 @@ function buildSimulators() {
}
}
-// Rebuild ReactTestUtils.Simulate whenever event plugins are injected
-var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
-EventPluginHub.injection.injectEventPluginOrder = function () {
- oldInjectEventPluginOrder.apply(this, arguments);
- buildSimulators();
-};
-var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
-EventPluginHub.injection.injectEventPluginsByName = function () {
- oldInjectEventPlugins.apply(this, arguments);
- buildSimulators();
-};
-
buildSimulators();
/**
@@ -1025,27 +1252,28 @@ buildSimulators();
* to dispatch synthetic events.
*/
-function makeNativeSimulator(eventType) {
+function makeNativeSimulator(eventType, topLevelType) {
return function (domComponentOrNode, nativeEventData) {
var fakeNativeEvent = new Event(eventType);
_assign(fakeNativeEvent, nativeEventData);
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
- ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
+ simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
} else if (domComponentOrNode.tagName) {
// Will allow on actual dom nodes.
- ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
+ simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
}
};
}
-Object.keys(topLevelTypes).forEach(function (eventType) {
- // Event type is stored as 'topClick' - we transform that to 'click'
- var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
+[[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
+ var topLevelType = _ref[0],
+ eventType = _ref[1];
+
/**
* @param {!Element|ReactDOMComponent} domComponentOrNode
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
*/
- ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
+ ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
});
@@ -1058,7 +1286,7 @@ var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$
// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest.
-var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3;
+var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
module.exports = testUtils;
})();