tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

react-dom-test-utils-dev.mjs (48056B)


      1 /** @license React v16.8.6
      2 * react-dom-test-utils.development.js
      3 *
      4 * Copyright (c) Facebook, Inc. and its affiliates.
      5 *
      6 * This source code is licensed under the MIT license found in the
      7 * LICENSE file in the root directory of this source tree.
      8 */
      9 
     10 'use strict';
     11 
     12 import React from 'resource://devtools/client/shared/vendor/react.mjs';
     13 import ReactDOM from 'resource://devtools/client/shared/vendor/react-dom.mjs';
     14 
     15 var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
     16 
     17 var _assign = ReactInternals.assign;
     18 
     19 /**
     20 * Use invariant() to assert state which your program assumes to be true.
     21 *
     22 * Provide sprintf-style format (only %s is supported) and arguments
     23 * to provide information about what broke and what you were
     24 * expecting.
     25 *
     26 * The invariant message will be stripped in production, but the invariant
     27 * will remain to ensure logic does not differ in production.
     28 */
     29 
     30 var validateFormat = function () {};
     31 
     32 {
     33  validateFormat = function (format) {
     34    if (format === undefined) {
     35      throw new Error('invariant requires an error message argument');
     36    }
     37  };
     38 }
     39 
     40 function invariant(condition, format, a, b, c, d, e, f) {
     41  validateFormat(format);
     42 
     43  if (!condition) {
     44    var error = void 0;
     45    if (format === undefined) {
     46      error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
     47    } else {
     48      var args = [a, b, c, d, e, f];
     49      var argIndex = 0;
     50      error = new Error(format.replace(/%s/g, function () {
     51        return args[argIndex++];
     52      }));
     53      error.name = 'Invariant Violation';
     54    }
     55 
     56    error.framesToPop = 1; // we don't care about invariant's own frame
     57    throw error;
     58  }
     59 }
     60 
     61 // Relying on the `invariant()` implementation lets us
     62 // preserve the format and params in the www builds.
     63 
     64 /**
     65 * Similar to invariant but only logs a warning if the condition is not met.
     66 * This can be used to log issues in development environments in critical
     67 * paths. Removing the logging code for production environments will keep the
     68 * same logic and follow the same code paths.
     69 */
     70 
     71 var warningWithoutStack = function () {};
     72 
     73 {
     74  warningWithoutStack = function (condition, format) {
     75    for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
     76      args[_key - 2] = arguments[_key];
     77    }
     78 
     79    if (format === undefined) {
     80      throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
     81    }
     82    if (args.length > 8) {
     83      // Check before the condition to catch violations early.
     84      throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
     85    }
     86    if (condition) {
     87      return;
     88    }
     89    if (typeof console !== 'undefined') {
     90      var argsWithFormat = args.map(function (item) {
     91        return '' + item;
     92      });
     93      argsWithFormat.unshift('Warning: ' + format);
     94 
     95      // We intentionally don't use spread (or .apply) directly because it
     96      // breaks IE9: https://github.com/facebook/react/issues/13610
     97      Function.prototype.apply.call(console.error, console, argsWithFormat);
     98    }
     99    try {
    100      // --- Welcome to debugging React ---
    101      // This error was thrown as a convenience so that you can use this stack
    102      // to find the callsite that caused this warning to fire.
    103      var argIndex = 0;
    104      var message = 'Warning: ' + format.replace(/%s/g, function () {
    105        return args[argIndex++];
    106      });
    107      throw new Error(message);
    108    } catch (x) {}
    109  };
    110 }
    111 
    112 var warningWithoutStack$1 = warningWithoutStack;
    113 
    114 /**
    115 * `ReactInstanceMap` maintains a mapping from a public facing stateful
    116 * instance (key) and the internal representation (value). This allows public
    117 * methods to accept the user facing instance as an argument and map them back
    118 * to internal methods.
    119 *
    120 * Note that this module is currently shared and assumed to be stateless.
    121 * If this becomes an actual Map, that will break.
    122 */
    123 
    124 /**
    125 * This API should be called `delete` but we'd have to make sure to always
    126 * transform these to strings for IE support. When this transform is fully
    127 * supported we can rename it.
    128 */
    129 
    130 
    131 function get(key) {
    132  return key._reactInternalFiber;
    133 }
    134 
    135 var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    136 
    137 // Prevent newer renderers from RTE when used with older react package versions.
    138 // Current owner and dispatcher used to share the same ref,
    139 // but PR #14548 split them out to better support the react-debug-tools package.
    140 if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
    141  ReactSharedInternals.ReactCurrentDispatcher = {
    142    current: null
    143  };
    144 }
    145 
    146 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
    147 // nor polyfill, then a plain number is used for performance.
    148 
    149 var FunctionComponent = 0;
    150 var ClassComponent = 1;
    151 // Before we know whether it is function or class
    152 var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
    153 // A subtree. Could be an entry point to a different renderer.
    154 var HostComponent = 5;
    155 var HostText = 6;
    156 
    157 // Don't change these two values. They're used by React Dev Tools.
    158 var NoEffect = /*              */0;
    159 
    160 
    161 // You can change the rest (and add more).
    162 var Placement = /*             */2;
    163 
    164 
    165 
    166 
    167 
    168 
    169 
    170 
    171 
    172 
    173 // Passive & Update & Callback & Ref & Snapshot
    174 
    175 
    176 // Union of all host effects
    177 
    178 var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
    179 
    180 var MOUNTING = 1;
    181 var MOUNTED = 2;
    182 var UNMOUNTED = 3;
    183 
    184 function isFiberMountedImpl(fiber) {
    185  var node = fiber;
    186  if (!fiber.alternate) {
    187    // If there is no alternate, this might be a new tree that isn't inserted
    188    // yet. If it is, then it will have a pending insertion effect on it.
    189    if ((node.effectTag & Placement) !== NoEffect) {
    190      return MOUNTING;
    191    }
    192    while (node.return) {
    193      node = node.return;
    194      if ((node.effectTag & Placement) !== NoEffect) {
    195        return MOUNTING;
    196      }
    197    }
    198  } else {
    199    while (node.return) {
    200      node = node.return;
    201    }
    202  }
    203  if (node.tag === HostRoot) {
    204    // TODO: Check if this was a nested HostRoot when used with
    205    // renderContainerIntoSubtree.
    206    return MOUNTED;
    207  }
    208  // If we didn't hit the root, that means that we're in an disconnected tree
    209  // that has been unmounted.
    210  return UNMOUNTED;
    211 }
    212 
    213 
    214 
    215 
    216 
    217 function assertIsMounted(fiber) {
    218  !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    219 }
    220 
    221 function findCurrentFiberUsingSlowPath(fiber) {
    222  var alternate = fiber.alternate;
    223  if (!alternate) {
    224    // If there is no alternate, then we only need to check if it is mounted.
    225    var state = isFiberMountedImpl(fiber);
    226    !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    227    if (state === MOUNTING) {
    228      return null;
    229    }
    230    return fiber;
    231  }
    232  // If we have two possible branches, we'll walk backwards up to the root
    233  // to see what path the root points to. On the way we may hit one of the
    234  // special cases and we'll deal with them.
    235  var a = fiber;
    236  var b = alternate;
    237  while (true) {
    238    var parentA = a.return;
    239    var parentB = parentA ? parentA.alternate : null;
    240    if (!parentA || !parentB) {
    241      // We're at the root.
    242      break;
    243    }
    244 
    245    // If both copies of the parent fiber point to the same child, we can
    246    // assume that the child is current. This happens when we bailout on low
    247    // priority: the bailed out fiber's child reuses the current child.
    248    if (parentA.child === parentB.child) {
    249      var child = parentA.child;
    250      while (child) {
    251        if (child === a) {
    252          // We've determined that A is the current branch.
    253          assertIsMounted(parentA);
    254          return fiber;
    255        }
    256        if (child === b) {
    257          // We've determined that B is the current branch.
    258          assertIsMounted(parentA);
    259          return alternate;
    260        }
    261        child = child.sibling;
    262      }
    263      // We should never have an alternate for any mounting node. So the only
    264      // way this could possibly happen is if this was unmounted, if at all.
    265      invariant(false, 'Unable to find node on an unmounted component.');
    266    }
    267 
    268    if (a.return !== b.return) {
    269      // The return pointer of A and the return pointer of B point to different
    270      // fibers. We assume that return pointers never criss-cross, so A must
    271      // belong to the child set of A.return, and B must belong to the child
    272      // set of B.return.
    273      a = parentA;
    274      b = parentB;
    275    } else {
    276      // The return pointers point to the same fiber. We'll have to use the
    277      // default, slow path: scan the child sets of each parent alternate to see
    278      // which child belongs to which set.
    279      //
    280      // Search parent A's child set
    281      var didFindChild = false;
    282      var _child = parentA.child;
    283      while (_child) {
    284        if (_child === a) {
    285          didFindChild = true;
    286          a = parentA;
    287          b = parentB;
    288          break;
    289        }
    290        if (_child === b) {
    291          didFindChild = true;
    292          b = parentA;
    293          a = parentB;
    294          break;
    295        }
    296        _child = _child.sibling;
    297      }
    298      if (!didFindChild) {
    299        // Search parent B's child set
    300        _child = parentB.child;
    301        while (_child) {
    302          if (_child === a) {
    303            didFindChild = true;
    304            a = parentB;
    305            b = parentA;
    306            break;
    307          }
    308          if (_child === b) {
    309            didFindChild = true;
    310            b = parentB;
    311            a = parentA;
    312            break;
    313          }
    314          _child = _child.sibling;
    315        }
    316        !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
    317      }
    318    }
    319 
    320    !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
    321  }
    322  // If the root is not a host container, we're in a disconnected tree. I.e.
    323  // unmounted.
    324  !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
    325  if (a.stateNode.current === a) {
    326    // We've determined that A is the current branch.
    327    return fiber;
    328  }
    329  // Otherwise B has to be current branch.
    330  return alternate;
    331 }
    332 
    333 /* eslint valid-typeof: 0 */
    334 
    335 var EVENT_POOL_SIZE = 10;
    336 
    337 /**
    338 * @interface Event
    339 * @see http://www.w3.org/TR/DOM-Level-3-Events/
    340 */
    341 var EventInterface = {
    342  type: null,
    343  target: null,
    344  // currentTarget is set when dispatching; no use in copying it here
    345  currentTarget: function () {
    346    return null;
    347  },
    348  eventPhase: null,
    349  bubbles: null,
    350  cancelable: null,
    351  timeStamp: function (event) {
    352    return event.timeStamp || Date.now();
    353  },
    354  defaultPrevented: null,
    355  isTrusted: null
    356 };
    357 
    358 function functionThatReturnsTrue() {
    359  return true;
    360 }
    361 
    362 function functionThatReturnsFalse() {
    363  return false;
    364 }
    365 
    366 /**
    367 * Synthetic events are dispatched by event plugins, typically in response to a
    368 * top-level event delegation handler.
    369 *
    370 * These systems should generally use pooling to reduce the frequency of garbage
    371 * collection. The system should check `isPersistent` to determine whether the
    372 * event should be released into the pool after being dispatched. Users that
    373 * need a persisted event should invoke `persist`.
    374 *
    375 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
    376 * normalizing browser quirks. Subclasses do not necessarily have to implement a
    377 * DOM interface; custom application-specific events can also subclass this.
    378 *
    379 * @param {object} dispatchConfig Configuration used to dispatch this event.
    380 * @param {*} targetInst Marker identifying the event target.
    381 * @param {object} nativeEvent Native browser event.
    382 * @param {DOMEventTarget} nativeEventTarget Target node.
    383 */
    384 function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
    385  {
    386    // these have a getter/setter for warnings
    387    delete this.nativeEvent;
    388    delete this.preventDefault;
    389    delete this.stopPropagation;
    390    delete this.isDefaultPrevented;
    391    delete this.isPropagationStopped;
    392  }
    393 
    394  this.dispatchConfig = dispatchConfig;
    395  this._targetInst = targetInst;
    396  this.nativeEvent = nativeEvent;
    397 
    398  var Interface = this.constructor.Interface;
    399  for (var propName in Interface) {
    400    if (!Interface.hasOwnProperty(propName)) {
    401      continue;
    402    }
    403    {
    404      delete this[propName]; // this has a getter/setter for warnings
    405    }
    406    var normalize = Interface[propName];
    407    if (normalize) {
    408      this[propName] = normalize(nativeEvent);
    409    } else {
    410      if (propName === 'target') {
    411        this.target = nativeEventTarget;
    412      } else {
    413        this[propName] = nativeEvent[propName];
    414      }
    415    }
    416  }
    417 
    418  var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
    419  if (defaultPrevented) {
    420    this.isDefaultPrevented = functionThatReturnsTrue;
    421  } else {
    422    this.isDefaultPrevented = functionThatReturnsFalse;
    423  }
    424  this.isPropagationStopped = functionThatReturnsFalse;
    425  return this;
    426 }
    427 
    428 _assign(SyntheticEvent.prototype, {
    429  preventDefault: function () {
    430    this.defaultPrevented = true;
    431    var event = this.nativeEvent;
    432    if (!event) {
    433      return;
    434    }
    435 
    436    if (event.preventDefault) {
    437      event.preventDefault();
    438    } else if (typeof event.returnValue !== 'unknown') {
    439      event.returnValue = false;
    440    }
    441    this.isDefaultPrevented = functionThatReturnsTrue;
    442  },
    443 
    444  stopPropagation: function () {
    445    var event = this.nativeEvent;
    446    if (!event) {
    447      return;
    448    }
    449 
    450    if (event.stopPropagation) {
    451      event.stopPropagation();
    452    } else if (typeof event.cancelBubble !== 'unknown') {
    453      // The ChangeEventPlugin registers a "propertychange" event for
    454      // IE. This event does not support bubbling or cancelling, and
    455      // any references to cancelBubble throw "Member not found".  A
    456      // typeof check of "unknown" circumvents this issue (and is also
    457      // IE specific).
    458      event.cancelBubble = true;
    459    }
    460 
    461    this.isPropagationStopped = functionThatReturnsTrue;
    462  },
    463 
    464  /**
    465   * We release all dispatched `SyntheticEvent`s after each event loop, adding
    466   * them back into the pool. This allows a way to hold onto a reference that
    467   * won't be added back into the pool.
    468   */
    469  persist: function () {
    470    this.isPersistent = functionThatReturnsTrue;
    471  },
    472 
    473  /**
    474   * Checks if this event should be released back into the pool.
    475   *
    476   * @return {boolean} True if this should not be released, false otherwise.
    477   */
    478  isPersistent: functionThatReturnsFalse,
    479 
    480  /**
    481   * `PooledClass` looks for `destructor` on each instance it releases.
    482   */
    483  destructor: function () {
    484    var Interface = this.constructor.Interface;
    485    for (var propName in Interface) {
    486      {
    487        Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
    488      }
    489    }
    490    this.dispatchConfig = null;
    491    this._targetInst = null;
    492    this.nativeEvent = null;
    493    this.isDefaultPrevented = functionThatReturnsFalse;
    494    this.isPropagationStopped = functionThatReturnsFalse;
    495    this._dispatchListeners = null;
    496    this._dispatchInstances = null;
    497    {
    498      Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
    499      Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
    500      Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
    501      Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
    502      Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
    503    }
    504  }
    505 });
    506 
    507 SyntheticEvent.Interface = EventInterface;
    508 
    509 /**
    510 * Helper to reduce boilerplate when creating subclasses.
    511 */
    512 SyntheticEvent.extend = function (Interface) {
    513  var Super = this;
    514 
    515  var E = function () {};
    516  E.prototype = Super.prototype;
    517  var prototype = new E();
    518 
    519  function Class() {
    520    return Super.apply(this, arguments);
    521  }
    522  _assign(prototype, Class.prototype);
    523  Class.prototype = prototype;
    524  Class.prototype.constructor = Class;
    525 
    526  Class.Interface = _assign({}, Super.Interface, Interface);
    527  Class.extend = Super.extend;
    528  addEventPoolingTo(Class);
    529 
    530  return Class;
    531 };
    532 
    533 addEventPoolingTo(SyntheticEvent);
    534 
    535 /**
    536 * Helper to nullify syntheticEvent instance properties when destructing
    537 *
    538 * @param {String} propName
    539 * @param {?object} getVal
    540 * @return {object} defineProperty object
    541 */
    542 function getPooledWarningPropertyDefinition(propName, getVal) {
    543  var isFunction = typeof getVal === 'function';
    544  return {
    545    configurable: true,
    546    set: set,
    547    get: get
    548  };
    549 
    550  function set(val) {
    551    var action = isFunction ? 'setting the method' : 'setting the property';
    552    warn(action, 'This is effectively a no-op');
    553    return val;
    554  }
    555 
    556  function get() {
    557    var action = isFunction ? 'accessing the method' : 'accessing the property';
    558    var result = isFunction ? 'This is a no-op function' : 'This is set to null';
    559    warn(action, result);
    560    return getVal;
    561  }
    562 
    563  function warn(action, result) {
    564    var warningCondition = false;
    565    !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;
    566  }
    567 }
    568 
    569 function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
    570  var EventConstructor = this;
    571  if (EventConstructor.eventPool.length) {
    572    var instance = EventConstructor.eventPool.pop();
    573    EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
    574    return instance;
    575  }
    576  return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
    577 }
    578 
    579 function releasePooledEvent(event) {
    580  var EventConstructor = this;
    581  !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
    582  event.destructor();
    583  if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
    584    EventConstructor.eventPool.push(event);
    585  }
    586 }
    587 
    588 function addEventPoolingTo(EventConstructor) {
    589  EventConstructor.eventPool = [];
    590  EventConstructor.getPooled = getPooledEvent;
    591  EventConstructor.release = releasePooledEvent;
    592 }
    593 
    594 /**
    595 * Forked from fbjs/warning:
    596 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
    597 *
    598 * Only change is we use console.warn instead of console.error,
    599 * and do nothing when 'console' is not supported.
    600 * This really simplifies the code.
    601 * ---
    602 * Similar to invariant but only logs a warning if the condition is not met.
    603 * This can be used to log issues in development environments in critical
    604 * paths. Removing the logging code for production environments will keep the
    605 * same logic and follow the same code paths.
    606 */
    607 
    608 var lowPriorityWarning = function () {};
    609 
    610 {
    611  var printWarning = function (format) {
    612    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    613      args[_key - 1] = arguments[_key];
    614    }
    615 
    616    var argIndex = 0;
    617    var message = 'Warning: ' + format.replace(/%s/g, function () {
    618      return args[argIndex++];
    619    });
    620    if (typeof console !== 'undefined') {
    621      console.warn(message);
    622    }
    623    try {
    624      // --- Welcome to debugging React ---
    625      // This error was thrown as a convenience so that you can use this stack
    626      // to find the callsite that caused this warning to fire.
    627      throw new Error(message);
    628    } catch (x) {}
    629  };
    630 
    631  lowPriorityWarning = function (condition, format) {
    632    if (format === undefined) {
    633      throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
    634    }
    635    if (!condition) {
    636      for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
    637        args[_key2 - 2] = arguments[_key2];
    638      }
    639 
    640      printWarning.apply(undefined, [format].concat(args));
    641    }
    642  };
    643 }
    644 
    645 var lowPriorityWarning$1 = lowPriorityWarning;
    646 
    647 /**
    648 * HTML nodeType values that represent the type of the node
    649 */
    650 
    651 var ELEMENT_NODE = 1;
    652 
    653 // Do not uses the below two methods directly!
    654 // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
    655 // (It is the only module that is allowed to access these methods.)
    656 
    657 function unsafeCastStringToDOMTopLevelType(topLevelType) {
    658  return topLevelType;
    659 }
    660 
    661 var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
    662 
    663 /**
    664 * Generate a mapping of standard vendor prefixes using the defined style property and event name.
    665 *
    666 * @param {string} styleProp
    667 * @param {string} eventName
    668 * @returns {object}
    669 */
    670 function makePrefixMap(styleProp, eventName) {
    671  var prefixes = {};
    672 
    673  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
    674  prefixes['Webkit' + styleProp] = 'webkit' + eventName;
    675  prefixes['Moz' + styleProp] = 'moz' + eventName;
    676 
    677  return prefixes;
    678 }
    679 
    680 /**
    681 * A list of event names to a configurable list of vendor prefixes.
    682 */
    683 var vendorPrefixes = {
    684  animationend: makePrefixMap('Animation', 'AnimationEnd'),
    685  animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
    686  animationstart: makePrefixMap('Animation', 'AnimationStart'),
    687  transitionend: makePrefixMap('Transition', 'TransitionEnd')
    688 };
    689 
    690 /**
    691 * Event names that have already been detected and prefixed (if applicable).
    692 */
    693 var prefixedEventNames = {};
    694 
    695 /**
    696 * Element to check for prefixes on.
    697 */
    698 var style = {};
    699 
    700 /**
    701 * Bootstrap if a DOM exists.
    702 */
    703 if (canUseDOM) {
    704  style = document.createElementNS('http://www.w3.org/1999/xhtml', 'div').style;
    705 
    706  // On some platforms, in particular some releases of Android 4.x,
    707  // the un-prefixed "animation" and "transition" properties are defined on the
    708  // style object but the events that fire will still be prefixed, so we need
    709  // to check if the un-prefixed events are usable, and if not remove them from the map.
    710  if (!('AnimationEvent' in window)) {
    711    delete vendorPrefixes.animationend.animation;
    712    delete vendorPrefixes.animationiteration.animation;
    713    delete vendorPrefixes.animationstart.animation;
    714  }
    715 
    716  // Same as above
    717  if (!('TransitionEvent' in window)) {
    718    delete vendorPrefixes.transitionend.transition;
    719  }
    720 }
    721 
    722 /**
    723 * Attempts to determine the correct vendor prefixed event name.
    724 *
    725 * @param {string} eventName
    726 * @returns {string}
    727 */
    728 function getVendorPrefixedEventName(eventName) {
    729  if (prefixedEventNames[eventName]) {
    730    return prefixedEventNames[eventName];
    731  } else if (!vendorPrefixes[eventName]) {
    732    return eventName;
    733  }
    734 
    735  var prefixMap = vendorPrefixes[eventName];
    736 
    737  for (var styleProp in prefixMap) {
    738    if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
    739      return prefixedEventNames[eventName] = prefixMap[styleProp];
    740    }
    741  }
    742 
    743  return eventName;
    744 }
    745 
    746 /**
    747 * To identify top level events in ReactDOM, we use constants defined by this
    748 * module. This is the only module that uses the unsafe* methods to express
    749 * that the constants actually correspond to the browser event names. This lets
    750 * us save some bundle size by avoiding a top level type -> event name map.
    751 * The rest of ReactDOM code should import top level types from this file.
    752 */
    753 var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
    754 var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
    755 var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
    756 var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
    757 var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
    758 var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
    759 var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
    760 var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
    761 var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
    762 var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
    763 var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
    764 var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
    765 var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
    766 var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
    767 var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
    768 var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
    769 var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
    770 var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
    771 
    772 var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
    773 var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
    774 var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
    775 var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
    776 var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
    777 var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
    778 var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
    779 var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
    780 var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
    781 var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
    782 var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
    783 var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
    784 var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
    785 var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
    786 
    787 var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
    788 
    789 var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
    790 var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
    791 var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
    792 var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
    793 var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
    794 var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
    795 var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
    796 
    797 var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
    798 var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
    799 var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
    800 var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
    801 var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
    802 var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
    803 var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
    804 var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
    805 var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
    806 
    807 
    808 
    809 
    810 
    811 
    812 
    813 
    814 var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
    815 var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
    816 
    817 var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
    818 var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
    819 var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
    820 var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
    821 var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
    822 
    823 var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
    824 var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
    825 var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
    826 var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
    827 var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
    828 var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
    829 var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
    830 var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
    831 var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
    832 var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
    833 var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
    834 var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
    835 
    836 // List of events that need to be individually attached to media elements.
    837 // Note that events in this list will *not* be listened to at the top level
    838 // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
    839 
    840 // for .act's return value
    841 var findDOMNode = ReactDOM.findDOMNode;
    842 // Keep in sync with ReactDOMUnstableNativeDependencies.js
    843 // and ReactDOM.js:
    844 
    845 var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
    846 var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
    847 var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
    848 var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
    849 var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
    850 var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4];
    851 var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5];
    852 var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6];
    853 var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
    854 var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
    855 var dispatchEvent = _ReactDOM$__SECRET_IN[9];
    856 var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
    857 
    858 
    859 function Event(suffix) {}
    860 
    861 var hasWarnedAboutDeprecatedMockComponent = false;
    862 
    863 /**
    864 * @class ReactTestUtils
    865 */
    866 
    867 /**
    868 * Simulates a top level event being dispatched from a raw event that occurred
    869 * on an `Element` node.
    870 * @param {number} topLevelType A number from `TopLevelEventTypes`
    871 * @param {!Element} node The dom to simulate an event occurring on.
    872 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
    873 */
    874 function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
    875  fakeNativeEvent.target = node;
    876  dispatchEvent(topLevelType, fakeNativeEvent);
    877 }
    878 
    879 /**
    880 * Simulates a top level event being dispatched from a raw event that occurred
    881 * on the `ReactDOMComponent` `comp`.
    882 * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
    883 * @param {!ReactDOMComponent} comp
    884 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
    885 */
    886 function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
    887  simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
    888 }
    889 
    890 function findAllInRenderedFiberTreeInternal(fiber, test) {
    891  if (!fiber) {
    892    return [];
    893  }
    894  var currentParent = findCurrentFiberUsingSlowPath(fiber);
    895  if (!currentParent) {
    896    return [];
    897  }
    898  var node = currentParent;
    899  var ret = [];
    900  while (true) {
    901    if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
    902      var publicInst = node.stateNode;
    903      if (test(publicInst)) {
    904        ret.push(publicInst);
    905      }
    906    }
    907    if (node.child) {
    908      node.child.return = node;
    909      node = node.child;
    910      continue;
    911    }
    912    if (node === currentParent) {
    913      return ret;
    914    }
    915    while (!node.sibling) {
    916      if (!node.return || node.return === currentParent) {
    917        return ret;
    918      }
    919      node = node.return;
    920    }
    921    node.sibling.return = node.return;
    922    node = node.sibling;
    923  }
    924 }
    925 
    926 function validateClassInstance(inst, methodName) {
    927  if (!inst) {
    928    // This is probably too relaxed but it's existing behavior.
    929    return;
    930  }
    931  if (get(inst)) {
    932    // This is a public instance indeed.
    933    return;
    934  }
    935  var received = void 0;
    936  var stringified = '' + inst;
    937  if (Array.isArray(inst)) {
    938    received = 'an array';
    939  } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
    940    received = 'a DOM node';
    941  } else if (stringified === '[object Object]') {
    942    received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
    943  } else {
    944    received = stringified;
    945  }
    946  invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
    947 }
    948 
    949 // a stub element, lazily initialized, used by act() when flushing effects
    950 var actContainerElement = null;
    951 
    952 /**
    953 * Utilities for making it easy to test React components.
    954 *
    955 * See https://reactjs.org/docs/test-utils.html
    956 *
    957 * Todo: Support the entire DOM.scry query syntax. For now, these simple
    958 * utilities will suffice for testing purposes.
    959 * @lends ReactTestUtils
    960 */
    961 var ReactTestUtils = {
    962  renderIntoDocument: function (element) {
    963    var div = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
    964    // None of our tests actually require attaching the container to the
    965    // DOM, and doing so creates a mess that we rely on test isolation to
    966    // clean up, so we're going to stop honoring the name of this method
    967    // (and probably rename it eventually) if no problems arise.
    968    // document.documentElement.appendChild(div);
    969    return ReactDOM.render(element, div);
    970  },
    971 
    972  isElement: function (element) {
    973    return React.isValidElement(element);
    974  },
    975 
    976  isElementOfType: function (inst, convenienceConstructor) {
    977    return React.isValidElement(inst) && inst.type === convenienceConstructor;
    978  },
    979 
    980  isDOMComponent: function (inst) {
    981    return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
    982  },
    983 
    984  isDOMComponentElement: function (inst) {
    985    return !!(inst && React.isValidElement(inst) && !!inst.tagName);
    986  },
    987 
    988  isCompositeComponent: function (inst) {
    989    if (ReactTestUtils.isDOMComponent(inst)) {
    990      // Accessing inst.setState warns; just return false as that'll be what
    991      // this returns when we have DOM nodes as refs directly
    992      return false;
    993    }
    994    return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
    995  },
    996 
    997  isCompositeComponentWithType: function (inst, type) {
    998    if (!ReactTestUtils.isCompositeComponent(inst)) {
    999      return false;
   1000    }
   1001    var internalInstance = get(inst);
   1002    var constructor = internalInstance.type;
   1003    return constructor === type;
   1004  },
   1005 
   1006  findAllInRenderedTree: function (inst, test) {
   1007    validateClassInstance(inst, 'findAllInRenderedTree');
   1008    if (!inst) {
   1009      return [];
   1010    }
   1011    var internalInstance = get(inst);
   1012    return findAllInRenderedFiberTreeInternal(internalInstance, test);
   1013  },
   1014 
   1015  /**
   1016   * Finds all instance of components in the rendered tree that are DOM
   1017   * components with the class name matching `className`.
   1018   * @return {array} an array of all the matches.
   1019   */
   1020  scryRenderedDOMComponentsWithClass: function (root, classNames) {
   1021    validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
   1022    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1023      if (ReactTestUtils.isDOMComponent(inst)) {
   1024        var className = inst.className;
   1025        if (typeof className !== 'string') {
   1026          // SVG, probably.
   1027          className = inst.getAttribute('class') || '';
   1028        }
   1029        var classList = className.split(/\s+/);
   1030 
   1031        if (!Array.isArray(classNames)) {
   1032          !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
   1033          classNames = classNames.split(/\s+/);
   1034        }
   1035        return classNames.every(function (name) {
   1036          return classList.indexOf(name) !== -1;
   1037        });
   1038      }
   1039      return false;
   1040    });
   1041  },
   1042 
   1043  /**
   1044   * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
   1045   * and returns that one result, or throws exception if there is any other
   1046   * number of matches besides one.
   1047   * @return {!ReactDOMComponent} The one match.
   1048   */
   1049  findRenderedDOMComponentWithClass: function (root, className) {
   1050    validateClassInstance(root, 'findRenderedDOMComponentWithClass');
   1051    var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
   1052    if (all.length !== 1) {
   1053      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
   1054    }
   1055    return all[0];
   1056  },
   1057 
   1058  /**
   1059   * Finds all instance of components in the rendered tree that are DOM
   1060   * components with the tag name matching `tagName`.
   1061   * @return {array} an array of all the matches.
   1062   */
   1063  scryRenderedDOMComponentsWithTag: function (root, tagName) {
   1064    validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
   1065    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1066      return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
   1067    });
   1068  },
   1069 
   1070  /**
   1071   * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
   1072   * and returns that one result, or throws exception if there is any other
   1073   * number of matches besides one.
   1074   * @return {!ReactDOMComponent} The one match.
   1075   */
   1076  findRenderedDOMComponentWithTag: function (root, tagName) {
   1077    validateClassInstance(root, 'findRenderedDOMComponentWithTag');
   1078    var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
   1079    if (all.length !== 1) {
   1080      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
   1081    }
   1082    return all[0];
   1083  },
   1084 
   1085  /**
   1086   * Finds all instances of components with type equal to `componentType`.
   1087   * @return {array} an array of all the matches.
   1088   */
   1089  scryRenderedComponentsWithType: function (root, componentType) {
   1090    validateClassInstance(root, 'scryRenderedComponentsWithType');
   1091    return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
   1092      return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
   1093    });
   1094  },
   1095 
   1096  /**
   1097   * Same as `scryRenderedComponentsWithType` but expects there to be one result
   1098   * and returns that one result, or throws exception if there is any other
   1099   * number of matches besides one.
   1100   * @return {!ReactComponent} The one match.
   1101   */
   1102  findRenderedComponentWithType: function (root, componentType) {
   1103    validateClassInstance(root, 'findRenderedComponentWithType');
   1104    var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
   1105    if (all.length !== 1) {
   1106      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
   1107    }
   1108    return all[0];
   1109  },
   1110 
   1111  /**
   1112   * Pass a mocked component module to this method to augment it with
   1113   * useful methods that allow it to be used as a dummy React component.
   1114   * Instead of rendering as usual, the component will become a simple
   1115   * <div> containing any provided children.
   1116   *
   1117   * @param {object} module the mock function object exported from a
   1118   *                        module that defines the component to be mocked
   1119   * @param {?string} mockTagName optional dummy root tag name to return
   1120   *                              from render method (overrides
   1121   *                              module.mockTagName if provided)
   1122   * @return {object} the ReactTestUtils object (for chaining)
   1123   */
   1124  mockComponent: function (module, mockTagName) {
   1125    if (!hasWarnedAboutDeprecatedMockComponent) {
   1126      hasWarnedAboutDeprecatedMockComponent = true;
   1127      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.');
   1128    }
   1129 
   1130    mockTagName = mockTagName || module.mockTagName || 'div';
   1131 
   1132    module.prototype.render.mockImplementation(function () {
   1133      return React.createElement(mockTagName, null, this.props.children);
   1134    });
   1135 
   1136    return this;
   1137  },
   1138 
   1139  nativeTouchData: function (x, y) {
   1140    return {
   1141      touches: [{ pageX: x, pageY: y }]
   1142    };
   1143  },
   1144 
   1145  Simulate: null,
   1146  SimulateNative: {},
   1147 
   1148  act: function (callback) {
   1149    if (actContainerElement === null) {
   1150      // warn if we can't actually create the stub element
   1151      {
   1152        !(typeof document !== 'undefined' && document !== null && typeof document.createElement === 'function') ? warningWithoutStack$1(false, 'It looks like you called TestUtils.act(...) in a non-browser environment. ' + "If you're using TestRenderer for your tests, you should call " + 'TestRenderer.act(...) instead of TestUtils.act(...).') : void 0;
   1153      }
   1154      // then make it
   1155      actContainerElement = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
   1156    }
   1157 
   1158    var result = ReactDOM.unstable_batchedUpdates(callback);
   1159    // note: keep these warning messages in sync with
   1160    // createReactNoop.js and ReactTestRenderer.js
   1161    {
   1162      if (result !== undefined) {
   1163        var addendum = void 0;
   1164        if (result !== null && typeof result.then === 'function') {
   1165          addendum = '\n\nIt looks like you wrote ReactTestUtils.act(async () => ...), ' + 'or returned a Promise from the callback passed to it. ' + 'Putting asynchronous logic inside ReactTestUtils.act(...) is not supported.\n';
   1166        } else {
   1167          addendum = ' You returned: ' + result;
   1168        }
   1169        warningWithoutStack$1(false, 'The callback passed to ReactTestUtils.act(...) function must not return anything.%s', addendum);
   1170      }
   1171    }
   1172    ReactDOM.render(React.createElement('div', null), actContainerElement);
   1173    // we want the user to not expect a return,
   1174    // but we want to warn if they use it like they can await on it.
   1175    return {
   1176      then: function () {
   1177        {
   1178          warningWithoutStack$1(false, 'Do not await the result of calling ReactTestUtils.act(...), it is not a Promise.');
   1179        }
   1180      }
   1181    };
   1182  }
   1183 };
   1184 
   1185 /**
   1186 * Exports:
   1187 *
   1188 * - `ReactTestUtils.Simulate.click(Element)`
   1189 * - `ReactTestUtils.Simulate.mouseMove(Element)`
   1190 * - `ReactTestUtils.Simulate.change(Element)`
   1191 * - ... (All keys from event plugin `eventTypes` objects)
   1192 */
   1193 function makeSimulator(eventType) {
   1194  return function (domNode, eventData) {
   1195    !!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;
   1196    !!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;
   1197 
   1198    var dispatchConfig = eventNameDispatchConfigs[eventType];
   1199 
   1200    var fakeNativeEvent = new Event();
   1201    fakeNativeEvent.target = domNode;
   1202    fakeNativeEvent.type = eventType.toLowerCase();
   1203 
   1204    // We don't use SyntheticEvent.getPooled in order to not have to worry about
   1205    // properly destroying any properties assigned from `eventData` upon release
   1206    var targetInst = getInstanceFromNode(domNode);
   1207    var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
   1208 
   1209    // Since we aren't using pooling, always persist the event. This will make
   1210    // sure it's marked and won't warn when setting additional properties.
   1211    event.persist();
   1212    _assign(event, eventData);
   1213 
   1214    if (dispatchConfig.phasedRegistrationNames) {
   1215      accumulateTwoPhaseDispatches(event);
   1216    } else {
   1217      accumulateDirectDispatches(event);
   1218    }
   1219 
   1220    ReactDOM.unstable_batchedUpdates(function () {
   1221      // Normally extractEvent enqueues a state restore, but we'll just always
   1222      // do that since we're by-passing it here.
   1223      enqueueStateRestore(domNode);
   1224      runEventsInBatch(event);
   1225    });
   1226    restoreStateIfNeeded();
   1227  };
   1228 }
   1229 
   1230 function buildSimulators() {
   1231  ReactTestUtils.Simulate = {};
   1232 
   1233  var eventType = void 0;
   1234  for (eventType in eventNameDispatchConfigs) {
   1235    /**
   1236     * @param {!Element|ReactDOMComponent} domComponentOrNode
   1237     * @param {?object} eventData Fake event data to use in SyntheticEvent.
   1238     */
   1239    ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
   1240  }
   1241 }
   1242 
   1243 buildSimulators();
   1244 
   1245 /**
   1246 * Exports:
   1247 *
   1248 * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
   1249 * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
   1250 * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
   1251 * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
   1252 * - ... (All keys from `BrowserEventConstants.topLevelTypes`)
   1253 *
   1254 * Note: Top level event types are a subset of the entire set of handler types
   1255 * (which include a broader set of "synthetic" events). For example, onDragDone
   1256 * is a synthetic event. Except when testing an event plugin or React's event
   1257 * handling code specifically, you probably want to use ReactTestUtils.Simulate
   1258 * to dispatch synthetic events.
   1259 */
   1260 
   1261 function makeNativeSimulator(eventType, topLevelType) {
   1262  return function (domComponentOrNode, nativeEventData) {
   1263    var fakeNativeEvent = new Event(eventType);
   1264    _assign(fakeNativeEvent, nativeEventData);
   1265    if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
   1266      simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
   1267    } else if (domComponentOrNode.tagName) {
   1268      // Will allow on actual dom nodes.
   1269      simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
   1270    }
   1271  };
   1272 }
   1273 
   1274 [[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) {
   1275  var topLevelType = _ref[0],
   1276      eventType = _ref[1];
   1277 
   1278  /**
   1279   * @param {!Element|ReactDOMComponent} domComponentOrNode
   1280   * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
   1281   */
   1282  ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
   1283 });
   1284 
   1285 
   1286 
   1287 var ReactTestUtils$2 = ({
   1288 default: ReactTestUtils
   1289 });
   1290 
   1291 var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2;
   1292 
   1293 // TODO: decide on the top-level export form.
   1294 // This is hacky but makes it work with both Rollup and Jest.
   1295 var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
   1296 
   1297 export default testUtils;