aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js')
-rw-r--r--node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js1250
1 files changed, 302 insertions, 948 deletions
diff --git a/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js b/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js
index 15ca1332a..d14970bf8 100644
--- a/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js
+++ b/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js
@@ -1,4 +1,4 @@
-/** @license React v16.0.0
+/** @license React v16.2.0
* react-dom-unstable-native-dependencies.development.js
*
* Copyright (c) 2013-present, Facebook, Inc.
@@ -7,20 +7,19 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-dom')) :
- typeof define === 'function' && define.amd ? define(['react-dom'], factory) :
- (global.ReactDOMUnstableNativeDependencies = factory(global.ReactDOM));
-}(this, (function (reactDom) { 'use strict';
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-dom'), require('react')) :
+ typeof define === 'function' && define.amd ? define(['react-dom', 'react'], factory) :
+ (global.ReactDOMUnstableNativeDependencies = factory(global.ReactDOM,global.React));
+}(this, (function (ReactDOM,React) { 'use strict';
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule reactProdInvariant
- *
+ * 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.
*/
/**
@@ -31,6 +30,8 @@
*
*/
+
+
/**
* Use invariant() to assert state which your program assumes to be true.
*
@@ -75,96 +76,6 @@ function invariant(condition, format, a, b, c, d, e, f) {
var invariant_1 = invariant;
-var ReactErrorUtils = {
- // Used by Fiber to simulate a try-catch.
- _caughtError: null,
- _hasCaughtError: false,
-
- // Used by event system to capture/rethrow the first error.
- _rethrowError: null,
- _hasRethrowError: false,
-
- injection: {
- injectErrorUtils: function (injectedErrorUtils) {
- !(typeof injectedErrorUtils.invokeGuardedCallback === 'function') ? invariant_1(false, 'Injected invokeGuardedCallback() must be a function.') : void 0;
- invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback;
- }
- },
-
- /**
- * Call a function while guarding against errors that happens within it.
- * Returns an error if it throws, otherwise null.
- *
- * In production, this is implemented using a try-catch. The reason we don't
- * use a try-catch directly is so that we can swap out a different
- * implementation in DEV mode.
- *
- * @param {String} name of the guard to use for logging or debugging
- * @param {Function} func The function to invoke
- * @param {*} context The context to use when calling the function
- * @param {...*} args Arguments for function
- */
- invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) {
- invokeGuardedCallback.apply(ReactErrorUtils, arguments);
- },
-
- /**
- * Same as invokeGuardedCallback, but instead of returning an error, it stores
- * it in a global so it can be rethrown by `rethrowCaughtError` later.
- * TODO: See if _caughtError and _rethrowError can be unified.
- *
- * @param {String} name of the guard to use for logging or debugging
- * @param {Function} func The function to invoke
- * @param {*} context The context to use when calling the function
- * @param {...*} args Arguments for function
- */
- invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) {
- ReactErrorUtils.invokeGuardedCallback.apply(this, arguments);
- if (ReactErrorUtils.hasCaughtError()) {
- var error = ReactErrorUtils.clearCaughtError();
- if (!ReactErrorUtils._hasRethrowError) {
- ReactErrorUtils._hasRethrowError = true;
- ReactErrorUtils._rethrowError = error;
- }
- }
- },
-
- /**
- * During execution of guarded functions we will capture the first error which
- * we will rethrow to be handled by the top level error handler.
- */
- rethrowCaughtError: function () {
- return rethrowCaughtError.apply(ReactErrorUtils, arguments);
- },
-
- hasCaughtError: function () {
- return ReactErrorUtils._hasCaughtError;
- },
-
- clearCaughtError: function () {
- if (ReactErrorUtils._hasCaughtError) {
- var error = ReactErrorUtils._caughtError;
- ReactErrorUtils._caughtError = null;
- ReactErrorUtils._hasCaughtError = false;
- return error;
- } else {
- invariant_1(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.');
- }
- }
-};
-
-var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) {
- ReactErrorUtils._hasCaughtError = false;
- ReactErrorUtils._caughtError = null;
- var funcArgs = Array.prototype.slice.call(arguments, 3);
- try {
- func.apply(context, funcArgs);
- } catch (error) {
- ReactErrorUtils._caughtError = error;
- ReactErrorUtils._hasCaughtError = true;
- }
-};
-
{
// In DEV mode, we swap out invokeGuardedCallback for a special version
// that plays more nicely with the browser's DevTools. The idea is to preserve
@@ -190,99 +101,10 @@ var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) {
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
var fakeNode = document.createElement('react');
- var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
- // Keeps track of whether the user-provided callback threw an error. We
- // set this to true at the beginning, then set it to false right after
- // calling the function. If the function errors, `didError` will never be
- // set to false. This strategy works even if the browser is flaky and
- // fails to call our global error handler, because it doesn't rely on
- // the error event at all.
- var didError = true;
-
- // Create an event handler for our fake event. We will synchronously
- // dispatch our fake event using `dispatchEvent`. Inside the handler, we
- // call the user-provided callback.
- var funcArgs = Array.prototype.slice.call(arguments, 3);
- function callCallback() {
- // We immediately remove the callback from event listeners so that
- // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
- // nested call would trigger the fake event handlers of any call higher
- // in the stack.
- fakeNode.removeEventListener(evtType, callCallback, false);
- func.apply(context, funcArgs);
- didError = false;
- }
-
- // Create a global error event handler. We use this to capture the value
- // that was thrown. It's possible that this error handler will fire more
- // than once; for example, if non-React code also calls `dispatchEvent`
- // and a handler for that event throws. We should be resilient to most of
- // those cases. Even if our error event handler fires more than once, the
- // last error event is always used. If the callback actually does error,
- // we know that the last error event is the correct one, because it's not
- // possible for anything else to have happened in between our callback
- // erroring and the code that follows the `dispatchEvent` call below. If
- // the callback doesn't error, but the error event was fired, we know to
- // ignore it because `didError` will be false, as described above.
- var error = void 0;
- // Use this to track whether the error event is ever called.
- var didSetError = false;
- var isCrossOriginError = false;
-
- function onError(event) {
- error = event.error;
- didSetError = true;
- if (error === null && event.colno === 0 && event.lineno === 0) {
- isCrossOriginError = true;
- }
- }
-
- // Create a fake event type.
- var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
-
- // Attach our event handlers
- window.addEventListener('error', onError);
- fakeNode.addEventListener(evtType, callCallback, false);
-
- // Synchronously dispatch our fake event. If the user-provided function
- // errors, it will trigger our global error handler.
- var evt = document.createEvent('Event');
- evt.initEvent(evtType, false, false);
- fakeNode.dispatchEvent(evt);
-
- if (didError) {
- if (!didSetError) {
- // The callback errored, but the error event never fired.
- error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
- } else if (isCrossOriginError) {
- error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
- }
- ReactErrorUtils._hasCaughtError = true;
- ReactErrorUtils._caughtError = error;
- } else {
- ReactErrorUtils._hasCaughtError = false;
- ReactErrorUtils._caughtError = null;
- }
-
- // Remove our event listeners
- window.removeEventListener('error', onError);
- };
-
- invokeGuardedCallback = invokeGuardedCallbackDev;
+
}
}
-var rethrowCaughtError = function () {
- if (ReactErrorUtils._hasRethrowError) {
- var error = ReactErrorUtils._rethrowError;
- ReactErrorUtils._rethrowError = null;
- ReactErrorUtils._hasRethrowError = false;
- throw error;
- }
-};
-
-var ReactErrorUtils_1 = ReactErrorUtils;
-
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
@@ -319,13 +141,25 @@ emptyFunction.thatReturnsArgument = function (arg) {
var emptyFunction_1 = emptyFunction;
/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ */
+
+
+
+
+
+/**
* 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 warning$1 = emptyFunction_1;
+var warning = emptyFunction_1;
{
var printWarning = function printWarning(format) {
@@ -348,7 +182,7 @@ var warning$1 = emptyFunction_1;
} catch (x) {}
};
- warning$1 = function warning(condition, format) {
+ warning = function warning(condition, format) {
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
}
@@ -367,26 +201,20 @@ var warning$1 = emptyFunction_1;
};
}
-var warning_1 = warning$1;
+var warning_1 = warning;
-{
- var warning = warning_1;
-}
+var getFiberCurrentPropsFromNode = null;
+var getInstanceFromNode = null;
+var getNodeFromInstance = null;
-/**
- * Injected dependencies:
- */
-
-/**
- * - `ComponentTree`: [required] Module that can convert between React instances
- * and actual node references.
- */
-var ComponentTree;
var injection = {
injectComponentTree: function (Injected) {
- ComponentTree = Injected;
+ getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode;
+ getInstanceFromNode = Injected.getInstanceFromNode;
+ getNodeFromInstance = Injected.getNodeFromInstance;
+
{
- warning(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.');
+ warning_1(getNodeFromInstance && getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.');
}
}
};
@@ -414,47 +242,14 @@ var validateEventDispatches;
var instancesIsArr = Array.isArray(dispatchInstances);
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
- warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.');
+ warning_1(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.');
};
}
/**
- * Dispatch the event to the listener.
- * @param {SyntheticEvent} event SyntheticEvent to handle
- * @param {boolean} simulated If the event is simulated (changes exn behavior)
- * @param {function} listener Application-level callback
- * @param {*} inst Internal component instance
- */
-function executeDispatch(event, simulated, listener, inst) {
- var type = event.type || 'unknown-event';
- event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
- ReactErrorUtils_1.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
- event.currentTarget = null;
-}
-
-/**
* Standard/simple iteration through an event's collected dispatches.
*/
-function executeDispatchesInOrder(event, simulated) {
- var dispatchListeners = event._dispatchListeners;
- var dispatchInstances = event._dispatchInstances;
- {
- validateEventDispatches(event);
- }
- if (Array.isArray(dispatchListeners)) {
- for (var i = 0; i < dispatchListeners.length; i++) {
- if (event.isPropagationStopped()) {
- break;
- }
- // Listeners and Instances are two parallel arrays that are always in sync.
- executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
- }
- } else if (dispatchListeners) {
- executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
- }
- event._dispatchListeners = null;
- event._dispatchInstances = null;
-}
+
/**
* Standard/simple iteration through an event's collected dispatches, but stops
@@ -513,7 +308,7 @@ function executeDirectDispatch(event) {
var dispatchListener = event._dispatchListeners;
var dispatchInstance = event._dispatchInstances;
!!Array.isArray(dispatchListener) ? invariant_1(false, 'executeDirectDispatch(...): Invalid `event`.') : void 0;
- event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null;
+ event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null;
var res = dispatchListener ? dispatchListener(event) : null;
event.currentTarget = null;
event._dispatchListeners = null;
@@ -529,201 +324,168 @@ function hasDispatches(event) {
return !!event._dispatchListeners;
}
-/**
- * General utilities that are useful in creating custom Event Plugins.
- */
-var EventPluginUtils = {
- isEndish: isEndish,
- isMoveish: isMoveish,
- isStartish: isStartish,
-
- executeDirectDispatch: executeDirectDispatch,
- executeDispatchesInOrder: executeDispatchesInOrder,
- executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
- hasDispatches: hasDispatches,
-
- getFiberCurrentPropsFromNode: function (node) {
- return ComponentTree.getFiberCurrentPropsFromNode(node);
- },
- getInstanceFromNode: function (node) {
- return ComponentTree.getInstanceFromNode(node);
- },
- getNodeFromInstance: function (node) {
- return ComponentTree.getNodeFromInstance(node);
- },
+// Before we know whether it is functional or class
- injection: injection
-};
-var EventPluginUtils_1 = EventPluginUtils;
+ // 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;
-/**
- * Injectable ordering of event plugins.
- */
-var eventPluginOrder = null;
+function getParent(inst) {
+ do {
+ inst = inst['return'];
+ // TODO: If this is a HostRoot we might want to bail out.
+ // That is depending on if we want nested subtrees (layers) to bubble
+ // events to their parent. We could also go through parentNode on the
+ // host node but that wouldn't work for React Native and doesn't let us
+ // do the portal feature.
+ } while (inst && inst.tag !== HostComponent);
+ if (inst) {
+ return inst;
+ }
+ return null;
+}
/**
- * Injectable mapping from names to event plugin modules.
+ * Return the lowest common ancestor of A and B, or null if they are in
+ * different trees.
*/
-var namesToPlugins = {};
+function getLowestCommonAncestor(instA, instB) {
+ var depthA = 0;
+ for (var tempA = instA; tempA; tempA = getParent(tempA)) {
+ depthA++;
+ }
+ var depthB = 0;
+ for (var tempB = instB; tempB; tempB = getParent(tempB)) {
+ depthB++;
+ }
-/**
- * Recomputes the plugin list using the injected plugins and plugin ordering.
- *
- * @private
- */
-function recomputePluginOrdering() {
- if (!eventPluginOrder) {
- // Wait until an `eventPluginOrder` is injected.
- return;
+ // If A is deeper, crawl up.
+ while (depthA - depthB > 0) {
+ instA = getParent(instA);
+ depthA--;
}
- for (var pluginName in namesToPlugins) {
- var pluginModule = namesToPlugins[pluginName];
- var pluginIndex = eventPluginOrder.indexOf(pluginName);
- !(pluginIndex > -1) ? invariant_1(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0;
- if (EventPluginRegistry.plugins[pluginIndex]) {
- continue;
- }
- !pluginModule.extractEvents ? invariant_1(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0;
- EventPluginRegistry.plugins[pluginIndex] = pluginModule;
- var publishedEvents = pluginModule.eventTypes;
- for (var eventName in publishedEvents) {
- !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant_1(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0;
+
+ // If B is deeper, crawl up.
+ while (depthB - depthA > 0) {
+ instB = getParent(instB);
+ depthB--;
+ }
+
+ // Walk in lockstep until we find a match.
+ var depth = depthA;
+ while (depth--) {
+ if (instA === instB || instA === instB.alternate) {
+ return instA;
}
+ instA = getParent(instA);
+ instB = getParent(instB);
}
+ return null;
}
/**
- * Publishes an event so that it can be dispatched by the supplied plugin.
- *
- * @param {object} dispatchConfig Dispatch configuration for the event.
- * @param {object} PluginModule Plugin publishing the event.
- * @return {boolean} True if the event was successfully published.
- * @private
+ * Return if A is an ancestor of B.
*/
-function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
- !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant_1(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0;
- EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
-
- var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
- if (phasedRegistrationNames) {
- for (var phaseName in phasedRegistrationNames) {
- if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
- var phasedRegistrationName = phasedRegistrationNames[phaseName];
- publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
- }
+function isAncestor(instA, instB) {
+ while (instB) {
+ if (instA === instB || instA === instB.alternate) {
+ return true;
}
- return true;
- } else if (dispatchConfig.registrationName) {
- publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
- return true;
+ instB = getParent(instB);
}
return false;
}
/**
- * Publishes a registration name that is used to identify dispatched events.
- *
- * @param {string} registrationName Registration name to add.
- * @param {object} PluginModule Plugin publishing the event.
- * @private
+ * Return the parent instance of the passed-in instance.
*/
-function publishRegistrationName(registrationName, pluginModule, eventName) {
- !!EventPluginRegistry.registrationNameModules[registrationName] ? invariant_1(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0;
- EventPluginRegistry.registrationNameModules[registrationName] = pluginModule;
- EventPluginRegistry.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
-
- {
- var lowerCasedName = registrationName.toLowerCase();
- EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName;
+function getParentInstance(inst) {
+ return getParent(inst);
+}
- if (registrationName === 'onDoubleClick') {
- EventPluginRegistry.possibleRegistrationNames.ondblclick = registrationName;
- }
+/**
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
+ */
+function traverseTwoPhase(inst, fn, arg) {
+ var path = [];
+ while (inst) {
+ path.push(inst);
+ inst = getParent(inst);
+ }
+ var i;
+ for (i = path.length; i-- > 0;) {
+ fn(path[i], 'captured', arg);
+ }
+ for (i = 0; i < path.length; i++) {
+ fn(path[i], 'bubbled', arg);
}
}
/**
+ * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
+ * should would receive a `mouseEnter` or `mouseLeave` event.
+ *
+ * Does not invoke the callback on the nearest common ancestor because nothing
+ * "entered" or "left" that element.
+ */
+
+/**
* Registers plugins so that they can extract and dispatch events.
*
* @see {EventPluginHub}
*/
-var EventPluginRegistry = {
- /**
- * Ordered list of injected plugins.
- */
- plugins: [],
- /**
- * Mapping from event name to dispatch config
- */
- eventNameDispatchConfigs: {},
+/**
+ * Ordered list of injected plugins.
+ */
- /**
- * Mapping from registration name to plugin module
- */
- registrationNameModules: {},
- /**
- * Mapping from registration name to event name
- */
- registrationNameDependencies: {},
+/**
+ * Mapping from event name to dispatch config
+ */
- /**
- * Mapping from lowercase registration names to the properly cased version,
- * used to warn in the case of missing event handlers. Available
- * only in true.
- * @type {Object}
- */
- possibleRegistrationNames: {},
- // Trust the developer to only use possibleRegistrationNames in true
- /**
- * Injects an ordering of plugins (by plugin name). This allows the ordering
- * to be decoupled from injection of the actual plugins so that ordering is
- * always deterministic regardless of packaging, on-the-fly injection, etc.
- *
- * @param {array} InjectedEventPluginOrder
- * @internal
- * @see {EventPluginHub.injection.injectEventPluginOrder}
- */
- injectEventPluginOrder: function (injectedEventPluginOrder) {
- !!eventPluginOrder ? invariant_1(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0;
- // Clone the ordering so it cannot be dynamically mutated.
- eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
- recomputePluginOrdering();
- },
+/**
+ * Mapping from registration name to plugin module
+ */
- /**
- * Injects plugins to be used by `EventPluginHub`. The plugin names must be
- * in the ordering injected by `injectEventPluginOrder`.
- *
- * Plugins can be injected as part of page initialization or on-the-fly.
- *
- * @param {object} injectedNamesToPlugins Map from names to plugin modules.
- * @internal
- * @see {EventPluginHub.injection.injectEventPluginsByName}
- */
- injectEventPluginsByName: function (injectedNamesToPlugins) {
- var isOrderingDirty = false;
- for (var pluginName in injectedNamesToPlugins) {
- if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
- continue;
- }
- var pluginModule = injectedNamesToPlugins[pluginName];
- if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
- !!namesToPlugins[pluginName] ? invariant_1(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : void 0;
- namesToPlugins[pluginName] = pluginModule;
- isOrderingDirty = true;
- }
- }
- if (isOrderingDirty) {
- recomputePluginOrdering();
- }
- }
-};
-var EventPluginRegistry_1 = EventPluginRegistry;
+/**
+ * Mapping from registration name to event name
+ */
+
+
+/**
+ * Mapping from lowercase registration names to the properly cased version,
+ * used to warn in the case of missing event handlers. Available
+ * only in true.
+ * @type {Object}
+ */
+
+// Trust the developer to only use possibleRegistrationNames in true
+
+/**
+ * Injects an ordering of plugins (by plugin name). This allows the ordering
+ * to be decoupled from injection of the actual plugins so that ordering is
+ * always deterministic regardless of packaging, on-the-fly injection, etc.
+ *
+ * @param {array} InjectedEventPluginOrder
+ * @internal
+ * @see {EventPluginHub.injection.injectEventPluginOrder}
+ */
+
+
+/**
+ * Injects plugins to be used by `EventPluginHub`. The plugin names must be
+ * in the ordering injected by `injectEventPluginOrder`.
+ *
+ * Plugins can be injected as part of page initialization or on-the-fly.
+ *
+ * @param {object} injectedNamesToPlugins Map from names to plugin modules.
+ * @internal
+ * @see {EventPluginHub.injection.injectEventPluginsByName}
+ */
/**
* Accumulates items that must not be null or undefined into the first one. This
@@ -764,18 +526,6 @@ function accumulateInto(current, next) {
return [current, next];
}
-var accumulateInto_1 = accumulateInto;
-
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule forEachAccumulated
- *
- */
-
/**
* @param {array} arr an "accumulation" of items which is either an Array or
* a single item. Useful when paired with the `accumulate` module. This is a
@@ -785,7 +535,6 @@ var accumulateInto_1 = accumulateInto;
* @param {function} cb Callback invoked with each element or a collection.
* @param {?} [scope] Scope used as `this` in a callback.
*/
-
function forEachAccumulated(arr, cb, scope) {
if (Array.isArray(arr)) {
arr.forEach(cb, scope);
@@ -794,37 +543,6 @@ function forEachAccumulated(arr, cb, scope) {
}
}
-var forEachAccumulated_1 = forEachAccumulated;
-
-/**
- * Internal queue of events that have accumulated their dispatches and are
- * waiting to have their dispatches executed.
- */
-var eventQueue = null;
-
-/**
- * Dispatches an event and releases it back into the pool, unless persistent.
- *
- * @param {?object} event Synthetic event to be dispatched.
- * @param {boolean} simulated If the event is simulated (changes exn behavior)
- * @private
- */
-var executeDispatchesAndRelease = function (event, simulated) {
- if (event) {
- EventPluginUtils_1.executeDispatchesInOrder(event, simulated);
-
- if (!event.isPersistent()) {
- event.constructor.release(event);
- }
- }
-};
-var executeDispatchesAndReleaseSimulated = function (e) {
- return executeDispatchesAndRelease(e, true);
-};
-var executeDispatchesAndReleaseTopLevel = function (e) {
- return executeDispatchesAndRelease(e, false);
-};
-
function isInteractive(tag) {
return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
}
@@ -869,291 +587,63 @@ function shouldPreventMouseEvent(name, type, props) {
*
* @public
*/
-var EventPluginHub = {
- /**
- * Methods for injecting dependencies.
- */
- injection: {
- /**
- * @param {array} InjectedEventPluginOrder
- * @public
- */
- injectEventPluginOrder: EventPluginRegistry_1.injectEventPluginOrder,
-
- /**
- * @param {object} injectedNamesToPlugins Map from names to plugin modules.
- */
- injectEventPluginsByName: EventPluginRegistry_1.injectEventPluginsByName
- },
-
- /**
- * @param {object} inst The instance, which is the source of events.
- * @param {string} registrationName Name of listener (e.g. `onClick`).
- * @return {?function} The stored callback.
- */
- getListener: function (inst, registrationName) {
- var listener;
-
- // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
- // live here; needs to be moved to a better place soon
- if (typeof inst.tag === 'number') {
- var stateNode = inst.stateNode;
- if (!stateNode) {
- // Work in progress (ex: onload events in incremental mode).
- return null;
- }
- var props = EventPluginUtils_1.getFiberCurrentPropsFromNode(stateNode);
- if (!props) {
- // Work in progress.
- return null;
- }
- listener = props[registrationName];
- if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
- return null;
- }
- } else {
- var currentElement = inst._currentElement;
- if (typeof currentElement === 'string' || typeof currentElement === 'number') {
- // Text node, let it bubble through.
- return null;
- }
- if (!inst._rootNodeID) {
- // If the instance is already unmounted, we have no listeners.
- return null;
- }
- var _props = currentElement.props;
- listener = _props[registrationName];
- if (shouldPreventMouseEvent(registrationName, currentElement.type, _props)) {
- return null;
- }
- }
-
- !(!listener || typeof listener === 'function') ? invariant_1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0;
- return listener;
- },
-
- /**
- * Allows registered plugins an opportunity to extract events from top-level
- * native browser events.
- *
- * @return {*} An accumulation of synthetic events.
- * @internal
- */
- extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
- var events;
- var plugins = EventPluginRegistry_1.plugins;
- for (var i = 0; i < plugins.length; i++) {
- // Not every plugin in the ordering may be loaded at runtime.
- var possiblePlugin = plugins[i];
- if (possiblePlugin) {
- var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
- if (extractedEvents) {
- events = accumulateInto_1(events, extractedEvents);
- }
- }
- }
- return events;
- },
-
- /**
- * Enqueues a synthetic event that should be dispatched when
- * `processEventQueue` is invoked.
- *
- * @param {*} events An accumulation of synthetic events.
- * @internal
- */
- enqueueEvents: function (events) {
- if (events) {
- eventQueue = accumulateInto_1(eventQueue, events);
- }
- },
-
- /**
- * Dispatches all synthetic events on the event queue.
- *
- * @internal
- */
- processEventQueue: function (simulated) {
- // Set `eventQueue` to null before processing it so that we can tell if more
- // events get enqueued while processing.
- var processingEventQueue = eventQueue;
- eventQueue = null;
- if (simulated) {
- forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseSimulated);
- } else {
- forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseTopLevel);
- }
- !!eventQueue ? invariant_1(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0;
- // This would be a good time to rethrow if any of the event handlers threw.
- ReactErrorUtils_1.rethrowCaughtError();
- }
-};
-
-var EventPluginHub_1 = EventPluginHub;
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule ReactTypeOfWork
- *
+ * Methods for injecting dependencies.
*/
-var ReactTypeOfWork = {
- IndeterminateComponent: 0, // Before we know whether it is functional or class
- FunctionalComponent: 1,
- ClassComponent: 2,
- HostRoot: 3, // Root of a host tree. Could be nested inside another node.
- HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
- HostComponent: 5,
- HostText: 6,
- CoroutineComponent: 7,
- CoroutineHandlerPhase: 8,
- YieldComponent: 9,
- Fragment: 10
-};
-
-var HostComponent = ReactTypeOfWork.HostComponent;
-
-function getParent(inst) {
- if (inst._hostParent !== undefined) {
- return inst._hostParent;
- }
- if (typeof inst.tag === 'number') {
- do {
- inst = inst['return'];
- // TODO: If this is a HostRoot we might want to bail out.
- // That is depending on if we want nested subtrees (layers) to bubble
- // events to their parent. We could also go through parentNode on the
- // host node but that wouldn't work for React Native and doesn't let us
- // do the portal feature.
- } while (inst && inst.tag !== HostComponent);
- if (inst) {
- return inst;
- }
- }
- return null;
-}
/**
- * Return the lowest common ancestor of A and B, or null if they are in
- * different trees.
+ * @param {object} inst The instance, which is the source of events.
+ * @param {string} registrationName Name of listener (e.g. `onClick`).
+ * @return {?function} The stored callback.
*/
-function getLowestCommonAncestor(instA, instB) {
- var depthA = 0;
- for (var tempA = instA; tempA; tempA = getParent(tempA)) {
- depthA++;
- }
- var depthB = 0;
- for (var tempB = instB; tempB; tempB = getParent(tempB)) {
- depthB++;
- }
-
- // If A is deeper, crawl up.
- while (depthA - depthB > 0) {
- instA = getParent(instA);
- depthA--;
+function getListener(inst, registrationName) {
+ var listener;
+
+ // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
+ // live here; needs to be moved to a better place soon
+ var stateNode = inst.stateNode;
+ if (!stateNode) {
+ // Work in progress (ex: onload events in incremental mode).
+ return null;
}
-
- // If B is deeper, crawl up.
- while (depthB - depthA > 0) {
- instB = getParent(instB);
- depthB--;
+ var props = getFiberCurrentPropsFromNode(stateNode);
+ if (!props) {
+ // Work in progress.
+ return null;
}
-
- // Walk in lockstep until we find a match.
- var depth = depthA;
- while (depth--) {
- if (instA === instB || instA === instB.alternate) {
- return instA;
- }
- instA = getParent(instA);
- instB = getParent(instB);
+ listener = props[registrationName];
+ if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
+ return null;
}
- return null;
+ !(!listener || typeof listener === 'function') ? invariant_1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0;
+ return listener;
}
/**
- * Return if A is an ancestor of B.
+ * Allows registered plugins an opportunity to extract events from top-level
+ * native browser events.
+ *
+ * @return {*} An accumulation of synthetic events.
+ * @internal
*/
-function isAncestor(instA, instB) {
- while (instB) {
- if (instA === instB || instA === instB.alternate) {
- return true;
- }
- instB = getParent(instB);
- }
- return false;
-}
-/**
- * Return the parent instance of the passed-in instance.
- */
-function getParentInstance(inst) {
- return getParent(inst);
-}
/**
- * Simulates the traversal of a two-phase, capture/bubble event dispatch.
+ * Enqueues a synthetic event that should be dispatched when
+ * `processEventQueue` is invoked.
+ *
+ * @param {*} events An accumulation of synthetic events.
+ * @internal
*/
-function traverseTwoPhase(inst, fn, arg) {
- var path = [];
- while (inst) {
- path.push(inst);
- inst = getParent(inst);
- }
- var i;
- for (i = path.length; i-- > 0;) {
- fn(path[i], 'captured', arg);
- }
- for (i = 0; i < path.length; i++) {
- fn(path[i], 'bubbled', arg);
- }
-}
+
/**
- * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
- * should would receive a `mouseEnter` or `mouseLeave` event.
+ * Dispatches all synthetic events on the event queue.
*
- * Does not invoke the callback on the nearest common ancestor because nothing
- * "entered" or "left" that element.
+ * @internal
*/
-function traverseEnterLeave(from, to, fn, argFrom, argTo) {
- var common = from && to ? getLowestCommonAncestor(from, to) : null;
- var pathFrom = [];
- while (from && from !== common) {
- pathFrom.push(from);
- from = getParent(from);
- }
- var pathTo = [];
- while (to && to !== common) {
- pathTo.push(to);
- to = getParent(to);
- }
- var i;
- for (i = 0; i < pathFrom.length; i++) {
- fn(pathFrom[i], 'bubbled', argFrom);
- }
- for (i = pathTo.length; i-- > 0;) {
- fn(pathTo[i], 'captured', argTo);
- }
-}
-
-var ReactTreeTraversal = {
- isAncestor: isAncestor,
- getLowestCommonAncestor: getLowestCommonAncestor,
- getParentInstance: getParentInstance,
- traverseTwoPhase: traverseTwoPhase,
- traverseEnterLeave: traverseEnterLeave
-};
-
-var getListener = EventPluginHub_1.getListener;
-
-{
- var warning$2 = warning_1;
-}
/**
* Some event types have a notion of different registration names for different
@@ -1165,6 +655,16 @@ function listenerAtPhase(inst, event, propagationPhase) {
}
/**
+ * A small set of propagation patterns, each of which will accept a small amount
+ * of information, and generate a set of "dispatch ready event objects" - which
+ * are sets of events that have already been annotated with a set of dispatched
+ * listener functions/ids. The API is designed this way to discourage these
+ * propagation strategies from actually executing the dispatches, since we
+ * always want to collect the entire set of dispatches before executing even a
+ * single one.
+ */
+
+/**
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
* here, allows us to not have to bind or create functions for each event.
* Mutating the event's members allows us to not have to create a wrapping
@@ -1172,12 +672,12 @@ function listenerAtPhase(inst, event, propagationPhase) {
*/
function accumulateDirectionalDispatches(inst, phase, event) {
{
- warning$2(inst, 'Dispatching inst must not be null');
+ warning_1(inst, 'Dispatching inst must not be null');
}
var listener = listenerAtPhase(inst, event, phase);
if (listener) {
- event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener);
- event._dispatchInstances = accumulateInto_1(event._dispatchInstances, inst);
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
}
}
@@ -1190,7 +690,7 @@ function accumulateDirectionalDispatches(inst, phase, event) {
*/
function accumulateTwoPhaseDispatchesSingle(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
- ReactTreeTraversal.traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
}
}
@@ -1200,8 +700,8 @@ function accumulateTwoPhaseDispatchesSingle(event) {
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
var targetInst = event._targetInst;
- var parentInst = targetInst ? ReactTreeTraversal.getParentInstance(targetInst) : null;
- ReactTreeTraversal.traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
+ var parentInst = targetInst ? getParentInstance(targetInst) : null;
+ traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
}
}
@@ -1215,8 +715,8 @@ function accumulateDispatches(inst, ignoredDirection, event) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(inst, registrationName);
if (listener) {
- event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener);
- event._dispatchInstances = accumulateInto_1(event._dispatchInstances, inst);
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
}
}
}
@@ -1233,139 +733,29 @@ function accumulateDirectDispatchesSingle(event) {
}
function accumulateTwoPhaseDispatches(events) {
- forEachAccumulated_1(events, accumulateTwoPhaseDispatchesSingle);
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
}
function accumulateTwoPhaseDispatchesSkipTarget(events) {
- forEachAccumulated_1(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
}
-function accumulateEnterLeaveDispatches(leave, enter, from, to) {
- ReactTreeTraversal.traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
-}
+
function accumulateDirectDispatches(events) {
- forEachAccumulated_1(events, accumulateDirectDispatchesSingle);
+ forEachAccumulated(events, accumulateDirectDispatchesSingle);
}
-/**
- * A small set of propagation patterns, each of which will accept a small amount
- * of information, and generate a set of "dispatch ready event objects" - which
- * are sets of events that have already been annotated with a set of dispatched
- * listener functions/ids. The API is designed this way to discourage these
- * propagation strategies from actually executing the dispatches, since we
- * always want to collect the entire set of dispatches before executing even a
- * single one.
- *
- * @constructor EventPropagators
- */
-var EventPropagators = {
- accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
- accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
- accumulateDirectDispatches: accumulateDirectDispatches,
- accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
-};
-
-var EventPropagators_1 = EventPropagators;
+var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
-/*
-object-assign
-(c) Sindre Sorhus
-@license MIT
-*/
+var _assign = ReactInternals.assign;
-/* eslint-disable no-unused-vars */
-var getOwnPropertySymbols = Object.getOwnPropertySymbols;
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
-function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
-}
-
-function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
-}
-
-var index = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
-};
+/* eslint valid-typeof: 0 */
var didWarnForAddedNewProperty = false;
var isProxySupported = typeof Proxy === 'function';
var EVENT_POOL_SIZE = 10;
-{
- var warning$3 = warning_1;
-}
-
var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
/**
@@ -1447,7 +837,7 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
return this;
}
-index(SyntheticEvent.prototype, {
+_assign(SyntheticEvent.prototype, {
preventDefault: function () {
this.defaultPrevented = true;
var event = this.nativeEvent;
@@ -1535,19 +925,19 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
E.prototype = Super.prototype;
var prototype = new E();
- index(prototype, Class.prototype);
+ _assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = index({}, Super.Interface, Interface);
+ Class.Interface = _assign({}, Super.Interface, Interface);
Class.augmentClass = Super.augmentClass;
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)
- */
+ * 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 */
@@ -1559,7 +949,7 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
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$3(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.');
+ warning_1(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;
@@ -1574,15 +964,13 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
addEventPoolingTo(SyntheticEvent);
-var SyntheticEvent_1 = SyntheticEvent;
-
/**
- * Helper to nullify syntheticEvent instance properties when destructing
- *
- * @param {String} propName
- * @param {?object} getVal
- * @return {object} defineProperty object
- */
+ * Helper to nullify syntheticEvent instance properties when destructing
+ *
+ * @param {String} propName
+ * @param {?object} getVal
+ * @return {object} defineProperty object
+ */
function getPooledWarningPropertyDefinition(propName, getVal) {
var isFunction = typeof getVal === 'function';
return {
@@ -1606,7 +994,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
function warn(action, result) {
var warningCondition = false;
- warning$3(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);
+ warning_1(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);
}
}
@@ -1635,6 +1023,8 @@ function addEventPoolingTo(EventConstructor) {
EventConstructor.release = releasePooledEvent;
}
+var SyntheticEvent$1 = SyntheticEvent;
+
/**
* `touchHistory` isn't actually on the native event, but putting it in the
* interface will ensure that it is cleaned up when pooled/destroyed. The
@@ -1653,21 +1043,10 @@ var ResponderEventInterface = {
* @extends {SyntheticEvent}
*/
function ResponderSyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
- return SyntheticEvent_1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
+ return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
}
-SyntheticEvent_1.augmentClass(ResponderSyntheticEvent, ResponderEventInterface);
-
-var ResponderSyntheticEvent_1 = ResponderSyntheticEvent;
-
-var isEndish$2 = EventPluginUtils_1.isEndish;
-var isMoveish$2 = EventPluginUtils_1.isMoveish;
-var isStartish$2 = EventPluginUtils_1.isStartish;
-
-
-{
- var warning$4 = warning_1;
-}
+SyntheticEvent$1.augmentClass(ResponderSyntheticEvent, ResponderEventInterface);
/**
* Tracks the position and time of each active touch by `touch.identifier`. We
@@ -1732,7 +1111,7 @@ function getTouchIdentifier(_ref) {
!(identifier != null) ? invariant_1(false, 'Touch object is missing identifier.') : void 0;
{
- warning$4(identifier <= MAX_TOUCH_BANK, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK);
+ warning_1(identifier <= MAX_TOUCH_BANK, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK);
}
return identifier;
}
@@ -1799,15 +1178,15 @@ function printTouchBank() {
var ResponderTouchHistoryStore = {
recordTouchTrack: function (topLevelType, nativeEvent) {
- if (isMoveish$2(topLevelType)) {
+ if (isMoveish(topLevelType)) {
nativeEvent.changedTouches.forEach(recordTouchMove);
- } else if (isStartish$2(topLevelType)) {
+ } else if (isStartish(topLevelType)) {
nativeEvent.changedTouches.forEach(recordTouchStart);
touchHistory.numberActiveTouches = nativeEvent.touches.length;
if (touchHistory.numberActiveTouches === 1) {
touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
}
- } else if (isEndish$2(topLevelType)) {
+ } else if (isEndish(topLevelType)) {
nativeEvent.changedTouches.forEach(recordTouchEnd);
touchHistory.numberActiveTouches = nativeEvent.touches.length;
if (touchHistory.numberActiveTouches === 1) {
@@ -1820,7 +1199,7 @@ var ResponderTouchHistoryStore = {
}
{
var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
- warning$4(activeRecord != null && activeRecord.touchActive, 'Cannot find single active touch.');
+ warning_1(activeRecord != null && activeRecord.touchActive, 'Cannot find single active touch.');
}
}
}
@@ -1830,8 +1209,6 @@ var ResponderTouchHistoryStore = {
touchHistory: touchHistory
};
-var ResponderTouchHistoryStore_1 = ResponderTouchHistoryStore;
-
/**
* Accumulates items that must not be null or undefined.
*
@@ -1859,15 +1236,6 @@ function accumulate(current, next) {
return [current, next];
}
-var accumulate_1 = accumulate;
-
-var isStartish$1 = EventPluginUtils_1.isStartish;
-var isMoveish$1 = EventPluginUtils_1.isMoveish;
-var isEndish$1 = EventPluginUtils_1.isEndish;
-var executeDirectDispatch$1 = EventPluginUtils_1.executeDirectDispatch;
-var hasDispatches$1 = EventPluginUtils_1.hasDispatches;
-var executeDispatchesInOrderStopAtTrue$1 = EventPluginUtils_1.executeDispatchesInOrderStopAtTrue;
-
/**
* Instance of element that should respond to touch/move types of interactions,
* as indicated explicitly by relevant callbacks.
@@ -2152,24 +1520,24 @@ to return true:wantsResponderID| |
*/
function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
- var shouldSetEventType = isStartish$1(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish$1(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === 'topSelectionChange' ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
+ var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === 'topSelectionChange' ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
// TODO: stop one short of the current responder.
- var bubbleShouldSetFrom = !responderInst ? targetInst : ReactTreeTraversal.getLowestCommonAncestor(responderInst, targetInst);
+ var bubbleShouldSetFrom = !responderInst ? targetInst : getLowestCommonAncestor(responderInst, targetInst);
// When capturing/bubbling the "shouldSet" event, we want to skip the target
// (deepest ID) if it happens to be the current responder. The reasoning:
// It's strange to get an `onMoveShouldSetResponder` when you're *already*
// the responder.
var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
- var shouldSetEvent = ResponderSyntheticEvent_1.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
- shouldSetEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
+ var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
+ shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
if (skipOverBubbleShouldSetFrom) {
- EventPropagators_1.accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
+ accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
} else {
- EventPropagators_1.accumulateTwoPhaseDispatches(shouldSetEvent);
+ accumulateTwoPhaseDispatches(shouldSetEvent);
}
- var wantsResponderInst = executeDispatchesInOrderStopAtTrue$1(shouldSetEvent);
+ var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
if (!shouldSetEvent.isPersistent()) {
shouldSetEvent.constructor.release(shouldSetEvent);
}
@@ -2178,34 +1546,34 @@ function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, n
return null;
}
var extracted;
- var grantEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
- grantEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
+ var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
+ grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(grantEvent);
- var blockHostResponder = executeDirectDispatch$1(grantEvent) === true;
+ accumulateDirectDispatches(grantEvent);
+ var blockHostResponder = executeDirectDispatch(grantEvent) === true;
if (responderInst) {
- var terminationRequestEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
- terminationRequestEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(terminationRequestEvent);
- var shouldSwitch = !hasDispatches$1(terminationRequestEvent) || executeDirectDispatch$1(terminationRequestEvent);
+ var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
+ terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
+ accumulateDirectDispatches(terminationRequestEvent);
+ var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
if (!terminationRequestEvent.isPersistent()) {
terminationRequestEvent.constructor.release(terminationRequestEvent);
}
if (shouldSwitch) {
- var terminateEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
- terminateEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(terminateEvent);
- extracted = accumulate_1(extracted, [grantEvent, terminateEvent]);
+ var terminateEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
+ terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
+ accumulateDirectDispatches(terminateEvent);
+ extracted = accumulate(extracted, [grantEvent, terminateEvent]);
changeResponder(wantsResponderInst, blockHostResponder);
} else {
- var rejectEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
- rejectEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(rejectEvent);
- extracted = accumulate_1(extracted, rejectEvent);
+ var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
+ rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
+ accumulateDirectDispatches(rejectEvent);
+ extracted = accumulate(extracted, rejectEvent);
}
} else {
- extracted = accumulate_1(extracted, grantEvent);
+ extracted = accumulate(extracted, grantEvent);
changeResponder(wantsResponderInst, blockHostResponder);
}
return extracted;
@@ -2224,7 +1592,7 @@ function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
// responderIgnoreScroll: We are trying to migrate away from specifically
// tracking native scroll events here and responderIgnoreScroll indicates we
// will send topTouchCancel to handle canceling touch events instead
- topLevelType === 'topScroll' && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === 'topSelectionChange' || isStartish$1(topLevelType) || isMoveish$1(topLevelType));
+ topLevelType === 'topScroll' && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === 'topSelectionChange' || isStartish(topLevelType) || isMoveish(topLevelType));
}
/**
@@ -2244,8 +1612,8 @@ function noResponderTouches(nativeEvent) {
var target = activeTouch.target;
if (target !== null && target !== undefined && target !== 0) {
// Is the original touch location inside of the current responder?
- var targetInst = EventPluginUtils_1.getInstanceFromNode(target);
- if (ReactTreeTraversal.isAncestor(responderInst, targetInst)) {
+ var targetInst = getInstanceFromNode(target);
+ if (isAncestor(responderInst, targetInst)) {
return false;
}
}
@@ -2267,9 +1635,9 @@ var ResponderEventPlugin = {
* assumed control and the original touch targets are destroyed.
*/
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
- if (isStartish$1(topLevelType)) {
+ if (isStartish(topLevelType)) {
trackedTouchCount += 1;
- } else if (isEndish$1(topLevelType)) {
+ } else if (isEndish(topLevelType)) {
if (trackedTouchCount >= 0) {
trackedTouchCount -= 1;
} else {
@@ -2278,7 +1646,7 @@ var ResponderEventPlugin = {
}
}
- ResponderTouchHistoryStore_1.recordTouchTrack(topLevelType, nativeEvent);
+ ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
// Responder may or may not have transferred on a new touch start/move.
@@ -2291,30 +1659,30 @@ var ResponderEventPlugin = {
// These multiple individual change touch events are are always bookended
// by `onResponderGrant`, and one of
// (`onResponderRelease/onResponderTerminate`).
- var isResponderTouchStart = responderInst && isStartish$1(topLevelType);
- var isResponderTouchMove = responderInst && isMoveish$1(topLevelType);
- var isResponderTouchEnd = responderInst && isEndish$1(topLevelType);
+ var isResponderTouchStart = responderInst && isStartish(topLevelType);
+ var isResponderTouchMove = responderInst && isMoveish(topLevelType);
+ var isResponderTouchEnd = responderInst && isEndish(topLevelType);
var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
if (incrementalTouch) {
- var gesture = ResponderSyntheticEvent_1.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
- gesture.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(gesture);
- extracted = accumulate_1(extracted, gesture);
+ var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
+ gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
+ accumulateDirectDispatches(gesture);
+ extracted = accumulate(extracted, gesture);
}
var isResponderTerminate = responderInst && topLevelType === 'topTouchCancel';
- var isResponderRelease = responderInst && !isResponderTerminate && isEndish$1(topLevelType) && noResponderTouches(nativeEvent);
+ var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
if (finalTouch) {
- var finalEvent = ResponderSyntheticEvent_1.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
- finalEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory;
- EventPropagators_1.accumulateDirectDispatches(finalEvent);
- extracted = accumulate_1(extracted, finalEvent);
+ var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
+ finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
+ accumulateDirectDispatches(finalEvent);
+ extracted = accumulate(extracted, finalEvent);
changeResponder(null);
}
- var numberActiveTouches = ResponderTouchHistoryStore_1.touchHistory.numberActiveTouches;
+ var numberActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches;
if (ResponderEventPlugin.GlobalInteractionHandler && numberActiveTouches !== previousActiveTouches) {
ResponderEventPlugin.GlobalInteractionHandler.onChange(numberActiveTouches);
}
@@ -2346,35 +1714,21 @@ var ResponderEventPlugin = {
}
};
-var ResponderEventPlugin_1 = ResponderEventPlugin;
-
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule ReactDOMUnstableNativeDependenciesEntry
- */
-
-
-
-
-
-var ReactDOMUnstableNativeDependencies = {
- injectComponentTree: EventPluginUtils_1.injection.injectComponentTree,
- ResponderEventPlugin: ResponderEventPlugin_1,
- ResponderTouchHistoryStore: ResponderTouchHistoryStore_1
-};
-
+// This is used by react-native-web.
+var injectComponentTree = injection.injectComponentTree;
// Inject react-dom's ComponentTree into this module.
+var ReactDOMComponentTree = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree;
-var ReactDOMComponentTree = reactDom.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree;
+injectComponentTree(ReactDOMComponentTree);
-ReactDOMUnstableNativeDependencies.injectComponentTree(ReactDOMComponentTree);
+var ReactDOMUnstableNativeDependencies = Object.freeze({
+ injectComponentTree: injectComponentTree,
+ ResponderEventPlugin: ResponderEventPlugin,
+ ResponderTouchHistoryStore: ResponderTouchHistoryStore
+});
-var ReactDOMUnstableNativeDependenciesEntry = ReactDOMUnstableNativeDependencies;
+var unstableNativeDependencies = ReactDOMUnstableNativeDependencies;
-return ReactDOMUnstableNativeDependenciesEntry;
+return unstableNativeDependencies;
})));