Untitled diff

Created Diff never expires
/** @license React vundefined
/** @license React v0.0.0-88eeb24bb
* react-dom.development.js
* react-dom.development.js
*
*
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Facebook, Inc. and its affiliates.
*
*
* This source code is licensed under the MIT license found in the
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
*/
'use strict';
'use strict';
(function (global, factory) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
typeof define === 'function' && define.amd ? define(['react'], factory) :
typeof define === 'function' && define.amd ? define(['react'], factory) :
(global.ReactDOM = factory(global.React));
(global.ReactDOM = factory(global.React));
}(this, (function (React) { 'use strict';
}(this, (function (React) { 'use strict';
// Do not require this module directly! Use normal `invariant` calls with
// Do not require this module directly! Use normal `invariant` calls with
// template literal strings. The messages will be converted to ReactError during
// template literal strings. The messages will be converted to ReactError during
// build, and in production they will be minified.
// build, and in production they will be minified.
// Do not require this module directly! Use normal `invariant` calls with
// Do not require this module directly! Use normal `invariant` calls with
// template literal strings. The messages will be converted to ReactError during
// template literal strings. The messages will be converted to ReactError during
// build, and in production they will be minified.
// build, and in production they will be minified.
function ReactError(error) {
function ReactError(error) {
error.name = 'Invariant Violation';
error.name = 'Invariant Violation';
return error;
return error;
}
}
/**
/**
* Use invariant() to assert state which your program assumes to be true.
* Use invariant() to assert state which your program assumes to be true.
*
*
* Provide sprintf-style format (only %s is supported) and arguments
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* to provide information about what broke and what you were
* expecting.
* expecting.
*
*
* The invariant message will be stripped in production, but the invariant
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
* will remain to ensure logic does not differ in production.
*/
*/
(function () {
(function () {
if (!React) {
if (!React) {
{
{
throw ReactError(Error('ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.'));
throw ReactError(Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM."));
}
}
}
}
})();
})();
/**
/**
* Injectable ordering of event plugins.
* Injectable ordering of event plugins.
*/
*/
var eventPluginOrder = null;
var eventPluginOrder = null;
/**
/**
* Injectable mapping from names to event plugin modules.
* Injectable mapping from names to event plugin modules.
*/
*/
var namesToPlugins = {};
var namesToPlugins = {};
/**
/**
* Recomputes the plugin list using the injected plugins and plugin ordering.
* Recomputes the plugin list using the injected plugins and plugin ordering.
*
*
* @private
* @private
*/
*/
function recomputePluginOrdering() {
function recomputePluginOrdering() {
if (!eventPluginOrder) {
if (!eventPluginOrder) {
// Wait until an `eventPluginOrder` is injected.
// Wait until an `eventPluginOrder` is injected.
return;
return;
}
}
for (var pluginName in namesToPlugins) {
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName];
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
var pluginIndex = eventPluginOrder.indexOf(pluginName);
(function () {
(function () {
if (!(pluginIndex > -1)) {
if (!(pluginIndex > -1)) {
{
{
throw ReactError(Error('EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `' + pluginName + '`.'));
throw ReactError(Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`."));
}
}
}
}
})();
})();
if (plugins[pluginIndex]) {
if (plugins[pluginIndex]) {
continue;
continue;
}
}
(function () {
(function () {
if (!pluginModule.extractEvents) {
if (!pluginModule.extractEvents) {
{
{
throw ReactError(Error('EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `' + pluginName + '` does not.'));
throw ReactError(Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not."));
}
}
}
}
})();
})();
plugins[pluginIndex] = pluginModule;
plugins[pluginIndex] = pluginModule;
var publishedEvents = pluginModule.eventTypes;
var publishedEvents = pluginModule.eventTypes;
for (var eventName in publishedEvents) {
for (var eventName in publishedEvents) {
(function () {
(function () {
if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
{
{
throw ReactError(Error('EventPluginRegistry: Failed to publish event `' + eventName + '` for plugin `' + pluginName + '`.'));
throw ReactError(Error("EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`."));
}
}
}
}
})();
})();
}
}
}
}
}
}
/**
/**
* Publishes an event so that it can be dispatched by the supplied plugin.
* Publishes an event so that it can be dispatched by the supplied plugin.
*
*
* @param {object} dispatchConfig Dispatch configuration for the event.
* @param {object} dispatchConfig Dispatch configuration for the event.
* @param {object} PluginModule Plugin publishing the event.
* @param {object} PluginModule Plugin publishing the event.
* @return {boolean} True if the event was successfully published.
* @return {boolean} True if the event was successfully published.
* @private
* @private
*/
*/
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
(function () {
(function () {
if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
{
{
throw ReactError(Error('EventPluginHub: More than one plugin attempted to publish the same event name, `' + eventName + '`.'));
throw ReactError(Error("EventPluginHub: More than one plugin attempted to publish the same event name, `" + eventName + "`."));
}
}
}
}
})();
})();
eventNameDispatchConfigs[eventName] = dispatchConfig;
eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
var phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
}
}
}
}
return true;
return true;
} else if (dispatchConfig.registrationName) {
} else if (dispatchConfig.registrationName) {
publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
return true;
return true;
}
}
return false;
return false;
}
}
/**
/**
* Publishes a registration name that is used to identify dispatched events.
* Publishes a registration name that is used to identify dispatched events.
*
*
* @param {string} registrationName Registration name to add.
* @param {string} registrationName Registration name to add.
* @param {object} PluginModule Plugin publishing the event.
* @param {object} PluginModule Plugin publishing the event.
* @private
* @private
*/
*/
function publishRegistrationName(registrationName, pluginModule, eventName) {
function publishRegistrationName(registrationName, pluginModule, eventName) {
(function () {
(function () {
if (!!registrationNameModules[registrationName]) {
if (!!registrationNameModules[registrationName]) {
{
{
throw ReactError(Error('EventPluginHub: More than one plugin attempted to publish the same registration name, `' + registrationName + '`.'));
throw ReactError(Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `" + registrationName + "`."));
}
}
}
}
})();
})();
registrationNameModules[registrationName] = pluginModule;
registrationNameModules[registrationName] = pluginModule;
registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
{
{
var lowerCasedName = registrationName.toLowerCase();
var lowerCasedName = registrationName.toLowerCase();
possibleRegistrationNames[lowerCasedName] = registrationName;
possibleRegistrationNames[lowerCasedName] = registrationName;
if (registrationName === 'onDoubleClick') {
if (registrationName === 'onDoubleClick') {
possibleRegistrationNames.ondblclick = registrationName;
possibleRegistrationNames.ondblclick = registrationName;
}
}
}
}
}
}
/**
/**
* Registers plugins so that they can extract and dispatch events.
* Registers plugins so that they can extract and dispatch events.
*
*
* @see {EventPluginHub}
* @see {EventPluginHub}
*/
*/
/**
/**
* Ordered list of injected plugins.
* Ordered list of injected plugins.
*/
*/
var plugins = [];
var plugins = [];
/**
/**
* Mapping from event name to dispatch config
* Mapping from event name to dispatch config
*/
*/
var eventNameDispatchConfigs = {};
var eventNameDispatchConfigs = {};
/**
/**
* Mapping from registration name to plugin module
* Mapping from registration name to plugin module
*/
*/
var registrationNameModules = {};
var registrationNameModules = {};
/**
/**
* Mapping from registration name to event name
* Mapping from registration name to event name
*/
*/
var registrationNameDependencies = {};
var registrationNameDependencies = {};
/**
/**
* Mapping from lowercase registration names to the properly cased version,
* Mapping from lowercase registration names to the properly cased version,
* used to warn in the case of missing event handlers. Available
* used to warn in the case of missing event handlers. Available
* only in true.
* only in true.
* @type {Object}
* @type {Object}
*/
*/
var possibleRegistrationNames = {};
var possibleRegistrationNames = {}; // Trust the developer to only use possibleRegistrationNames in true
// Trust the developer to only use possibleRegistrationNames in true
/**
/**
* Injects an ordering of plugins (by plugin name). This allows the ordering
* 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
* to be decoupled from injection of the actual plugins so that ordering is
* always deterministic regardless of packaging, on-the-fly injection, etc.
* always deterministic regardless of packaging, on-the-fly injection, etc.
*
*
* @param {array} InjectedEventPluginOrder
* @param {array} InjectedEventPluginOrder
* @internal
* @internal
* @see {EventPluginHub.injection.injectEventPluginOrder}
* @see {EventPluginHub.injection.injectEventPluginOrder}
*/
*/
function injectEventPluginOrder(injectedEventPluginOrder) {
function injectEventPluginOrder(injectedEventPluginOrder) {
(function () {
(function () {
if (!!eventPluginOrder) {
if (!!eventPluginOrder) {
{
{
throw ReactError(Error('EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.'));
throw ReactError(Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."));
}
}
}
}
})();
})(); // Clone the ordering so it cannot be dynamically mutated.
// Clone the ordering so it cannot be dynamically mutated.
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
recomputePluginOrdering();
recomputePluginOrdering();
}
}
/**
/**
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
* in the ordering injected by `injectEventPluginOrder`.
* in the ordering injected by `injectEventPluginOrder`.
*
*
* Plugins can be injected as part of page initialization or on-the-fly.
* Plugins can be injected as part of page initialization or on-the-fly.
*
*
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
* @internal
* @internal
* @see {EventPluginHub.injection.injectEventPluginsByName}
* @see {EventPluginHub.injection.injectEventPluginsByName}
*/
*/
function injectEventPluginsByName(injectedNamesToPlugins) {
function injectEventPluginsByName(injectedNamesToPlugins) {
var isOrderingDirty = false;
var isOrderingDirty = false;
for (var pluginName in injectedNamesToPlugins) {
for (var pluginName in injectedNamesToPlugins) {
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
continue;
continue;
}
}
var pluginModule = injectedNamesToPlugins[pluginName];
var pluginModule = injectedNamesToPlugins[pluginName];
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
(function () {
(function () {
if (!!namesToPlugins[pluginName]) {
if (!!namesToPlugins[pluginName]) {
{
{
throw ReactError(Error('EventPluginRegistry: Cannot inject two different event plugins using the same name, `' + pluginName + '`.'));
throw ReactError(Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`."));
}
}
}
}
})();
})();
namesToPlugins[pluginName] = pluginModule;
namesToPlugins[pluginName] = pluginModule;
isOrderingDirty = true;
isOrderingDirty = true;
}
}
}
}
if (isOrderingDirty) {
if (isOrderingDirty) {
recomputePluginOrdering();
recomputePluginOrdering();
}
}
}
}
var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
var funcArgs = Array.prototype.slice.call(arguments, 3);
var funcArgs = Array.prototype.slice.call(arguments, 3);
try {
try {
func.apply(context, funcArgs);
func.apply(context, funcArgs);
} catch (error) {
} catch (error) {
this.onError(error);
this.onError(error);
}
}
};
};
{
{
// In DEV mode, we swap out invokeGuardedCallback for a special version
// 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
// that plays more nicely with the browser's DevTools. The idea is to preserve
// "Pause on exceptions" behavior. Because React wraps all user-provided
// "Pause on exceptions" behavior. Because React wraps all user-provided
// functions in invokeGuardedCallback, and the production version of
// functions in invokeGuardedCallback, and the production version of
// invokeGuardedCallback uses a try-catch, all user exceptions are treated
// invokeGuardedCallback uses a try-catch, all user exceptions are treated
// like caught exceptions, and the DevTools won't pause unless the developer
// like caught exceptions, and the DevTools won't pause unless the developer
// takes the extra step of enabling pause on caught exceptions. This is
// takes the extra step of enabling pause on caught exceptions. This is
// unintuitive, though, because even though React has caught the error, from
// unintuitive, though, because even though React has caught the error, from
// the developer's perspective, the error is uncaught.
// the developer's perspective, the error is uncaught.
//
//
// To preserve the expected "Pause on exceptions" behavior, we don't use a
// To preserve the expected "Pause on exceptions" behavior, we don't use a
// try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
// try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
// DOM node, and call the user-provided callback from inside an event handler
// DOM node, and call the user-provided callback from inside an event handler
// for that fake event. If the callback throws, the error is "captured" using
// for that fake event. If the callback throws, the error is "captured" using
// a global event handler. But because the error happens in a different
// a global event handler. But because the error happens in a different
// event loop context, it does not interrupt the normal program flow.
// event loop context, it does not interrupt the normal program flow.
// Effectively, this gives us try-catch behavior without actually using
// Effectively, this gives us try-catch behavior without actually using
// try-catch. Neat!
// try-catch. Neat!
// Check that the browser supports the APIs we need to implement our special
// Check that the browser supports the APIs we need to implement our special
// DEV version of invokeGuardedCallback
// DEV version of invokeGuardedCallback
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
var fakeNode = document.createElement('react');
var fakeNode = document.createElement('react');
var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
// If document doesn't exist we know for sure we will crash in this method
// If document doesn't exist we know for sure we will crash in this method
// when we call document.createEvent(). However this can cause confusing
// when we call document.createEvent(). However this can cause confusing
// errors: https://github.com/facebookincubator/create-react-app/issues/3482
// errors: https://github.com/facebookincubator/create-react-app/issues/3482
// So we preemptively throw with a better message instead.
// So we preemptively throw with a better message instead.
(function () {
(function () {
if (!(typeof document !== 'undefined')) {
if (!(typeof document !== 'undefined')) {
{
{
throw ReactError(Error('The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.'));
throw ReactError(Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."));
}
}
}
}
})();
})();
var evt = document.createEvent('Event');
var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
// 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
// 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
// calling the function. If the function errors, `didError` will never be
// set to false. This strategy works even if the browser is flaky and
// 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
// fails to call our global error handler, because it doesn't rely on
// the error event at all.
// the error event at all.
var didError = true;
var didError = true; // Keeps track of the value of window.event so that we can reset it
// Keeps track of the value of window.event so that we can reset it
// during the callback to let user code access window.event in the
// during the callback to let user code access window.event in the
// browsers that support it.
// browsers that support it.
var windowEvent = window.event;
var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
// Keeps track of the descriptor of window.event to restore it after event
// dispatching: https://github.com/facebook/react/issues/13688
// dispatching: https://github.com/facebook/react/issues/13688
var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
// Create an event handler for our fake event. We will synchronously
// dispatch our fake event using `dispatchEvent`. Inside the handler, we
// dispatch our fake event using `dispatchEvent`. Inside the handler, we
// call the user-provided callback.
// call the user-provided callback.
var funcArgs = Array.prototype.slice.call(arguments, 3);
var funcArgs = Array.prototype.slice.call(arguments, 3);
function callCallback() {
function callCallback() {
// We immediately remove the callback from event listeners so that
// We immediately remove the callback from event listeners so that
// nested `invokeGuardedCallback` calls do not clash. Otherwise, a
// nested `invokeGuardedCallback` calls do not clash. Otherwise, a
// nested call would trigger the fake event handlers of any call higher
// nested call would trigger the fake event handlers of any call higher
// in the stack.
// in the stack.
fakeNode.removeEventListener(evtType, callCallback, false);
fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
// We check for window.hasOwnProperty('event') to prevent the
// window.event assignment in both IE <= 10 as they throw an error
// window.event assignment in both IE <= 10 as they throw an error
// "Member not found" in strict mode, and in Firefox which does not
// "Member not found" in strict mode, and in Firefox which does not
// support window.event.
// support window.event.
if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
window.event = windowEvent;
window.event = windowEvent;
}
}
func.apply(context, funcArgs);
func.apply(context, funcArgs);
didError = false;
didError = false;
}
} // Create a global error event handler. We use this to capture the value
// 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
// that was thrown. It's possible that this error handler will fire more
// than once; for example, if non-React code also calls `dispatchEvent`
// 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
// 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
// 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,
// 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
// 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
// possible for anything else to have happened in between our callback
// erroring and the code that follows the `dispatchEvent` call below. If
// 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
// the callback doesn't error, but the error event was fired, we know to
// ignore it because `didError` will be false, as described above.
// ignore it because `didError` will be false, as described above.
var error = void 0;
var error; // Use this to track whether the error event is ever called.
// Use this to track whether the error event is ever called.
var didSetError = false;
var didSetError = false;
var isCrossOriginError = false;
var isCrossOriginError = false;
function handleWindowError(event) {
function handleWindowError(event) {
error = event.error;
error = event.error;
didSetError = true;
didSetError = true;
if (error === null && event.colno === 0 && event.lineno === 0) {
if (error === null && event.colno === 0 && event.lineno === 0) {
isCrossOriginError = true;
isCrossOriginError = true;
}
}
if (event.defaultPrevented) {
if (event.defaultPrevented) {
// Some other error handler has prevented default.
// Some other error handler has prevented default.
// Browsers silence the error report if this happens.
// Browsers silence the error report if this happens.
// We'll remember this to later decide whether to log it or not.
// We'll remember this to later decide whether to log it or not.
if (error != null && typeof error === 'object') {
if (error != null && typeof error === 'object') {
try {
try {
error._suppressLogging = true;
error._suppressLogging = true;
} catch (inner) {
} catch (inner) {// Ignore.
// Ignore.
}
}
}
}
}
}
}
} // Create a fake event type.
// Create a fake event type.
var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
// Attach our event handlers
window.addEventListener('error', handleWindowError);
window.addEventListener('error', handleWindowError);
fakeNode.addEventListener(evtType, callCallback, false);
fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
// Synchronously dispatch our fake event. If the user-provided function
// errors, it will trigger our global error handler.
// errors, it will trigger our global error handler.
evt.initEvent(evtType, false, false);
evt.initEvent(evtType, false, false);
fakeNode.dispatchEvent(evt);
fakeNode.dispatchEvent(evt);
if (windowEventDescriptor) {
if (windowEventDescriptor) {
Object.defineProperty(window, 'event', windowEventDescriptor);
Object.defineProperty(window, 'event', windowEventDescriptor);
}
}
if (didError) {
if (didError) {
if (!didSetError) {
if (!didSetError) {
// The callback errored, but the error event never fired.
// 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.');
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) {
} 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.');
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.');
}
}
this.onError(error);
this.onError(error);
}
} // Remove our event listeners
// Remove our event listeners
window.removeEventListener('error', handleWindowError);
window.removeEventListener('error', handleWindowError);
};
};
invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
}
}
}
}
var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
// Used by Fiber to simulate a try-catch.
var hasError = false;
var hasError = false;
var caughtError = null;
var caughtError = null; // Used by event system to capture/rethrow the first error.
// Used by event system to capture/rethrow the first error.
var hasRethrowError = false;
var hasRethrowError = false;
var rethrowError = null;
var rethrowError = null;
var reporter = {
var reporter = {
onError: function (error) {
onError: function (error) {
hasError = true;
hasError = true;
caughtError = error;
caughtError = error;
}
}
};
};
/**
/**
* Call a function while guarding against errors that happens within it.
* Call a function while guarding against errors that happens within it.
* Returns an error if it throws, otherwise null.
* Returns an error if it throws, otherwise null.
*
*
* In production, this is implemented using a try-catch. The reason we don't
* 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
* use a try-catch directly is so that we can swap out a different
* implementation in DEV mode.
* implementation in DEV mode.
*
*
* @param {String} name of the guard to use for logging or debugging
* @param {String} name of the guard to use for logging or debugging
* @param {Function} func The function to invoke
* @param {Function} func The function to invoke
* @param {*} context The context to use when calling the function
* @param {*} context The context to use when calling the function
* @param {...*} args Arguments for function
* @param {...*} args Arguments for function
*/
*/
function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
hasError = false;
hasError = false;
caughtError = null;
caughtError = null;
invokeGuardedCallbackImpl$1.apply(reporter, arguments);
invokeGuardedCallbackImpl$1.apply(reporter, arguments);
}
}
/**
/**
* Same as invokeGuardedCallback, but instead of returning an error, it stores
* Same as invokeGuardedCallback, but instead of returning an error, it stores
* it in a global so it can be rethrown by `rethrowCaughtError` later.
* it in a global so it can be rethrown by `rethrowCaughtError` later.
* TODO: See if caughtError and rethrowError can be unified.
* TODO: See if caughtError and rethrowError can be unified.
*
*
* @param {String} name of the guard to use for logging or debugging
* @param {String} name of the guard to use for logging or debugging
* @param {Function} func The function to invoke
* @param {Function} func The function to invoke
* @param {*} context The context to use when calling the function
* @param {*} context The context to use when calling the function
* @param {...*} args Arguments for function
* @param {...*} args Arguments for function
*/
*/
function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
invokeGuardedCallback.apply(this, arguments);
invokeGuardedCallback.apply(this, arguments);
if (hasError) {
if (hasError) {
var error = clearCaughtError();
var error = clearCaughtError();
if (!hasRethrowError) {
if (!hasRethrowError) {
hasRethrowError = true;
hasRethrowError = true;
rethrowError = error;
rethrowError = error;
}
}
}
}
}
}
/**
/**
* During execution of guarded functions we will capture the first error which
* During execution of guarded functions we will capture the first error which
* we will rethrow to be handled by the top level error handler.
* we will rethrow to be handled by the top level error handler.
*/
*/
function rethrowCaughtError() {
function rethrowCaughtError() {
if (hasRethrowError) {
if (hasRethrowError) {
var error = rethrowError;
var error = rethrowError;
hasRethrowError = false;
hasRethrowError = false;
rethrowError = null;
rethrowError = null;
throw error;
throw error;
}
}
}
}
function hasCaughtError() {
function hasCaughtError() {
return hasError;
return hasError;
}
}
function clearCaughtError() {
function clearCaughtError() {
if (hasError) {
if (hasError) {
var error = caughtError;
var error = caughtError;
hasError = false;
hasError = false;
caughtError = null;
caughtError = null;
return error;
return error;
} else {
} else {
(function () {
(function () {
{
{
{
{
throw ReactError(Error('clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.'));
throw ReactError(Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."));
}
}
}
}
})();
})();
}
}
}
}
/**
/**
* Similar to invariant but only logs a warning if the condition is not met.
* 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
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
* same logic and follow the same code paths.
*/
*/
var warningWithoutStack = function () {};
var warningWithoutStack = function () {};
{
{
warningWithoutStack = function (condition, format) {
warningWithoutStack = function (condition, format) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
args[_key - 2] = arguments[_key];
}
}
if (format === undefined) {
if (format === undefined) {
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
}
}
if (args.length > 8) {
if (args.length > 8) {
// Check before the condition to catch violations early.
// Check before the condition to catch violations early.
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
}
}
if (condition) {
if (condition) {
return;
return;
}
}
if (typeof console !== 'undefined') {
if (typeof console !== 'undefined') {
var argsWithFormat = args.map(function (item) {
var argsWithFormat = args.map(function (item) {
return '' + item;
return '' + item;
});
});
argsWithFormat.unshift('Warning: ' + format);
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// breaks IE9: https://github.com/facebook/react/issues/13610
Function.prototype.apply.call(console.error, console, argsWithFormat);
Function.prototype.apply.call(console.error, console, argsWithFormat);
}
}
try {
try {
// --- Welcome to debugging React ---
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
// to find the callsite that caused this warning to fire.
var argIndex = 0;
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
return args[argIndex++];
});
});
throw new Error(message);
throw new Error(message);
} catch (x) {}
} catch (x) {}
};
};
}
}
var warningWithoutStack$1 = warningWithoutStack;
var warningWithoutStack$1 = warningWithoutStack;
var getFiberCurrentPropsFromNode = null;
var getFiberCurrentPropsFromNode = null;
var getInstanceFromNode = null;
var getInstanceFromNode = null;
var getNodeFromInstance = null;
var getNodeFromInstance = null;
function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
getInstanceFromNode = getInstanceFromNodeImpl;
getInstanceFromNode = getInstanceFromNodeImpl;
getNodeFromInstance = getNodeFromInstanceImpl;
getNodeFromInstance = getNodeFromInstanceImpl;
{
{
!(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
!(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
}
}
}
}
var validateEventDispatches = void 0;
var validateEventDispatches;
{
{
validateEventDispatches = function (event) {
validateEventDispatches = function (event) {
var dispatchListeners = event._dispatchListeners;
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
var dispatchInstances = event._dispatchInstances;
var listenersIsArr = Array.isArray(dispatchListeners);
var listenersIsArr = Array.isArray(dispatchListeners);
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
var instancesIsArr = Array.isArray(dispatchInstances);
var instancesIsArr = Array.isArray(dispatchInstances);
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
!(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
!(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
};
};
}
}
/**
/**
* Dispatch the event to the listener.
* Dispatch the event to the listener.
* @param {SyntheticEvent} event SyntheticEvent to handle
* @param {SyntheticEvent} event SyntheticEvent to handle
* @param {function} listener Application-level callback
* @param {function} listener Application-level callback
* @param {*} inst Internal component instance
* @param {*} inst Internal component instance
*/
*/
function executeDispatch(event, listener, inst) {
function executeDispatch(event, listener, inst) {
var type = event.type || 'unknown-event';
var type = event.type || 'unknown-event';
event.currentTarget = getNodeFromInstance(inst);
event.currentTarget = getNodeFromInstance(inst);
invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
event.currentTarget = null;
event.currentTarget = null;
}
}
/**
/**
* Standard/simple iteration through an event's collected dispatches.
* Standard/simple iteration through an event's collected dispatches.
*/
*/
function executeDispatchesInOrder(event) {
function executeDispatchesInOrder(event) {
var dispatchListeners = event._dispatchListeners;
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
var dispatchInstances = event._dispatchInstances;
{
{
validateEventDispatches(event);
validateEventDispatches(event);
}
}
if (Array.isArray(dispatchListeners)) {
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
for (var i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
if (event.isPropagationStopped()) {
break;
break;
}
} // Listeners and Instances are two parallel arrays that are always in sync.
// Listeners and Instances are two parallel arrays that are always in sync.
executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
}
}
} else if (dispatchListeners) {
} else if (dispatchListeners) {
executeDispatch(event, dispatchListeners, dispatchInstances);
executeDispatch(event, dispatchListeners, dispatchInstances);
}
}
event._dispatchListeners = null;
event._dispatchListeners = null;
event._dispatchInstances = null;
event._dispatchInstances = null;
}
}
/**
/**
* @see executeDispatchesInOrderStopAtTrueImpl
* @see executeDispatchesInOrderStopAtTrueImpl
*/
*/
/**
/**
* Execution of a "direct" dispatch - there must be at most one dispatch
* Execution of a "direct" dispatch - there must be at most one dispatch
* accumulated on the event or it is considered an error. It doesn't really make
* accumulated on the event or it is considered an error. It doesn't really make
* sense for an event with multiple dispatches (bubbled) to keep track of the
* sense for an event with multiple dispatches (bubbled) to keep track of the
* return values at each dispatch execution, but it does tend to make sense when
* return values at each dispatch execution, but it does tend to make sense when
* dealing with "direct" dispatches.
* dealing with "direct" dispatches.
*
*
* @return {*} The return value of executing the single dispatch.
* @return {*} The return value of executing the single dispatch.
*/
*/
/**
/**
* @param {SyntheticEvent} event
* @param {SyntheticEvent} event
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
*/
*/
/**
/**
* Accumulates items that must not be null or undefined into the first one. This
* Accumulates items that must not be null or undefined into the first one. This
* is used to conserve memory by avoiding array allocations, and thus sacrifices
* is used to conserve memory by avoiding array allocations, and thus sacrifices
* API cleanness. Since `current` can be null before being passed in and not
* API cleanness. Since `current` can be null before being passed in and not
* null after this function, make sure to assign it back to `current`:
* null after this function, make sure to assign it back to `current`:
*
*
* `a = accumulateInto(a, b);`
* `a = accumulateInto(a, b);`
*
*
* This API should be sparingly used. Try `accumulate` for something cleaner.
* This API should be sparingly used. Try `accumulate` for something cleaner.
*
*
* @return {*|array<*>} An accumulation of items.
* @return {*|array<*>} An accumulation of items.
*/
*/
function accumulateInto(current, next) {
function accumulateInto(current, next) {
(function () {
(function () {
if (!(next != null)) {
if (!(next != null)) {
{
{
throw ReactError(Error('accumulateInto(...): Accumulated items must not be null or undefined.'));
throw ReactError(Error("accumulateInto(...): Accumulated items must not be null or undefined."));
}
}
}
}
})();
})();
if (current == null) {
if (current == null) {
return next;
return next;
}
} // Both are not empty. Warning: Never call x.concat(y) when you are not
// Both are not empty. Warning: Never call x.concat(y) when you are not
// certain that x is an Array (x could be a string with concat method).
// certain that x is an Array (x could be a string with concat method).
if (Array.isArray(current)) {
if (Array.isArray(current)) {
if (Array.isArray(next)) {
if (Array.isArray(next)) {
current.push.apply(current, next);
current.push.apply(current, next);
return current;
return current;
}
}
current.push(next);
current.push(next);
return current;
return current;
}
}
if (Array.isArray(next)) {
if (Array.isArray(next)) {
// A bit too dangerous to mutate `next`.
// A bit too dangerous to mutate `next`.
return [current].concat(next);
return [current].concat(next);
}
}
return [current, n
return [current, next];
}
/**
* @param {array} arr an "accumulation" of items which is either an Array or
* a single item. Useful when paired with the `accumulate` m