github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/internal/testutils/testutils.inc.js (about) 1 (function(e, a) { for(var i in a) e[i] = a[i]; }(this, /******/ (function(modules) { // webpackBootstrap 2 /******/ // The module cache 3 /******/ var installedModules = {}; 4 /******/ 5 /******/ // The require function 6 /******/ function __webpack_require__(moduleId) { 7 /******/ 8 /******/ // Check if module is in cache 9 /******/ if(installedModules[moduleId]) { 10 /******/ return installedModules[moduleId].exports; 11 /******/ } 12 /******/ // Create a new module (and put it into the cache) 13 /******/ var module = installedModules[moduleId] = { 14 /******/ i: moduleId, 15 /******/ l: false, 16 /******/ exports: {} 17 /******/ }; 18 /******/ 19 /******/ // Execute the module function 20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 /******/ 22 /******/ // Flag the module as loaded 23 /******/ module.l = true; 24 /******/ 25 /******/ // Return the exports of the module 26 /******/ return module.exports; 27 /******/ } 28 /******/ 29 /******/ 30 /******/ // expose the modules object (__webpack_modules__) 31 /******/ __webpack_require__.m = modules; 32 /******/ 33 /******/ // expose the module cache 34 /******/ __webpack_require__.c = installedModules; 35 /******/ 36 /******/ // define getter function for harmony exports 37 /******/ __webpack_require__.d = function(exports, name, getter) { 38 /******/ if(!__webpack_require__.o(exports, name)) { 39 /******/ Object.defineProperty(exports, name, { 40 /******/ configurable: false, 41 /******/ enumerable: true, 42 /******/ get: getter 43 /******/ }); 44 /******/ } 45 /******/ }; 46 /******/ 47 /******/ // getDefaultExport function for compatibility with non-harmony modules 48 /******/ __webpack_require__.n = function(module) { 49 /******/ var getter = module && module.__esModule ? 50 /******/ function getDefault() { return module['default']; } : 51 /******/ function getModuleExports() { return module; }; 52 /******/ __webpack_require__.d(getter, 'a', getter); 53 /******/ return getter; 54 /******/ }; 55 /******/ 56 /******/ // Object.prototype.hasOwnProperty.call 57 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 /******/ 59 /******/ // __webpack_public_path__ 60 /******/ __webpack_require__.p = ""; 61 /******/ 62 /******/ // Load entry module and return exports 63 /******/ return __webpack_require__(__webpack_require__.s = 15); 64 /******/ }) 65 /************************************************************************/ 66 /******/ ([ 67 /* 0 */ 68 /***/ (function(module, exports) { 69 70 // shim for using process in browser 71 var process = module.exports = {}; 72 73 // cached from whatever global is present so that test runners that stub it 74 // don't break things. But we need to wrap it in a try catch in case it is 75 // wrapped in strict mode code which doesn't define any globals. It's inside a 76 // function because try/catches deoptimize in certain engines. 77 78 var cachedSetTimeout; 79 var cachedClearTimeout; 80 81 function defaultSetTimout() { 82 throw new Error('setTimeout has not been defined'); 83 } 84 function defaultClearTimeout () { 85 throw new Error('clearTimeout has not been defined'); 86 } 87 (function () { 88 try { 89 if (typeof setTimeout === 'function') { 90 cachedSetTimeout = setTimeout; 91 } else { 92 cachedSetTimeout = defaultSetTimout; 93 } 94 } catch (e) { 95 cachedSetTimeout = defaultSetTimout; 96 } 97 try { 98 if (typeof clearTimeout === 'function') { 99 cachedClearTimeout = clearTimeout; 100 } else { 101 cachedClearTimeout = defaultClearTimeout; 102 } 103 } catch (e) { 104 cachedClearTimeout = defaultClearTimeout; 105 } 106 } ()) 107 function runTimeout(fun) { 108 if (cachedSetTimeout === setTimeout) { 109 //normal enviroments in sane situations 110 return setTimeout(fun, 0); 111 } 112 // if setTimeout wasn't available but was latter defined 113 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 114 cachedSetTimeout = setTimeout; 115 return setTimeout(fun, 0); 116 } 117 try { 118 // when when somebody has screwed with setTimeout but no I.E. maddness 119 return cachedSetTimeout(fun, 0); 120 } catch(e){ 121 try { 122 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 123 return cachedSetTimeout.call(null, fun, 0); 124 } catch(e){ 125 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 126 return cachedSetTimeout.call(this, fun, 0); 127 } 128 } 129 130 131 } 132 function runClearTimeout(marker) { 133 if (cachedClearTimeout === clearTimeout) { 134 //normal enviroments in sane situations 135 return clearTimeout(marker); 136 } 137 // if clearTimeout wasn't available but was latter defined 138 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 139 cachedClearTimeout = clearTimeout; 140 return clearTimeout(marker); 141 } 142 try { 143 // when when somebody has screwed with setTimeout but no I.E. maddness 144 return cachedClearTimeout(marker); 145 } catch (e){ 146 try { 147 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 148 return cachedClearTimeout.call(null, marker); 149 } catch (e){ 150 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 151 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 152 return cachedClearTimeout.call(this, marker); 153 } 154 } 155 156 157 158 } 159 var queue = []; 160 var draining = false; 161 var currentQueue; 162 var queueIndex = -1; 163 164 function cleanUpNextTick() { 165 if (!draining || !currentQueue) { 166 return; 167 } 168 draining = false; 169 if (currentQueue.length) { 170 queue = currentQueue.concat(queue); 171 } else { 172 queueIndex = -1; 173 } 174 if (queue.length) { 175 drainQueue(); 176 } 177 } 178 179 function drainQueue() { 180 if (draining) { 181 return; 182 } 183 var timeout = runTimeout(cleanUpNextTick); 184 draining = true; 185 186 var len = queue.length; 187 while(len) { 188 currentQueue = queue; 189 queue = []; 190 while (++queueIndex < len) { 191 if (currentQueue) { 192 currentQueue[queueIndex].run(); 193 } 194 } 195 queueIndex = -1; 196 len = queue.length; 197 } 198 currentQueue = null; 199 draining = false; 200 runClearTimeout(timeout); 201 } 202 203 process.nextTick = function (fun) { 204 var args = new Array(arguments.length - 1); 205 if (arguments.length > 1) { 206 for (var i = 1; i < arguments.length; i++) { 207 args[i - 1] = arguments[i]; 208 } 209 } 210 queue.push(new Item(fun, args)); 211 if (queue.length === 1 && !draining) { 212 runTimeout(drainQueue); 213 } 214 }; 215 216 // v8 likes predictible objects 217 function Item(fun, array) { 218 this.fun = fun; 219 this.array = array; 220 } 221 Item.prototype.run = function () { 222 this.fun.apply(null, this.array); 223 }; 224 process.title = 'browser'; 225 process.browser = true; 226 process.env = {}; 227 process.argv = []; 228 process.version = ''; // empty string to avoid regexp issues 229 process.versions = {}; 230 231 function noop() {} 232 233 process.on = noop; 234 process.addListener = noop; 235 process.once = noop; 236 process.off = noop; 237 process.removeListener = noop; 238 process.removeAllListeners = noop; 239 process.emit = noop; 240 process.prependListener = noop; 241 process.prependOnceListener = noop; 242 243 process.listeners = function (name) { return [] } 244 245 process.binding = function (name) { 246 throw new Error('process.binding is not supported'); 247 }; 248 249 process.cwd = function () { return '/' }; 250 process.chdir = function (dir) { 251 throw new Error('process.chdir is not supported'); 252 }; 253 process.umask = function() { return 0; }; 254 255 256 /***/ }), 257 /* 1 */ 258 /***/ (function(module, exports, __webpack_require__) { 259 260 "use strict"; 261 262 263 /** 264 * Copyright (c) 2013-present, Facebook, Inc. 265 * 266 * This source code is licensed under the MIT license found in the 267 * LICENSE file in the root directory of this source tree. 268 * 269 * 270 */ 271 272 function makeEmptyFunction(arg) { 273 return function () { 274 return arg; 275 }; 276 } 277 278 /** 279 * This function accepts and discards inputs; it has no side effects. This is 280 * primarily useful idiomatically for overridable function endpoints which 281 * always need to be callable, since JS lacks a null-call idiom ala Cocoa. 282 */ 283 var emptyFunction = function emptyFunction() {}; 284 285 emptyFunction.thatReturns = makeEmptyFunction; 286 emptyFunction.thatReturnsFalse = makeEmptyFunction(false); 287 emptyFunction.thatReturnsTrue = makeEmptyFunction(true); 288 emptyFunction.thatReturnsNull = makeEmptyFunction(null); 289 emptyFunction.thatReturnsThis = function () { 290 return this; 291 }; 292 emptyFunction.thatReturnsArgument = function (arg) { 293 return arg; 294 }; 295 296 module.exports = emptyFunction; 297 298 /***/ }), 299 /* 2 */ 300 /***/ (function(module, exports, __webpack_require__) { 301 302 "use strict"; 303 /* 304 object-assign 305 (c) Sindre Sorhus 306 @license MIT 307 */ 308 309 310 /* eslint-disable no-unused-vars */ 311 var getOwnPropertySymbols = Object.getOwnPropertySymbols; 312 var hasOwnProperty = Object.prototype.hasOwnProperty; 313 var propIsEnumerable = Object.prototype.propertyIsEnumerable; 314 315 function toObject(val) { 316 if (val === null || val === undefined) { 317 throw new TypeError('Object.assign cannot be called with null or undefined'); 318 } 319 320 return Object(val); 321 } 322 323 function shouldUseNative() { 324 try { 325 if (!Object.assign) { 326 return false; 327 } 328 329 // Detect buggy property enumeration order in older V8 versions. 330 331 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 332 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 333 test1[5] = 'de'; 334 if (Object.getOwnPropertyNames(test1)[0] === '5') { 335 return false; 336 } 337 338 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 339 var test2 = {}; 340 for (var i = 0; i < 10; i++) { 341 test2['_' + String.fromCharCode(i)] = i; 342 } 343 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 344 return test2[n]; 345 }); 346 if (order2.join('') !== '0123456789') { 347 return false; 348 } 349 350 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 351 var test3 = {}; 352 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 353 test3[letter] = letter; 354 }); 355 if (Object.keys(Object.assign({}, test3)).join('') !== 356 'abcdefghijklmnopqrst') { 357 return false; 358 } 359 360 return true; 361 } catch (err) { 362 // We don't expect any of the above to throw, but better to be safe. 363 return false; 364 } 365 } 366 367 module.exports = shouldUseNative() ? Object.assign : function (target, source) { 368 var from; 369 var to = toObject(target); 370 var symbols; 371 372 for (var s = 1; s < arguments.length; s++) { 373 from = Object(arguments[s]); 374 375 for (var key in from) { 376 if (hasOwnProperty.call(from, key)) { 377 to[key] = from[key]; 378 } 379 } 380 381 if (getOwnPropertySymbols) { 382 symbols = getOwnPropertySymbols(from); 383 for (var i = 0; i < symbols.length; i++) { 384 if (propIsEnumerable.call(from, symbols[i])) { 385 to[symbols[i]] = from[symbols[i]]; 386 } 387 } 388 } 389 } 390 391 return to; 392 }; 393 394 395 /***/ }), 396 /* 3 */ 397 /***/ (function(module, exports, __webpack_require__) { 398 399 "use strict"; 400 /* WEBPACK VAR INJECTION */(function(process) { 401 402 if (process.env.NODE_ENV === 'production') { 403 module.exports = __webpack_require__(18); 404 } else { 405 module.exports = __webpack_require__(19); 406 } 407 408 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 409 410 /***/ }), 411 /* 4 */ 412 /***/ (function(module, exports, __webpack_require__) { 413 414 "use strict"; 415 /* WEBPACK VAR INJECTION */(function(process) {/** 416 * Copyright (c) 2013-present, Facebook, Inc. 417 * 418 * This source code is licensed under the MIT license found in the 419 * LICENSE file in the root directory of this source tree. 420 * 421 */ 422 423 424 425 var emptyObject = {}; 426 427 if (process.env.NODE_ENV !== 'production') { 428 Object.freeze(emptyObject); 429 } 430 431 module.exports = emptyObject; 432 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 433 434 /***/ }), 435 /* 5 */ 436 /***/ (function(module, exports, __webpack_require__) { 437 438 "use strict"; 439 /* WEBPACK VAR INJECTION */(function(process) {/** 440 * Copyright (c) 2013-present, Facebook, Inc. 441 * 442 * This source code is licensed under the MIT license found in the 443 * LICENSE file in the root directory of this source tree. 444 * 445 */ 446 447 448 449 /** 450 * Use invariant() to assert state which your program assumes to be true. 451 * 452 * Provide sprintf-style format (only %s is supported) and arguments 453 * to provide information about what broke and what you were 454 * expecting. 455 * 456 * The invariant message will be stripped in production, but the invariant 457 * will remain to ensure logic does not differ in production. 458 */ 459 460 var validateFormat = function validateFormat(format) {}; 461 462 if (process.env.NODE_ENV !== 'production') { 463 validateFormat = function validateFormat(format) { 464 if (format === undefined) { 465 throw new Error('invariant requires an error message argument'); 466 } 467 }; 468 } 469 470 function invariant(condition, format, a, b, c, d, e, f) { 471 validateFormat(format); 472 473 if (!condition) { 474 var error; 475 if (format === undefined) { 476 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); 477 } else { 478 var args = [a, b, c, d, e, f]; 479 var argIndex = 0; 480 error = new Error(format.replace(/%s/g, function () { 481 return args[argIndex++]; 482 })); 483 error.name = 'Invariant Violation'; 484 } 485 486 error.framesToPop = 1; // we don't care about invariant's own frame 487 throw error; 488 } 489 } 490 491 module.exports = invariant; 492 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 493 494 /***/ }), 495 /* 6 */ 496 /***/ (function(module, exports, __webpack_require__) { 497 498 "use strict"; 499 /* WEBPACK VAR INJECTION */(function(process) {/** 500 * Copyright (c) 2014-present, Facebook, Inc. 501 * 502 * This source code is licensed under the MIT license found in the 503 * LICENSE file in the root directory of this source tree. 504 * 505 */ 506 507 508 509 var emptyFunction = __webpack_require__(1); 510 511 /** 512 * Similar to invariant but only logs a warning if the condition is not met. 513 * This can be used to log issues in development environments in critical 514 * paths. Removing the logging code for production environments will keep the 515 * same logic and follow the same code paths. 516 */ 517 518 var warning = emptyFunction; 519 520 if (process.env.NODE_ENV !== 'production') { 521 var printWarning = function printWarning(format) { 522 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 523 args[_key - 1] = arguments[_key]; 524 } 525 526 var argIndex = 0; 527 var message = 'Warning: ' + format.replace(/%s/g, function () { 528 return args[argIndex++]; 529 }); 530 if (typeof console !== 'undefined') { 531 console.error(message); 532 } 533 try { 534 // --- Welcome to debugging React --- 535 // This error was thrown as a convenience so that you can use this stack 536 // to find the callsite that caused this warning to fire. 537 throw new Error(message); 538 } catch (x) {} 539 }; 540 541 warning = function warning(condition, format) { 542 if (format === undefined) { 543 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 544 } 545 546 if (format.indexOf('Failed Composite propType: ') === 0) { 547 return; // Ignore CompositeComponent proptype check. 548 } 549 550 if (!condition) { 551 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 552 args[_key2 - 2] = arguments[_key2]; 553 } 554 555 printWarning.apply(undefined, [format].concat(args)); 556 } 557 }; 558 } 559 560 module.exports = warning; 561 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 562 563 /***/ }), 564 /* 7 */ 565 /***/ (function(module, exports, __webpack_require__) { 566 567 "use strict"; 568 /** 569 * Copyright (c) 2013-present, Facebook, Inc. 570 * 571 * This source code is licensed under the MIT license found in the 572 * LICENSE file in the root directory of this source tree. 573 * 574 */ 575 576 577 578 var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); 579 580 /** 581 * Simple, lightweight module assisting with the detection and context of 582 * Worker. Helps avoid circular dependencies and allows code to reason about 583 * whether or not they are in a Worker, even if they never include the main 584 * `ReactWorker` dependency. 585 */ 586 var ExecutionEnvironment = { 587 588 canUseDOM: canUseDOM, 589 590 canUseWorkers: typeof Worker !== 'undefined', 591 592 canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), 593 594 canUseViewport: canUseDOM && !!window.screen, 595 596 isInWorker: !canUseDOM // For now, this is true - might change in the future. 597 598 }; 599 600 module.exports = ExecutionEnvironment; 601 602 /***/ }), 603 /* 8 */ 604 /***/ (function(module, exports, __webpack_require__) { 605 606 "use strict"; 607 /* WEBPACK VAR INJECTION */(function(process) {/** 608 * Copyright (c) 2013-present, Facebook, Inc. 609 * 610 * This source code is licensed under the MIT license found in the 611 * LICENSE file in the root directory of this source tree. 612 */ 613 614 615 616 if (process.env.NODE_ENV !== 'production') { 617 var invariant = __webpack_require__(5); 618 var warning = __webpack_require__(6); 619 var ReactPropTypesSecret = __webpack_require__(20); 620 var loggedTypeFailures = {}; 621 } 622 623 /** 624 * Assert that the values match with the type specs. 625 * Error messages are memorized and will only be shown once. 626 * 627 * @param {object} typeSpecs Map of name to a ReactPropType 628 * @param {object} values Runtime values that need to be type-checked 629 * @param {string} location e.g. "prop", "context", "child context" 630 * @param {string} componentName Name of the component for error messages. 631 * @param {?Function} getStack Returns the component stack. 632 * @private 633 */ 634 function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 635 if (process.env.NODE_ENV !== 'production') { 636 for (var typeSpecName in typeSpecs) { 637 if (typeSpecs.hasOwnProperty(typeSpecName)) { 638 var error; 639 // Prop type validation may throw. In case they do, we don't want to 640 // fail the render phase where it didn't fail before. So we log it. 641 // After these have been cleaned up, we'll let them throw. 642 try { 643 // This is intentionally an invariant that gets caught. It's the same 644 // behavior as without this statement except with a better message. 645 invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); 646 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 647 } catch (ex) { 648 error = ex; 649 } 650 warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); 651 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 652 // Only monitor this failure once because there tends to be a lot of the 653 // same error. 654 loggedTypeFailures[error.message] = true; 655 656 var stack = getStack ? getStack() : ''; 657 658 warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); 659 } 660 } 661 } 662 } 663 } 664 665 module.exports = checkPropTypes; 666 667 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 668 669 /***/ }), 670 /* 9 */ 671 /***/ (function(module, exports, __webpack_require__) { 672 673 "use strict"; 674 /* WEBPACK VAR INJECTION */(function(process) { 675 676 function checkDCE() { 677 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 678 if ( 679 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 680 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 681 ) { 682 return; 683 } 684 if (process.env.NODE_ENV !== 'production') { 685 // This branch is unreachable because this function is only called 686 // in production, but the condition is true only in development. 687 // Therefore if the branch is still here, dead code elimination wasn't 688 // properly applied. 689 // Don't change the message. React DevTools relies on it. Also make sure 690 // this message doesn't occur elsewhere in this function, or it will cause 691 // a false positive. 692 throw new Error('^_^'); 693 } 694 try { 695 // Verify that the code above has been dead code eliminated (DCE'd). 696 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 697 } catch (err) { 698 // DevTools shouldn't crash React, no matter what. 699 // We should still report in case we break this code. 700 console.error(err); 701 } 702 } 703 704 if (process.env.NODE_ENV === 'production') { 705 // DCE check should happen before ReactDOM bundle executes so that 706 // DevTools can report bad minification during injection. 707 checkDCE(); 708 module.exports = __webpack_require__(21); 709 } else { 710 module.exports = __webpack_require__(24); 711 } 712 713 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 714 715 /***/ }), 716 /* 10 */ 717 /***/ (function(module, exports, __webpack_require__) { 718 719 "use strict"; 720 /* WEBPACK VAR INJECTION */(function(process) { 721 722 /** 723 * Copyright (c) 2013-present, Facebook, Inc. 724 * 725 * This source code is licensed under the MIT license found in the 726 * LICENSE file in the root directory of this source tree. 727 * 728 * @typechecks 729 */ 730 731 var emptyFunction = __webpack_require__(1); 732 733 /** 734 * Upstream version of event listener. Does not take into account specific 735 * nature of platform. 736 */ 737 var EventListener = { 738 /** 739 * Listen to DOM events during the bubble phase. 740 * 741 * @param {DOMEventTarget} target DOM element to register listener on. 742 * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. 743 * @param {function} callback Callback function. 744 * @return {object} Object with a `remove` method. 745 */ 746 listen: function listen(target, eventType, callback) { 747 if (target.addEventListener) { 748 target.addEventListener(eventType, callback, false); 749 return { 750 remove: function remove() { 751 target.removeEventListener(eventType, callback, false); 752 } 753 }; 754 } else if (target.attachEvent) { 755 target.attachEvent('on' + eventType, callback); 756 return { 757 remove: function remove() { 758 target.detachEvent('on' + eventType, callback); 759 } 760 }; 761 } 762 }, 763 764 /** 765 * Listen to DOM events during the capture phase. 766 * 767 * @param {DOMEventTarget} target DOM element to register listener on. 768 * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. 769 * @param {function} callback Callback function. 770 * @return {object} Object with a `remove` method. 771 */ 772 capture: function capture(target, eventType, callback) { 773 if (target.addEventListener) { 774 target.addEventListener(eventType, callback, true); 775 return { 776 remove: function remove() { 777 target.removeEventListener(eventType, callback, true); 778 } 779 }; 780 } else { 781 if (process.env.NODE_ENV !== 'production') { 782 console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); 783 } 784 return { 785 remove: emptyFunction 786 }; 787 } 788 }, 789 790 registerDefault: function registerDefault() {} 791 }; 792 793 module.exports = EventListener; 794 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 795 796 /***/ }), 797 /* 11 */ 798 /***/ (function(module, exports, __webpack_require__) { 799 800 "use strict"; 801 802 803 /** 804 * Copyright (c) 2013-present, Facebook, Inc. 805 * 806 * This source code is licensed under the MIT license found in the 807 * LICENSE file in the root directory of this source tree. 808 * 809 * @typechecks 810 */ 811 812 /* eslint-disable fb-www/typeof-undefined */ 813 814 /** 815 * Same as document.activeElement but wraps in a try-catch block. In IE it is 816 * not safe to call document.activeElement if there is nothing focused. 817 * 818 * The activeElement will be null only if the document or document body is not 819 * yet defined. 820 * 821 * @param {?DOMDocument} doc Defaults to current document. 822 * @return {?DOMElement} 823 */ 824 function getActiveElement(doc) /*?DOMElement*/{ 825 doc = doc || (typeof document !== 'undefined' ? document : undefined); 826 if (typeof doc === 'undefined') { 827 return null; 828 } 829 try { 830 return doc.activeElement || doc.body; 831 } catch (e) { 832 return doc.body; 833 } 834 } 835 836 module.exports = getActiveElement; 837 838 /***/ }), 839 /* 12 */ 840 /***/ (function(module, exports, __webpack_require__) { 841 842 "use strict"; 843 /** 844 * Copyright (c) 2013-present, Facebook, Inc. 845 * 846 * This source code is licensed under the MIT license found in the 847 * LICENSE file in the root directory of this source tree. 848 * 849 * @typechecks 850 * 851 */ 852 853 /*eslint-disable no-self-compare */ 854 855 856 857 var hasOwnProperty = Object.prototype.hasOwnProperty; 858 859 /** 860 * inlined Object.is polyfill to avoid requiring consumers ship their own 861 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 862 */ 863 function is(x, y) { 864 // SameValue algorithm 865 if (x === y) { 866 // Steps 1-5, 7-10 867 // Steps 6.b-6.e: +0 != -0 868 // Added the nonzero y check to make Flow happy, but it is redundant 869 return x !== 0 || y !== 0 || 1 / x === 1 / y; 870 } else { 871 // Step 6.a: NaN == NaN 872 return x !== x && y !== y; 873 } 874 } 875 876 /** 877 * Performs equality by iterating through keys on an object and returning false 878 * when any key has values which are not strictly equal between the arguments. 879 * Returns true when the values of all keys are strictly equal. 880 */ 881 function shallowEqual(objA, objB) { 882 if (is(objA, objB)) { 883 return true; 884 } 885 886 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 887 return false; 888 } 889 890 var keysA = Object.keys(objA); 891 var keysB = Object.keys(objB); 892 893 if (keysA.length !== keysB.length) { 894 return false; 895 } 896 897 // Test for A's keys different from B. 898 for (var i = 0; i < keysA.length; i++) { 899 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { 900 return false; 901 } 902 } 903 904 return true; 905 } 906 907 module.exports = shallowEqual; 908 909 /***/ }), 910 /* 13 */ 911 /***/ (function(module, exports, __webpack_require__) { 912 913 "use strict"; 914 915 916 /** 917 * Copyright (c) 2013-present, Facebook, Inc. 918 * 919 * This source code is licensed under the MIT license found in the 920 * LICENSE file in the root directory of this source tree. 921 * 922 * 923 */ 924 925 var isTextNode = __webpack_require__(22); 926 927 /*eslint-disable no-bitwise */ 928 929 /** 930 * Checks if a given DOM node contains or is another DOM node. 931 */ 932 function containsNode(outerNode, innerNode) { 933 if (!outerNode || !innerNode) { 934 return false; 935 } else if (outerNode === innerNode) { 936 return true; 937 } else if (isTextNode(outerNode)) { 938 return false; 939 } else if (isTextNode(innerNode)) { 940 return containsNode(outerNode, innerNode.parentNode); 941 } else if ('contains' in outerNode) { 942 return outerNode.contains(innerNode); 943 } else if (outerNode.compareDocumentPosition) { 944 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 945 } else { 946 return false; 947 } 948 } 949 950 module.exports = containsNode; 951 952 /***/ }), 953 /* 14 */ 954 /***/ (function(module, exports, __webpack_require__) { 955 956 "use strict"; 957 /** 958 * Copyright (c) 2013-present, Facebook, Inc. 959 * 960 * This source code is licensed under the MIT license found in the 961 * LICENSE file in the root directory of this source tree. 962 * 963 */ 964 965 966 967 /** 968 * @param {DOMElement} node input/textarea to focus 969 */ 970 971 function focusNode(node) { 972 // IE8 can throw "Can't move focus to the control because it is invisible, 973 // not enabled, or of a type that does not accept the focus." for all kinds of 974 // reasons that are too expensive and fragile to test. 975 try { 976 node.focus(); 977 } catch (e) {} 978 } 979 980 module.exports = focusNode; 981 982 /***/ }), 983 /* 15 */ 984 /***/ (function(module, exports, __webpack_require__) { 985 986 window.ReactTestUtils = __webpack_require__(16); 987 988 989 /***/ }), 990 /* 16 */ 991 /***/ (function(module, exports, __webpack_require__) { 992 993 "use strict"; 994 /* WEBPACK VAR INJECTION */(function(process) { 995 996 if (process.env.NODE_ENV === 'production') { 997 module.exports = __webpack_require__(17); 998 } else { 999 module.exports = __webpack_require__(29); 1000 } 1001 1002 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 1003 1004 /***/ }), 1005 /* 17 */ 1006 /***/ (function(module, exports, __webpack_require__) { 1007 1008 "use strict"; 1009 /** @license React v16.2.0 1010 * react-dom-test-utils.production.min.js 1011 * 1012 * Copyright (c) 2013-present, Facebook, Inc. 1013 * 1014 * This source code is licensed under the MIT license found in the 1015 * LICENSE file in the root directory of this source tree. 1016 */ 1017 1018 var f=__webpack_require__(2),h=__webpack_require__(3),m=__webpack_require__(9),n=__webpack_require__(1),p=__webpack_require__(7); 1019 function q(a){for(var b=arguments.length-1,c="Minified React error #"+a+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+a,d=0;d<b;d++)c+="\x26args[]\x3d"+encodeURIComponent(arguments[d+1]);b=Error(c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");b.name="Invariant Violation";b.framesToPop=1;throw b;} 1020 function r(a){var b=a;if(a.alternate)for(;b["return"];)b=b["return"];else{if(0!==(b.effectTag&2))return 1;for(;b["return"];)if(b=b["return"],0!==(b.effectTag&2))return 1}return 3===b.tag?2:3}function t(a){2!==r(a)?q("188"):void 0} 1021 function u(a){var b=a.alternate;if(!b)return b=r(a),3===b?q("188"):void 0,1===b?null:a;for(var c=a,d=b;;){var e=c["return"],l=e?e.alternate:null;if(!e||!l)break;if(e.child===l.child){for(var g=e.child;g;){if(g===c)return t(e),a;if(g===d)return t(e),b;g=g.sibling}q("188")}if(c["return"]!==d["return"])c=e,d=l;else{g=!1;for(var k=e.child;k;){if(k===c){g=!0;c=e;d=l;break}if(k===d){g=!0;d=e;c=l;break}k=k.sibling}if(!g){for(k=l.child;k;){if(k===c){g=!0;c=l;d=e;break}if(k===d){g=!0;d=l;c=e;break}k=k.sibling}g? 1022 void 0:q("189")}}c.alternate!==d?q("190"):void 0}3!==c.tag?q("188"):void 0;return c.stateNode.current===c?a:b}var v="dispatchConfig _targetInst nativeEvent isDefaultPrevented isPropagationStopped _dispatchListeners _dispatchInstances".split(" "),w={type:null,target:null,currentTarget:n.thatReturnsNull,eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null}; 1023 function x(a,b,c,d){this.dispatchConfig=a;this._targetInst=b;this.nativeEvent=c;a=this.constructor.Interface;for(var e in a)a.hasOwnProperty(e)&&((b=a[e])?this[e]=b(c):"target"===e?this.target=d:this[e]=c[e]);this.isDefaultPrevented=(null!=c.defaultPrevented?c.defaultPrevented:!1===c.returnValue)?n.thatReturnsTrue:n.thatReturnsFalse;this.isPropagationStopped=n.thatReturnsFalse;return this} 1024 f(x.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():"unknown"!==typeof a.returnValue&&(a.returnValue=!1),this.isDefaultPrevented=n.thatReturnsTrue)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():"unknown"!==typeof a.cancelBubble&&(a.cancelBubble=!0),this.isPropagationStopped=n.thatReturnsTrue)},persist:function(){this.isPersistent=n.thatReturnsTrue},isPersistent:n.thatReturnsFalse, 1025 destructor:function(){var a=this.constructor.Interface,b;for(b in a)this[b]=null;for(a=0;a<v.length;a++)this[v[a]]=null}});x.Interface=w;x.augmentClass=function(a,b){function c(){}c.prototype=this.prototype;var d=new c;f(d,a.prototype);a.prototype=d;a.prototype.constructor=a;a.Interface=f({},this.Interface,b);a.augmentClass=this.augmentClass;y(a)};y(x);function z(a,b,c,d){if(this.eventPool.length){var e=this.eventPool.pop();this.call(e,a,b,c,d);return e}return new this(a,b,c,d)} 1026 function A(a){a instanceof this?void 0:q("223");a.destructor();10>this.eventPool.length&&this.eventPool.push(a)}function y(a){a.eventPool=[];a.getPooled=z;a.release=A}function B(a,b){var c={};c[a.toLowerCase()]=b.toLowerCase();c["Webkit"+a]="webkit"+b;c["Moz"+a]="moz"+b;c["ms"+a]="MS"+b;c["O"+a]="o"+b.toLowerCase();return c} 1027 var C={animationend:B("Animation","AnimationEnd"),animationiteration:B("Animation","AnimationIteration"),animationstart:B("Animation","AnimationStart"),transitionend:B("Transition","TransitionEnd")},D={},E={};p.canUseDOM&&(E=document.createElement("div").style,"AnimationEvent"in window||(delete C.animationend.animation,delete C.animationiteration.animation,delete C.animationstart.animation),"TransitionEvent"in window||delete C.transitionend.transition); 1028 function F(a){if(D[a])return D[a];if(!C[a])return a;var b=C[a],c;for(c in b)if(b.hasOwnProperty(c)&&c in E)return D[a]=b[c];return""} 1029 var G={topLevelTypes:{topAbort:"abort",topAnimationEnd:F("animationend")||"animationend",topAnimationIteration:F("animationiteration")||"animationiteration",topAnimationStart:F("animationstart")||"animationstart",topBlur:"blur",topCancel:"cancel",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topClose:"close",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy", 1030 topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoad:"load",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart", 1031 topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topToggle:"toggle",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove", 1032 topTouchStart:"touchstart",topTransitionEnd:F("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"}},H=m.findDOMNode,I=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,J=I.EventPluginHub,K=I.EventPluginRegistry,L=I.EventPropagators,M=I.ReactControlledComponent,N=I.ReactDOMComponentTree,O=I.ReactDOMEventListener,P=G.topLevelTypes;function Q(){} 1033 function R(a,b){if(!a)return[];a=u(a);if(!a)return[];for(var c=a,d=[];;){if(5===c.tag||6===c.tag||2===c.tag||1===c.tag){var e=c.stateNode;b(e)&&d.push(e)}if(c.child)c.child["return"]=c,c=c.child;else{if(c===a)return d;for(;!c.sibling;){if(!c["return"]||c["return"]===a)return d;c=c["return"]}c.sibling["return"]=c["return"];c=c.sibling}}} 1034 var S={renderIntoDocument:function(a){var b=document.createElement("div");return m.render(a,b)},isElement:function(a){return h.isValidElement(a)},isElementOfType:function(a,b){return h.isValidElement(a)&&a.type===b},isDOMComponent:function(a){return!(!a||1!==a.nodeType||!a.tagName)},isDOMComponentElement:function(a){return!!(a&&h.isValidElement(a)&&a.tagName)},isCompositeComponent:function(a){return S.isDOMComponent(a)?!1:null!=a&&"function"===typeof a.render&&"function"===typeof a.setState},isCompositeComponentWithType:function(a, 1035 b){return S.isCompositeComponent(a)?a._reactInternalFiber.type===b:!1},findAllInRenderedTree:function(a,b){if(!a)return[];S.isCompositeComponent(a)?void 0:q("10");return R(a._reactInternalFiber,b)},scryRenderedDOMComponentsWithClass:function(a,b){return S.findAllInRenderedTree(a,function(a){if(S.isDOMComponent(a)){var c=a.className;"string"!==typeof c&&(c=a.getAttribute("class")||"");var e=c.split(/\s+/);Array.isArray(b)||(void 0===b?q("11"):void 0,b=b.split(/\s+/));return b.every(function(a){return-1!== 1036 e.indexOf(a)})}return!1})},findRenderedDOMComponentWithClass:function(a,b){a=S.scryRenderedDOMComponentsWithClass(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+a.length+") for class:"+b);return a[0]},scryRenderedDOMComponentsWithTag:function(a,b){return S.findAllInRenderedTree(a,function(a){return S.isDOMComponent(a)&&a.tagName.toUpperCase()===b.toUpperCase()})},findRenderedDOMComponentWithTag:function(a,b){a=S.scryRenderedDOMComponentsWithTag(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+ 1037 a.length+") for tag:"+b);return a[0]},scryRenderedComponentsWithType:function(a,b){return S.findAllInRenderedTree(a,function(a){return S.isCompositeComponentWithType(a,b)})},findRenderedComponentWithType:function(a,b){a=S.scryRenderedComponentsWithType(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+a.length+") for componentType:"+b);return a[0]},mockComponent:function(a,b){b=b||a.mockTagName||"div";a.prototype.render.mockImplementation(function(){return h.createElement(b, 1038 null,this.props.children)});return this},simulateNativeEventOnNode:function(a,b,c){c.target=b;O.dispatchEvent(a,c)},simulateNativeEventOnDOMComponent:function(a,b,c){S.simulateNativeEventOnNode(a,H(b),c)},nativeTouchData:function(a,b){return{touches:[{pageX:a,pageY:b}]}},Simulate:null,SimulateNative:{}}; 1039 function T(a){return function(b,c){h.isValidElement(b)?q("228"):void 0;S.isCompositeComponent(b)?q("229"):void 0;var d=K.eventNameDispatchConfigs[a],e=new Q;e.target=b;e.type=a.toLowerCase();var l=N.getInstanceFromNode(b),g=new x(d,l,e,b);g.persist();f(g,c);d.phasedRegistrationNames?L.accumulateTwoPhaseDispatches(g):L.accumulateDirectDispatches(g);m.unstable_batchedUpdates(function(){M.enqueueStateRestore(b);J.enqueueEvents(g);J.processEventQueue(!0)})}} 1040 function U(){S.Simulate={};for(var a in K.eventNameDispatchConfigs)S.Simulate[a]=T(a)}var V=J.injection.injectEventPluginOrder;J.injection.injectEventPluginOrder=function(){V.apply(this,arguments);U()};var W=J.injection.injectEventPluginsByName;J.injection.injectEventPluginsByName=function(){W.apply(this,arguments);U()};U();function X(a){return function(b,c){var d=new Q(a);f(d,c);S.isDOMComponent(b)?S.simulateNativeEventOnDOMComponent(a,b,d):b.tagName&&S.simulateNativeEventOnNode(a,b,d)}} 1041 Object.keys(P).forEach(function(a){var b=0===a.indexOf("top")?a.charAt(3).toLowerCase()+a.substr(4):a;S.SimulateNative[b]=X(a)});var Y=Object.freeze({default:S}),Z=Y&&S||Y;module.exports=Z["default"]?Z["default"]:Z; 1042 1043 1044 /***/ }), 1045 /* 18 */ 1046 /***/ (function(module, exports, __webpack_require__) { 1047 1048 "use strict"; 1049 /** @license React v16.2.0 1050 * react.production.min.js 1051 * 1052 * Copyright (c) 2013-present, Facebook, Inc. 1053 * 1054 * This source code is licensed under the MIT license found in the 1055 * LICENSE file in the root directory of this source tree. 1056 */ 1057 1058 var m=__webpack_require__(2),n=__webpack_require__(4),p=__webpack_require__(1),q="function"===typeof Symbol&&Symbol["for"],r=q?Symbol["for"]("react.element"):60103,t=q?Symbol["for"]("react.call"):60104,u=q?Symbol["for"]("react.return"):60105,v=q?Symbol["for"]("react.portal"):60106,w=q?Symbol["for"]("react.fragment"):60107,x="function"===typeof Symbol&&Symbol.iterator; 1059 function y(a){for(var b=arguments.length-1,e="Minified React error #"+a+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+a,c=0;c<b;c++)e+="\x26args[]\x3d"+encodeURIComponent(arguments[c+1]);b=Error(e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");b.name="Invariant Violation";b.framesToPop=1;throw b;} 1060 var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}};function A(a,b,e){this.props=a;this.context=b;this.refs=n;this.updater=e||z}A.prototype.isReactComponent={};A.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?y("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};A.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")}; 1061 function B(a,b,e){this.props=a;this.context=b;this.refs=n;this.updater=e||z}function C(){}C.prototype=A.prototype;var D=B.prototype=new C;D.constructor=B;m(D,A.prototype);D.isPureReactComponent=!0;function E(a,b,e){this.props=a;this.context=b;this.refs=n;this.updater=e||z}var F=E.prototype=new C;F.constructor=E;m(F,A.prototype);F.unstable_isAsyncReactComponent=!0;F.render=function(){return this.props.children};var G={current:null},H=Object.prototype.hasOwnProperty,I={key:!0,ref:!0,__self:!0,__source:!0}; 1062 function J(a,b,e){var c,d={},g=null,k=null;if(null!=b)for(c in void 0!==b.ref&&(k=b.ref),void 0!==b.key&&(g=""+b.key),b)H.call(b,c)&&!I.hasOwnProperty(c)&&(d[c]=b[c]);var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){for(var h=Array(f),l=0;l<f;l++)h[l]=arguments[l+2];d.children=h}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===d[c]&&(d[c]=f[c]);return{$$typeof:r,type:a,key:g,ref:k,props:d,_owner:G.current}}function K(a){return"object"===typeof a&&null!==a&&a.$$typeof===r} 1063 function escape(a){var b={"\x3d":"\x3d0",":":"\x3d2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var L=/\/+/g,M=[];function N(a,b,e,c){if(M.length){var d=M.pop();d.result=a;d.keyPrefix=b;d.func=e;d.context=c;d.count=0;return d}return{result:a,keyPrefix:b,func:e,context:c,count:0}}function O(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>M.length&&M.push(a)} 1064 function P(a,b,e,c){var d=typeof a;if("undefined"===d||"boolean"===d)a=null;var g=!1;if(null===a)g=!0;else switch(d){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case r:case t:case u:case v:g=!0}}if(g)return e(c,a,""===b?"."+Q(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var k=0;k<a.length;k++){d=a[k];var f=b+Q(d,k);g+=P(d,f,e,c)}else if(null===a||"undefined"===typeof a?f=null:(f=x&&a[x]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a= 1065 f.call(a),k=0;!(d=a.next()).done;)d=d.value,f=b+Q(d,k++),g+=P(d,f,e,c);else"object"===d&&(e=""+a,y("31","[object Object]"===e?"object with keys {"+Object.keys(a).join(", ")+"}":e,""));return g}function Q(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function R(a,b){a.func.call(a.context,b,a.count++)} 1066 function S(a,b,e){var c=a.result,d=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?T(a,c,e,p.thatReturnsArgument):null!=a&&(K(a)&&(b=d+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(L,"$\x26/")+"/")+e,a={$$typeof:r,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}),c.push(a))}function T(a,b,e,c,d){var g="";null!=e&&(g=(""+e).replace(L,"$\x26/")+"/");b=N(b,g,c,d);null==a||P(a,"",S,b);O(b)} 1067 var U={Children:{map:function(a,b,e){if(null==a)return a;var c=[];T(a,c,null,b,e);return c},forEach:function(a,b,e){if(null==a)return a;b=N(null,null,b,e);null==a||P(a,"",R,b);O(b)},count:function(a){return null==a?0:P(a,"",p.thatReturnsNull,null)},toArray:function(a){var b=[];T(a,b,null,p.thatReturnsArgument);return b},only:function(a){K(a)?void 0:y("143");return a}},Component:A,PureComponent:B,unstable_AsyncComponent:E,Fragment:w,createElement:J,cloneElement:function(a,b,e){var c=m({},a.props), 1068 d=a.key,g=a.ref,k=a._owner;if(null!=b){void 0!==b.ref&&(g=b.ref,k=G.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var f=a.type.defaultProps;for(h in b)H.call(b,h)&&!I.hasOwnProperty(h)&&(c[h]=void 0===b[h]&&void 0!==f?f[h]:b[h])}var h=arguments.length-2;if(1===h)c.children=e;else if(1<h){f=Array(h);for(var l=0;l<h;l++)f[l]=arguments[l+2];c.children=f}return{$$typeof:r,type:a.type,key:d,ref:g,props:c,_owner:k}},createFactory:function(a){var b=J.bind(null,a);b.type=a;return b}, 1069 isValidElement:K,version:"16.2.0",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:G,assign:m}},V=Object.freeze({default:U}),W=V&&U||V;module.exports=W["default"]?W["default"]:W; 1070 1071 1072 /***/ }), 1073 /* 19 */ 1074 /***/ (function(module, exports, __webpack_require__) { 1075 1076 "use strict"; 1077 /* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.2.0 1078 * react.development.js 1079 * 1080 * Copyright (c) 2013-present, Facebook, Inc. 1081 * 1082 * This source code is licensed under the MIT license found in the 1083 * LICENSE file in the root directory of this source tree. 1084 */ 1085 1086 1087 1088 1089 1090 if (process.env.NODE_ENV !== "production") { 1091 (function() { 1092 'use strict'; 1093 1094 var _assign = __webpack_require__(2); 1095 var emptyObject = __webpack_require__(4); 1096 var invariant = __webpack_require__(5); 1097 var warning = __webpack_require__(6); 1098 var emptyFunction = __webpack_require__(1); 1099 var checkPropTypes = __webpack_require__(8); 1100 1101 // TODO: this is special because it gets imported during build. 1102 1103 var ReactVersion = '16.2.0'; 1104 1105 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol 1106 // nor polyfill, then a plain number is used for performance. 1107 var hasSymbol = typeof Symbol === 'function' && Symbol['for']; 1108 1109 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7; 1110 var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8; 1111 var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9; 1112 var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca; 1113 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb; 1114 1115 var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 1116 var FAUX_ITERATOR_SYMBOL = '@@iterator'; 1117 1118 function getIteratorFn(maybeIterable) { 1119 if (maybeIterable === null || typeof maybeIterable === 'undefined') { 1120 return null; 1121 } 1122 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 1123 if (typeof maybeIterator === 'function') { 1124 return maybeIterator; 1125 } 1126 return null; 1127 } 1128 1129 /** 1130 * WARNING: DO NOT manually require this module. 1131 * This is a replacement for `invariant(...)` used by the error code system 1132 * and will _only_ be required by the corresponding babel pass. 1133 * It always throws. 1134 */ 1135 1136 /** 1137 * Forked from fbjs/warning: 1138 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js 1139 * 1140 * Only change is we use console.warn instead of console.error, 1141 * and do nothing when 'console' is not supported. 1142 * This really simplifies the code. 1143 * --- 1144 * Similar to invariant but only logs a warning if the condition is not met. 1145 * This can be used to log issues in development environments in critical 1146 * paths. Removing the logging code for production environments will keep the 1147 * same logic and follow the same code paths. 1148 */ 1149 1150 var lowPriorityWarning = function () {}; 1151 1152 { 1153 var printWarning = function (format) { 1154 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 1155 args[_key - 1] = arguments[_key]; 1156 } 1157 1158 var argIndex = 0; 1159 var message = 'Warning: ' + format.replace(/%s/g, function () { 1160 return args[argIndex++]; 1161 }); 1162 if (typeof console !== 'undefined') { 1163 console.warn(message); 1164 } 1165 try { 1166 // --- Welcome to debugging React --- 1167 // This error was thrown as a convenience so that you can use this stack 1168 // to find the callsite that caused this warning to fire. 1169 throw new Error(message); 1170 } catch (x) {} 1171 }; 1172 1173 lowPriorityWarning = function (condition, format) { 1174 if (format === undefined) { 1175 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 1176 } 1177 if (!condition) { 1178 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 1179 args[_key2 - 2] = arguments[_key2]; 1180 } 1181 1182 printWarning.apply(undefined, [format].concat(args)); 1183 } 1184 }; 1185 } 1186 1187 var lowPriorityWarning$1 = lowPriorityWarning; 1188 1189 var didWarnStateUpdateForUnmountedComponent = {}; 1190 1191 function warnNoop(publicInstance, callerName) { 1192 { 1193 var constructor = publicInstance.constructor; 1194 var componentName = constructor && (constructor.displayName || constructor.name) || 'ReactClass'; 1195 var warningKey = componentName + '.' + callerName; 1196 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 1197 return; 1198 } 1199 warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName); 1200 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 1201 } 1202 } 1203 1204 /** 1205 * This is the abstract API for an update queue. 1206 */ 1207 var ReactNoopUpdateQueue = { 1208 /** 1209 * Checks whether or not this composite component is mounted. 1210 * @param {ReactClass} publicInstance The instance we want to test. 1211 * @return {boolean} True if mounted, false otherwise. 1212 * @protected 1213 * @final 1214 */ 1215 isMounted: function (publicInstance) { 1216 return false; 1217 }, 1218 1219 /** 1220 * Forces an update. This should only be invoked when it is known with 1221 * certainty that we are **not** in a DOM transaction. 1222 * 1223 * You may want to call this when you know that some deeper aspect of the 1224 * component's state has changed but `setState` was not called. 1225 * 1226 * This will not invoke `shouldComponentUpdate`, but it will invoke 1227 * `componentWillUpdate` and `componentDidUpdate`. 1228 * 1229 * @param {ReactClass} publicInstance The instance that should rerender. 1230 * @param {?function} callback Called after component is updated. 1231 * @param {?string} callerName name of the calling function in the public API. 1232 * @internal 1233 */ 1234 enqueueForceUpdate: function (publicInstance, callback, callerName) { 1235 warnNoop(publicInstance, 'forceUpdate'); 1236 }, 1237 1238 /** 1239 * Replaces all of the state. Always use this or `setState` to mutate state. 1240 * You should treat `this.state` as immutable. 1241 * 1242 * There is no guarantee that `this.state` will be immediately updated, so 1243 * accessing `this.state` after calling this method may return the old value. 1244 * 1245 * @param {ReactClass} publicInstance The instance that should rerender. 1246 * @param {object} completeState Next state. 1247 * @param {?function} callback Called after component is updated. 1248 * @param {?string} callerName name of the calling function in the public API. 1249 * @internal 1250 */ 1251 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 1252 warnNoop(publicInstance, 'replaceState'); 1253 }, 1254 1255 /** 1256 * Sets a subset of the state. This only exists because _pendingState is 1257 * internal. This provides a merging strategy that is not available to deep 1258 * properties which is confusing. TODO: Expose pendingState or don't use it 1259 * during the merge. 1260 * 1261 * @param {ReactClass} publicInstance The instance that should rerender. 1262 * @param {object} partialState Next partial state to be merged with state. 1263 * @param {?function} callback Called after component is updated. 1264 * @param {?string} Name of the calling function in the public API. 1265 * @internal 1266 */ 1267 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 1268 warnNoop(publicInstance, 'setState'); 1269 } 1270 }; 1271 1272 /** 1273 * Base class helpers for the updating state of a component. 1274 */ 1275 function Component(props, context, updater) { 1276 this.props = props; 1277 this.context = context; 1278 this.refs = emptyObject; 1279 // We initialize the default updater but the real one gets injected by the 1280 // renderer. 1281 this.updater = updater || ReactNoopUpdateQueue; 1282 } 1283 1284 Component.prototype.isReactComponent = {}; 1285 1286 /** 1287 * Sets a subset of the state. Always use this to mutate 1288 * state. You should treat `this.state` as immutable. 1289 * 1290 * There is no guarantee that `this.state` will be immediately updated, so 1291 * accessing `this.state` after calling this method may return the old value. 1292 * 1293 * There is no guarantee that calls to `setState` will run synchronously, 1294 * as they may eventually be batched together. You can provide an optional 1295 * callback that will be executed when the call to setState is actually 1296 * completed. 1297 * 1298 * When a function is provided to setState, it will be called at some point in 1299 * the future (not synchronously). It will be called with the up to date 1300 * component arguments (state, props, context). These values can be different 1301 * from this.* because your function may be called after receiveProps but before 1302 * shouldComponentUpdate, and this new state, props, and context will not yet be 1303 * assigned to this. 1304 * 1305 * @param {object|function} partialState Next partial state or function to 1306 * produce next partial state to be merged with current state. 1307 * @param {?function} callback Called after state is updated. 1308 * @final 1309 * @protected 1310 */ 1311 Component.prototype.setState = function (partialState, callback) { 1312 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0; 1313 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 1314 }; 1315 1316 /** 1317 * Forces an update. This should only be invoked when it is known with 1318 * certainty that we are **not** in a DOM transaction. 1319 * 1320 * You may want to call this when you know that some deeper aspect of the 1321 * component's state has changed but `setState` was not called. 1322 * 1323 * This will not invoke `shouldComponentUpdate`, but it will invoke 1324 * `componentWillUpdate` and `componentDidUpdate`. 1325 * 1326 * @param {?function} callback Called after update is complete. 1327 * @final 1328 * @protected 1329 */ 1330 Component.prototype.forceUpdate = function (callback) { 1331 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 1332 }; 1333 1334 /** 1335 * Deprecated APIs. These APIs used to exist on classic React classes but since 1336 * we would like to deprecate them, we're not going to move them over to this 1337 * modern base class. Instead, we define a getter that warns if it's accessed. 1338 */ 1339 { 1340 var deprecatedAPIs = { 1341 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 1342 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 1343 }; 1344 var defineDeprecationWarning = function (methodName, info) { 1345 Object.defineProperty(Component.prototype, methodName, { 1346 get: function () { 1347 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 1348 return undefined; 1349 } 1350 }); 1351 }; 1352 for (var fnName in deprecatedAPIs) { 1353 if (deprecatedAPIs.hasOwnProperty(fnName)) { 1354 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 1355 } 1356 } 1357 } 1358 1359 /** 1360 * Base class helpers for the updating state of a component. 1361 */ 1362 function PureComponent(props, context, updater) { 1363 // Duplicated from Component. 1364 this.props = props; 1365 this.context = context; 1366 this.refs = emptyObject; 1367 // We initialize the default updater but the real one gets injected by the 1368 // renderer. 1369 this.updater = updater || ReactNoopUpdateQueue; 1370 } 1371 1372 function ComponentDummy() {} 1373 ComponentDummy.prototype = Component.prototype; 1374 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 1375 pureComponentPrototype.constructor = PureComponent; 1376 // Avoid an extra prototype jump for these methods. 1377 _assign(pureComponentPrototype, Component.prototype); 1378 pureComponentPrototype.isPureReactComponent = true; 1379 1380 function AsyncComponent(props, context, updater) { 1381 // Duplicated from Component. 1382 this.props = props; 1383 this.context = context; 1384 this.refs = emptyObject; 1385 // We initialize the default updater but the real one gets injected by the 1386 // renderer. 1387 this.updater = updater || ReactNoopUpdateQueue; 1388 } 1389 1390 var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy(); 1391 asyncComponentPrototype.constructor = AsyncComponent; 1392 // Avoid an extra prototype jump for these methods. 1393 _assign(asyncComponentPrototype, Component.prototype); 1394 asyncComponentPrototype.unstable_isAsyncReactComponent = true; 1395 asyncComponentPrototype.render = function () { 1396 return this.props.children; 1397 }; 1398 1399 /** 1400 * Keeps track of the current owner. 1401 * 1402 * The current owner is the component who should own any components that are 1403 * currently being constructed. 1404 */ 1405 var ReactCurrentOwner = { 1406 /** 1407 * @internal 1408 * @type {ReactComponent} 1409 */ 1410 current: null 1411 }; 1412 1413 var hasOwnProperty = Object.prototype.hasOwnProperty; 1414 1415 var RESERVED_PROPS = { 1416 key: true, 1417 ref: true, 1418 __self: true, 1419 __source: true 1420 }; 1421 1422 var specialPropKeyWarningShown; 1423 var specialPropRefWarningShown; 1424 1425 function hasValidRef(config) { 1426 { 1427 if (hasOwnProperty.call(config, 'ref')) { 1428 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 1429 if (getter && getter.isReactWarning) { 1430 return false; 1431 } 1432 } 1433 } 1434 return config.ref !== undefined; 1435 } 1436 1437 function hasValidKey(config) { 1438 { 1439 if (hasOwnProperty.call(config, 'key')) { 1440 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 1441 if (getter && getter.isReactWarning) { 1442 return false; 1443 } 1444 } 1445 } 1446 return config.key !== undefined; 1447 } 1448 1449 function defineKeyPropWarningGetter(props, displayName) { 1450 var warnAboutAccessingKey = function () { 1451 if (!specialPropKeyWarningShown) { 1452 specialPropKeyWarningShown = true; 1453 warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 1454 } 1455 }; 1456 warnAboutAccessingKey.isReactWarning = true; 1457 Object.defineProperty(props, 'key', { 1458 get: warnAboutAccessingKey, 1459 configurable: true 1460 }); 1461 } 1462 1463 function defineRefPropWarningGetter(props, displayName) { 1464 var warnAboutAccessingRef = function () { 1465 if (!specialPropRefWarningShown) { 1466 specialPropRefWarningShown = true; 1467 warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 1468 } 1469 }; 1470 warnAboutAccessingRef.isReactWarning = true; 1471 Object.defineProperty(props, 'ref', { 1472 get: warnAboutAccessingRef, 1473 configurable: true 1474 }); 1475 } 1476 1477 /** 1478 * Factory method to create a new React element. This no longer adheres to 1479 * the class pattern, so do not use new to call it. Also, no instanceof check 1480 * will work. Instead test $$typeof field against Symbol.for('react.element') to check 1481 * if something is a React Element. 1482 * 1483 * @param {*} type 1484 * @param {*} key 1485 * @param {string|object} ref 1486 * @param {*} self A *temporary* helper to detect places where `this` is 1487 * different from the `owner` when React.createElement is called, so that we 1488 * can warn. We want to get rid of owner and replace string `ref`s with arrow 1489 * functions, and as long as `this` and owner are the same, there will be no 1490 * change in behavior. 1491 * @param {*} source An annotation object (added by a transpiler or otherwise) 1492 * indicating filename, line number, and/or other information. 1493 * @param {*} owner 1494 * @param {*} props 1495 * @internal 1496 */ 1497 var ReactElement = function (type, key, ref, self, source, owner, props) { 1498 var element = { 1499 // This tag allow us to uniquely identify this as a React Element 1500 $$typeof: REACT_ELEMENT_TYPE, 1501 1502 // Built-in properties that belong on the element 1503 type: type, 1504 key: key, 1505 ref: ref, 1506 props: props, 1507 1508 // Record the component responsible for creating this element. 1509 _owner: owner 1510 }; 1511 1512 { 1513 // The validation flag is currently mutative. We put it on 1514 // an external backing store so that we can freeze the whole object. 1515 // This can be replaced with a WeakMap once they are implemented in 1516 // commonly used development environments. 1517 element._store = {}; 1518 1519 // To make comparing ReactElements easier for testing purposes, we make 1520 // the validation flag non-enumerable (where possible, which should 1521 // include every environment we run tests in), so the test framework 1522 // ignores it. 1523 Object.defineProperty(element._store, 'validated', { 1524 configurable: false, 1525 enumerable: false, 1526 writable: true, 1527 value: false 1528 }); 1529 // self and source are DEV only properties. 1530 Object.defineProperty(element, '_self', { 1531 configurable: false, 1532 enumerable: false, 1533 writable: false, 1534 value: self 1535 }); 1536 // Two elements created in two different places should be considered 1537 // equal for testing purposes and therefore we hide it from enumeration. 1538 Object.defineProperty(element, '_source', { 1539 configurable: false, 1540 enumerable: false, 1541 writable: false, 1542 value: source 1543 }); 1544 if (Object.freeze) { 1545 Object.freeze(element.props); 1546 Object.freeze(element); 1547 } 1548 } 1549 1550 return element; 1551 }; 1552 1553 /** 1554 * Create and return a new ReactElement of the given type. 1555 * See https://reactjs.org/docs/react-api.html#createelement 1556 */ 1557 function createElement(type, config, children) { 1558 var propName; 1559 1560 // Reserved names are extracted 1561 var props = {}; 1562 1563 var key = null; 1564 var ref = null; 1565 var self = null; 1566 var source = null; 1567 1568 if (config != null) { 1569 if (hasValidRef(config)) { 1570 ref = config.ref; 1571 } 1572 if (hasValidKey(config)) { 1573 key = '' + config.key; 1574 } 1575 1576 self = config.__self === undefined ? null : config.__self; 1577 source = config.__source === undefined ? null : config.__source; 1578 // Remaining properties are added to a new props object 1579 for (propName in config) { 1580 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 1581 props[propName] = config[propName]; 1582 } 1583 } 1584 } 1585 1586 // Children can be more than one argument, and those are transferred onto 1587 // the newly allocated props object. 1588 var childrenLength = arguments.length - 2; 1589 if (childrenLength === 1) { 1590 props.children = children; 1591 } else if (childrenLength > 1) { 1592 var childArray = Array(childrenLength); 1593 for (var i = 0; i < childrenLength; i++) { 1594 childArray[i] = arguments[i + 2]; 1595 } 1596 { 1597 if (Object.freeze) { 1598 Object.freeze(childArray); 1599 } 1600 } 1601 props.children = childArray; 1602 } 1603 1604 // Resolve default props 1605 if (type && type.defaultProps) { 1606 var defaultProps = type.defaultProps; 1607 for (propName in defaultProps) { 1608 if (props[propName] === undefined) { 1609 props[propName] = defaultProps[propName]; 1610 } 1611 } 1612 } 1613 { 1614 if (key || ref) { 1615 if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) { 1616 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 1617 if (key) { 1618 defineKeyPropWarningGetter(props, displayName); 1619 } 1620 if (ref) { 1621 defineRefPropWarningGetter(props, displayName); 1622 } 1623 } 1624 } 1625 } 1626 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 1627 } 1628 1629 /** 1630 * Return a function that produces ReactElements of a given type. 1631 * See https://reactjs.org/docs/react-api.html#createfactory 1632 */ 1633 1634 1635 function cloneAndReplaceKey(oldElement, newKey) { 1636 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 1637 1638 return newElement; 1639 } 1640 1641 /** 1642 * Clone and return a new ReactElement using element as the starting point. 1643 * See https://reactjs.org/docs/react-api.html#cloneelement 1644 */ 1645 function cloneElement(element, config, children) { 1646 var propName; 1647 1648 // Original props are copied 1649 var props = _assign({}, element.props); 1650 1651 // Reserved names are extracted 1652 var key = element.key; 1653 var ref = element.ref; 1654 // Self is preserved since the owner is preserved. 1655 var self = element._self; 1656 // Source is preserved since cloneElement is unlikely to be targeted by a 1657 // transpiler, and the original source is probably a better indicator of the 1658 // true owner. 1659 var source = element._source; 1660 1661 // Owner will be preserved, unless ref is overridden 1662 var owner = element._owner; 1663 1664 if (config != null) { 1665 if (hasValidRef(config)) { 1666 // Silently steal the ref from the parent. 1667 ref = config.ref; 1668 owner = ReactCurrentOwner.current; 1669 } 1670 if (hasValidKey(config)) { 1671 key = '' + config.key; 1672 } 1673 1674 // Remaining properties override existing props 1675 var defaultProps; 1676 if (element.type && element.type.defaultProps) { 1677 defaultProps = element.type.defaultProps; 1678 } 1679 for (propName in config) { 1680 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 1681 if (config[propName] === undefined && defaultProps !== undefined) { 1682 // Resolve default props 1683 props[propName] = defaultProps[propName]; 1684 } else { 1685 props[propName] = config[propName]; 1686 } 1687 } 1688 } 1689 } 1690 1691 // Children can be more than one argument, and those are transferred onto 1692 // the newly allocated props object. 1693 var childrenLength = arguments.length - 2; 1694 if (childrenLength === 1) { 1695 props.children = children; 1696 } else if (childrenLength > 1) { 1697 var childArray = Array(childrenLength); 1698 for (var i = 0; i < childrenLength; i++) { 1699 childArray[i] = arguments[i + 2]; 1700 } 1701 props.children = childArray; 1702 } 1703 1704 return ReactElement(element.type, key, ref, self, source, owner, props); 1705 } 1706 1707 /** 1708 * Verifies the object is a ReactElement. 1709 * See https://reactjs.org/docs/react-api.html#isvalidelement 1710 * @param {?object} object 1711 * @return {boolean} True if `object` is a valid component. 1712 * @final 1713 */ 1714 function isValidElement(object) { 1715 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 1716 } 1717 1718 var ReactDebugCurrentFrame = {}; 1719 1720 { 1721 // Component that is being worked on 1722 ReactDebugCurrentFrame.getCurrentStack = null; 1723 1724 ReactDebugCurrentFrame.getStackAddendum = function () { 1725 var impl = ReactDebugCurrentFrame.getCurrentStack; 1726 if (impl) { 1727 return impl(); 1728 } 1729 return null; 1730 }; 1731 } 1732 1733 var SEPARATOR = '.'; 1734 var SUBSEPARATOR = ':'; 1735 1736 /** 1737 * Escape and wrap key so it is safe to use as a reactid 1738 * 1739 * @param {string} key to be escaped. 1740 * @return {string} the escaped key. 1741 */ 1742 function escape(key) { 1743 var escapeRegex = /[=:]/g; 1744 var escaperLookup = { 1745 '=': '=0', 1746 ':': '=2' 1747 }; 1748 var escapedString = ('' + key).replace(escapeRegex, function (match) { 1749 return escaperLookup[match]; 1750 }); 1751 1752 return '$' + escapedString; 1753 } 1754 1755 /** 1756 * TODO: Test that a single child and an array with one item have the same key 1757 * pattern. 1758 */ 1759 1760 var didWarnAboutMaps = false; 1761 1762 var userProvidedKeyEscapeRegex = /\/+/g; 1763 function escapeUserProvidedKey(text) { 1764 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); 1765 } 1766 1767 var POOL_SIZE = 10; 1768 var traverseContextPool = []; 1769 function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { 1770 if (traverseContextPool.length) { 1771 var traverseContext = traverseContextPool.pop(); 1772 traverseContext.result = mapResult; 1773 traverseContext.keyPrefix = keyPrefix; 1774 traverseContext.func = mapFunction; 1775 traverseContext.context = mapContext; 1776 traverseContext.count = 0; 1777 return traverseContext; 1778 } else { 1779 return { 1780 result: mapResult, 1781 keyPrefix: keyPrefix, 1782 func: mapFunction, 1783 context: mapContext, 1784 count: 0 1785 }; 1786 } 1787 } 1788 1789 function releaseTraverseContext(traverseContext) { 1790 traverseContext.result = null; 1791 traverseContext.keyPrefix = null; 1792 traverseContext.func = null; 1793 traverseContext.context = null; 1794 traverseContext.count = 0; 1795 if (traverseContextPool.length < POOL_SIZE) { 1796 traverseContextPool.push(traverseContext); 1797 } 1798 } 1799 1800 /** 1801 * @param {?*} children Children tree container. 1802 * @param {!string} nameSoFar Name of the key path so far. 1803 * @param {!function} callback Callback to invoke with each child found. 1804 * @param {?*} traverseContext Used to pass information throughout the traversal 1805 * process. 1806 * @return {!number} The number of children in this subtree. 1807 */ 1808 function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { 1809 var type = typeof children; 1810 1811 if (type === 'undefined' || type === 'boolean') { 1812 // All of the above are perceived as null. 1813 children = null; 1814 } 1815 1816 var invokeCallback = false; 1817 1818 if (children === null) { 1819 invokeCallback = true; 1820 } else { 1821 switch (type) { 1822 case 'string': 1823 case 'number': 1824 invokeCallback = true; 1825 break; 1826 case 'object': 1827 switch (children.$$typeof) { 1828 case REACT_ELEMENT_TYPE: 1829 case REACT_CALL_TYPE: 1830 case REACT_RETURN_TYPE: 1831 case REACT_PORTAL_TYPE: 1832 invokeCallback = true; 1833 } 1834 } 1835 } 1836 1837 if (invokeCallback) { 1838 callback(traverseContext, children, 1839 // If it's the only child, treat the name as if it was wrapped in an array 1840 // so that it's consistent if the number of children grows. 1841 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); 1842 return 1; 1843 } 1844 1845 var child; 1846 var nextName; 1847 var subtreeCount = 0; // Count of children found in the current subtree. 1848 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 1849 1850 if (Array.isArray(children)) { 1851 for (var i = 0; i < children.length; i++) { 1852 child = children[i]; 1853 nextName = nextNamePrefix + getComponentKey(child, i); 1854 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 1855 } 1856 } else { 1857 var iteratorFn = getIteratorFn(children); 1858 if (typeof iteratorFn === 'function') { 1859 { 1860 // Warn about using Maps as children 1861 if (iteratorFn === children.entries) { 1862 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()); 1863 didWarnAboutMaps = true; 1864 } 1865 } 1866 1867 var iterator = iteratorFn.call(children); 1868 var step; 1869 var ii = 0; 1870 while (!(step = iterator.next()).done) { 1871 child = step.value; 1872 nextName = nextNamePrefix + getComponentKey(child, ii++); 1873 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 1874 } 1875 } else if (type === 'object') { 1876 var addendum = ''; 1877 { 1878 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); 1879 } 1880 var childrenString = '' + children; 1881 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); 1882 } 1883 } 1884 1885 return subtreeCount; 1886 } 1887 1888 /** 1889 * Traverses children that are typically specified as `props.children`, but 1890 * might also be specified through attributes: 1891 * 1892 * - `traverseAllChildren(this.props.children, ...)` 1893 * - `traverseAllChildren(this.props.leftPanelChildren, ...)` 1894 * 1895 * The `traverseContext` is an optional argument that is passed through the 1896 * entire traversal. It can be used to store accumulations or anything else that 1897 * the callback might find relevant. 1898 * 1899 * @param {?*} children Children tree object. 1900 * @param {!function} callback To invoke upon traversing each child. 1901 * @param {?*} traverseContext Context for traversal. 1902 * @return {!number} The number of children in this subtree. 1903 */ 1904 function traverseAllChildren(children, callback, traverseContext) { 1905 if (children == null) { 1906 return 0; 1907 } 1908 1909 return traverseAllChildrenImpl(children, '', callback, traverseContext); 1910 } 1911 1912 /** 1913 * Generate a key string that identifies a component within a set. 1914 * 1915 * @param {*} component A component that could contain a manual key. 1916 * @param {number} index Index that is used if a manual key is not provided. 1917 * @return {string} 1918 */ 1919 function getComponentKey(component, index) { 1920 // Do some typechecking here since we call this blindly. We want to ensure 1921 // that we don't block potential future ES APIs. 1922 if (typeof component === 'object' && component !== null && component.key != null) { 1923 // Explicit key 1924 return escape(component.key); 1925 } 1926 // Implicit key determined by the index in the set 1927 return index.toString(36); 1928 } 1929 1930 function forEachSingleChild(bookKeeping, child, name) { 1931 var func = bookKeeping.func, 1932 context = bookKeeping.context; 1933 1934 func.call(context, child, bookKeeping.count++); 1935 } 1936 1937 /** 1938 * Iterates through children that are typically specified as `props.children`. 1939 * 1940 * See https://reactjs.org/docs/react-api.html#react.children.foreach 1941 * 1942 * The provided forEachFunc(child, index) will be called for each 1943 * leaf child. 1944 * 1945 * @param {?*} children Children tree container. 1946 * @param {function(*, int)} forEachFunc 1947 * @param {*} forEachContext Context for forEachContext. 1948 */ 1949 function forEachChildren(children, forEachFunc, forEachContext) { 1950 if (children == null) { 1951 return children; 1952 } 1953 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); 1954 traverseAllChildren(children, forEachSingleChild, traverseContext); 1955 releaseTraverseContext(traverseContext); 1956 } 1957 1958 function mapSingleChildIntoContext(bookKeeping, child, childKey) { 1959 var result = bookKeeping.result, 1960 keyPrefix = bookKeeping.keyPrefix, 1961 func = bookKeeping.func, 1962 context = bookKeeping.context; 1963 1964 1965 var mappedChild = func.call(context, child, bookKeeping.count++); 1966 if (Array.isArray(mappedChild)) { 1967 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument); 1968 } else if (mappedChild != null) { 1969 if (isValidElement(mappedChild)) { 1970 mappedChild = cloneAndReplaceKey(mappedChild, 1971 // Keep both the (mapped) and old keys if they differ, just as 1972 // traverseAllChildren used to do for objects as children 1973 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); 1974 } 1975 result.push(mappedChild); 1976 } 1977 } 1978 1979 function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { 1980 var escapedPrefix = ''; 1981 if (prefix != null) { 1982 escapedPrefix = escapeUserProvidedKey(prefix) + '/'; 1983 } 1984 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); 1985 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); 1986 releaseTraverseContext(traverseContext); 1987 } 1988 1989 /** 1990 * Maps children that are typically specified as `props.children`. 1991 * 1992 * See https://reactjs.org/docs/react-api.html#react.children.map 1993 * 1994 * The provided mapFunction(child, key, index) will be called for each 1995 * leaf child. 1996 * 1997 * @param {?*} children Children tree container. 1998 * @param {function(*, int)} func The map function. 1999 * @param {*} context Context for mapFunction. 2000 * @return {object} Object containing the ordered map of results. 2001 */ 2002 function mapChildren(children, func, context) { 2003 if (children == null) { 2004 return children; 2005 } 2006 var result = []; 2007 mapIntoWithKeyPrefixInternal(children, result, null, func, context); 2008 return result; 2009 } 2010 2011 /** 2012 * Count the number of children that are typically specified as 2013 * `props.children`. 2014 * 2015 * See https://reactjs.org/docs/react-api.html#react.children.count 2016 * 2017 * @param {?*} children Children tree container. 2018 * @return {number} The number of children. 2019 */ 2020 function countChildren(children, context) { 2021 return traverseAllChildren(children, emptyFunction.thatReturnsNull, null); 2022 } 2023 2024 /** 2025 * Flatten a children object (typically specified as `props.children`) and 2026 * return an array with appropriately re-keyed children. 2027 * 2028 * See https://reactjs.org/docs/react-api.html#react.children.toarray 2029 */ 2030 function toArray(children) { 2031 var result = []; 2032 mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument); 2033 return result; 2034 } 2035 2036 /** 2037 * Returns the first child in a collection of children and verifies that there 2038 * is only one child in the collection. 2039 * 2040 * See https://reactjs.org/docs/react-api.html#react.children.only 2041 * 2042 * The current implementation of this function assumes that a single child gets 2043 * passed without a wrapper, but the purpose of this helper function is to 2044 * abstract away the particular structure of children. 2045 * 2046 * @param {?object} children Child collection structure. 2047 * @return {ReactElement} The first and only `ReactElement` contained in the 2048 * structure. 2049 */ 2050 function onlyChild(children) { 2051 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0; 2052 return children; 2053 } 2054 2055 var describeComponentFrame = function (name, source, ownerName) { 2056 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); 2057 }; 2058 2059 function getComponentName(fiber) { 2060 var type = fiber.type; 2061 2062 if (typeof type === 'string') { 2063 return type; 2064 } 2065 if (typeof type === 'function') { 2066 return type.displayName || type.name; 2067 } 2068 return null; 2069 } 2070 2071 /** 2072 * ReactElementValidator provides a wrapper around a element factory 2073 * which validates the props passed to the element. This is intended to be 2074 * used only in DEV and could be replaced by a static type checker for languages 2075 * that support it. 2076 */ 2077 2078 { 2079 var currentlyValidatingElement = null; 2080 2081 var propTypesMisspellWarningShown = false; 2082 2083 var getDisplayName = function (element) { 2084 if (element == null) { 2085 return '#empty'; 2086 } else if (typeof element === 'string' || typeof element === 'number') { 2087 return '#text'; 2088 } else if (typeof element.type === 'string') { 2089 return element.type; 2090 } else if (element.type === REACT_FRAGMENT_TYPE) { 2091 return 'React.Fragment'; 2092 } else { 2093 return element.type.displayName || element.type.name || 'Unknown'; 2094 } 2095 }; 2096 2097 var getStackAddendum = function () { 2098 var stack = ''; 2099 if (currentlyValidatingElement) { 2100 var name = getDisplayName(currentlyValidatingElement); 2101 var owner = currentlyValidatingElement._owner; 2102 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner)); 2103 } 2104 stack += ReactDebugCurrentFrame.getStackAddendum() || ''; 2105 return stack; 2106 }; 2107 2108 var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]); 2109 } 2110 2111 function getDeclarationErrorAddendum() { 2112 if (ReactCurrentOwner.current) { 2113 var name = getComponentName(ReactCurrentOwner.current); 2114 if (name) { 2115 return '\n\nCheck the render method of `' + name + '`.'; 2116 } 2117 } 2118 return ''; 2119 } 2120 2121 function getSourceInfoErrorAddendum(elementProps) { 2122 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { 2123 var source = elementProps.__source; 2124 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 2125 var lineNumber = source.lineNumber; 2126 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 2127 } 2128 return ''; 2129 } 2130 2131 /** 2132 * Warn if there's no key explicitly set on dynamic arrays of children or 2133 * object keys are not valid. This allows us to keep track of children between 2134 * updates. 2135 */ 2136 var ownerHasKeyUseWarning = {}; 2137 2138 function getCurrentComponentErrorInfo(parentType) { 2139 var info = getDeclarationErrorAddendum(); 2140 2141 if (!info) { 2142 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 2143 if (parentName) { 2144 info = '\n\nCheck the top-level render call using <' + parentName + '>.'; 2145 } 2146 } 2147 return info; 2148 } 2149 2150 /** 2151 * Warn if the element doesn't have an explicit key assigned to it. 2152 * This element is in an array. The array could grow and shrink or be 2153 * reordered. All children that haven't already been validated are required to 2154 * have a "key" property assigned to it. Error statuses are cached so a warning 2155 * will only be shown once. 2156 * 2157 * @internal 2158 * @param {ReactElement} element Element that requires a key. 2159 * @param {*} parentType element's parent's type. 2160 */ 2161 function validateExplicitKey(element, parentType) { 2162 if (!element._store || element._store.validated || element.key != null) { 2163 return; 2164 } 2165 element._store.validated = true; 2166 2167 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 2168 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 2169 return; 2170 } 2171 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 2172 2173 // Usually the current owner is the offender, but if it accepts children as a 2174 // property, it may be the creator of the child that's responsible for 2175 // assigning it a key. 2176 var childOwner = ''; 2177 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 2178 // Give the component that originally created this child. 2179 childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.'; 2180 } 2181 2182 currentlyValidatingElement = element; 2183 { 2184 warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum()); 2185 } 2186 currentlyValidatingElement = null; 2187 } 2188 2189 /** 2190 * Ensure that every element either is passed in a static location, in an 2191 * array with an explicit keys property defined, or in an object literal 2192 * with valid key property. 2193 * 2194 * @internal 2195 * @param {ReactNode} node Statically passed child of any type. 2196 * @param {*} parentType node's parent's type. 2197 */ 2198 function validateChildKeys(node, parentType) { 2199 if (typeof node !== 'object') { 2200 return; 2201 } 2202 if (Array.isArray(node)) { 2203 for (var i = 0; i < node.length; i++) { 2204 var child = node[i]; 2205 if (isValidElement(child)) { 2206 validateExplicitKey(child, parentType); 2207 } 2208 } 2209 } else if (isValidElement(node)) { 2210 // This element was passed in a valid location. 2211 if (node._store) { 2212 node._store.validated = true; 2213 } 2214 } else if (node) { 2215 var iteratorFn = getIteratorFn(node); 2216 if (typeof iteratorFn === 'function') { 2217 // Entry iterators used to provide implicit keys, 2218 // but now we print a separate warning for them later. 2219 if (iteratorFn !== node.entries) { 2220 var iterator = iteratorFn.call(node); 2221 var step; 2222 while (!(step = iterator.next()).done) { 2223 if (isValidElement(step.value)) { 2224 validateExplicitKey(step.value, parentType); 2225 } 2226 } 2227 } 2228 } 2229 } 2230 } 2231 2232 /** 2233 * Given an element, validate that its props follow the propTypes definition, 2234 * provided by the type. 2235 * 2236 * @param {ReactElement} element 2237 */ 2238 function validatePropTypes(element) { 2239 var componentClass = element.type; 2240 if (typeof componentClass !== 'function') { 2241 return; 2242 } 2243 var name = componentClass.displayName || componentClass.name; 2244 var propTypes = componentClass.propTypes; 2245 if (propTypes) { 2246 currentlyValidatingElement = element; 2247 checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum); 2248 currentlyValidatingElement = null; 2249 } else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) { 2250 propTypesMisspellWarningShown = true; 2251 warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); 2252 } 2253 if (typeof componentClass.getDefaultProps === 'function') { 2254 warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 2255 } 2256 } 2257 2258 /** 2259 * Given a fragment, validate that it can only be provided with fragment props 2260 * @param {ReactElement} fragment 2261 */ 2262 function validateFragmentProps(fragment) { 2263 currentlyValidatingElement = fragment; 2264 2265 var _iteratorNormalCompletion = true; 2266 var _didIteratorError = false; 2267 var _iteratorError = undefined; 2268 2269 try { 2270 for (var _iterator = Object.keys(fragment.props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { 2271 var key = _step.value; 2272 2273 if (!VALID_FRAGMENT_PROPS.has(key)) { 2274 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum()); 2275 break; 2276 } 2277 } 2278 } catch (err) { 2279 _didIteratorError = true; 2280 _iteratorError = err; 2281 } finally { 2282 try { 2283 if (!_iteratorNormalCompletion && _iterator['return']) { 2284 _iterator['return'](); 2285 } 2286 } finally { 2287 if (_didIteratorError) { 2288 throw _iteratorError; 2289 } 2290 } 2291 } 2292 2293 if (fragment.ref !== null) { 2294 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum()); 2295 } 2296 2297 currentlyValidatingElement = null; 2298 } 2299 2300 function createElementWithValidation(type, props, children) { 2301 var validType = typeof type === 'string' || typeof type === 'function' || typeof type === 'symbol' || typeof type === 'number'; 2302 // We warn in this case but don't throw. We expect the element creation to 2303 // succeed and there will likely be errors in render. 2304 if (!validType) { 2305 var info = ''; 2306 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 2307 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; 2308 } 2309 2310 var sourceInfo = getSourceInfoErrorAddendum(props); 2311 if (sourceInfo) { 2312 info += sourceInfo; 2313 } else { 2314 info += getDeclarationErrorAddendum(); 2315 } 2316 2317 info += getStackAddendum() || ''; 2318 2319 warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info); 2320 } 2321 2322 var element = createElement.apply(this, arguments); 2323 2324 // The result can be nullish if a mock or a custom function is used. 2325 // TODO: Drop this when these are no longer allowed as the type argument. 2326 if (element == null) { 2327 return element; 2328 } 2329 2330 // Skip key warning if the type isn't valid since our key validation logic 2331 // doesn't expect a non-string/function type and can throw confusing errors. 2332 // We don't want exception behavior to differ between dev and prod. 2333 // (Rendering will throw with a helpful message and as soon as the type is 2334 // fixed, the key warnings will appear.) 2335 if (validType) { 2336 for (var i = 2; i < arguments.length; i++) { 2337 validateChildKeys(arguments[i], type); 2338 } 2339 } 2340 2341 if (typeof type === 'symbol' && type === REACT_FRAGMENT_TYPE) { 2342 validateFragmentProps(element); 2343 } else { 2344 validatePropTypes(element); 2345 } 2346 2347 return element; 2348 } 2349 2350 function createFactoryWithValidation(type) { 2351 var validatedFactory = createElementWithValidation.bind(null, type); 2352 // Legacy hook TODO: Warn if this is accessed 2353 validatedFactory.type = type; 2354 2355 { 2356 Object.defineProperty(validatedFactory, 'type', { 2357 enumerable: false, 2358 get: function () { 2359 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 2360 Object.defineProperty(this, 'type', { 2361 value: type 2362 }); 2363 return type; 2364 } 2365 }); 2366 } 2367 2368 return validatedFactory; 2369 } 2370 2371 function cloneElementWithValidation(element, props, children) { 2372 var newElement = cloneElement.apply(this, arguments); 2373 for (var i = 2; i < arguments.length; i++) { 2374 validateChildKeys(arguments[i], newElement.type); 2375 } 2376 validatePropTypes(newElement); 2377 return newElement; 2378 } 2379 2380 var React = { 2381 Children: { 2382 map: mapChildren, 2383 forEach: forEachChildren, 2384 count: countChildren, 2385 toArray: toArray, 2386 only: onlyChild 2387 }, 2388 2389 Component: Component, 2390 PureComponent: PureComponent, 2391 unstable_AsyncComponent: AsyncComponent, 2392 2393 Fragment: REACT_FRAGMENT_TYPE, 2394 2395 createElement: createElementWithValidation, 2396 cloneElement: cloneElementWithValidation, 2397 createFactory: createFactoryWithValidation, 2398 isValidElement: isValidElement, 2399 2400 version: ReactVersion, 2401 2402 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { 2403 ReactCurrentOwner: ReactCurrentOwner, 2404 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 2405 assign: _assign 2406 } 2407 }; 2408 2409 { 2410 _assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, { 2411 // These should not be included in production. 2412 ReactDebugCurrentFrame: ReactDebugCurrentFrame, 2413 // Shim for React DOM 16.0.0 which still destructured (but not used) this. 2414 // TODO: remove in React 17.0. 2415 ReactComponentTreeHook: {} 2416 }); 2417 } 2418 2419 2420 2421 var React$2 = Object.freeze({ 2422 default: React 2423 }); 2424 2425 var React$3 = ( React$2 && React ) || React$2; 2426 2427 // TODO: decide on the top-level export form. 2428 // This is hacky but makes it work with both Rollup and Jest. 2429 var react = React$3['default'] ? React$3['default'] : React$3; 2430 2431 module.exports = react; 2432 })(); 2433 } 2434 2435 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 2436 2437 /***/ }), 2438 /* 20 */ 2439 /***/ (function(module, exports, __webpack_require__) { 2440 2441 "use strict"; 2442 /** 2443 * Copyright (c) 2013-present, Facebook, Inc. 2444 * 2445 * This source code is licensed under the MIT license found in the 2446 * LICENSE file in the root directory of this source tree. 2447 */ 2448 2449 2450 2451 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 2452 2453 module.exports = ReactPropTypesSecret; 2454 2455 2456 /***/ }), 2457 /* 21 */ 2458 /***/ (function(module, exports, __webpack_require__) { 2459 2460 "use strict"; 2461 /** @license React v16.2.0 2462 * react-dom.production.min.js 2463 * 2464 * Copyright (c) 2013-present, Facebook, Inc. 2465 * 2466 * This source code is licensed under the MIT license found in the 2467 * LICENSE file in the root directory of this source tree. 2468 */ 2469 2470 /* 2471 Modernizr 3.0.0pre (Custom Build) | MIT 2472 */ 2473 var aa=__webpack_require__(3),l=__webpack_require__(7),B=__webpack_require__(2),C=__webpack_require__(1),ba=__webpack_require__(10),da=__webpack_require__(11),ea=__webpack_require__(12),fa=__webpack_require__(13),ia=__webpack_require__(14),D=__webpack_require__(4); 2474 function E(a){for(var b=arguments.length-1,c="Minified React error #"+a+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+a,d=0;d<b;d++)c+="\x26args[]\x3d"+encodeURIComponent(arguments[d+1]);b=Error(c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");b.name="Invariant Violation";b.framesToPop=1;throw b;}aa?void 0:E("227"); 2475 var oa={children:!0,dangerouslySetInnerHTML:!0,defaultValue:!0,defaultChecked:!0,innerHTML:!0,suppressContentEditableWarning:!0,suppressHydrationWarning:!0,style:!0};function pa(a,b){return(a&b)===b} 2476 var ta={MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,HAS_STRING_BOOLEAN_VALUE:64,injectDOMPropertyConfig:function(a){var b=ta,c=a.Properties||{},d=a.DOMAttributeNamespaces||{},e=a.DOMAttributeNames||{};a=a.DOMMutationMethods||{};for(var f in c){ua.hasOwnProperty(f)?E("48",f):void 0;var g=f.toLowerCase(),h=c[f];g={attributeName:g,attributeNamespace:null,propertyName:f,mutationMethod:null,mustUseProperty:pa(h,b.MUST_USE_PROPERTY), 2477 hasBooleanValue:pa(h,b.HAS_BOOLEAN_VALUE),hasNumericValue:pa(h,b.HAS_NUMERIC_VALUE),hasPositiveNumericValue:pa(h,b.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:pa(h,b.HAS_OVERLOADED_BOOLEAN_VALUE),hasStringBooleanValue:pa(h,b.HAS_STRING_BOOLEAN_VALUE)};1>=g.hasBooleanValue+g.hasNumericValue+g.hasOverloadedBooleanValue?void 0:E("50",f);e.hasOwnProperty(f)&&(g.attributeName=e[f]);d.hasOwnProperty(f)&&(g.attributeNamespace=d[f]);a.hasOwnProperty(f)&&(g.mutationMethod=a[f]);ua[f]=g}}},ua={}; 2478 function va(a,b){if(oa.hasOwnProperty(a)||2<a.length&&("o"===a[0]||"O"===a[0])&&("n"===a[1]||"N"===a[1]))return!1;if(null===b)return!0;switch(typeof b){case "boolean":return oa.hasOwnProperty(a)?a=!0:(b=wa(a))?a=b.hasBooleanValue||b.hasStringBooleanValue||b.hasOverloadedBooleanValue:(a=a.toLowerCase().slice(0,5),a="data-"===a||"aria-"===a),a;case "undefined":case "number":case "string":case "object":return!0;default:return!1}}function wa(a){return ua.hasOwnProperty(a)?ua[a]:null} 2479 var xa=ta,ya=xa.MUST_USE_PROPERTY,K=xa.HAS_BOOLEAN_VALUE,za=xa.HAS_NUMERIC_VALUE,Aa=xa.HAS_POSITIVE_NUMERIC_VALUE,Ba=xa.HAS_OVERLOADED_BOOLEAN_VALUE,Ca=xa.HAS_STRING_BOOLEAN_VALUE,Da={Properties:{allowFullScreen:K,async:K,autoFocus:K,autoPlay:K,capture:Ba,checked:ya|K,cols:Aa,contentEditable:Ca,controls:K,"default":K,defer:K,disabled:K,download:Ba,draggable:Ca,formNoValidate:K,hidden:K,loop:K,multiple:ya|K,muted:ya|K,noValidate:K,open:K,playsInline:K,readOnly:K,required:K,reversed:K,rows:Aa,rowSpan:za, 2480 scoped:K,seamless:K,selected:ya|K,size:Aa,start:za,span:Aa,spellCheck:Ca,style:0,tabIndex:0,itemScope:K,acceptCharset:0,className:0,htmlFor:0,httpEquiv:0,value:Ca},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMMutationMethods:{value:function(a,b){if(null==b)return a.removeAttribute("value");"number"!==a.type||!1===a.hasAttribute("value")?a.setAttribute("value",""+b):a.validity&&!a.validity.badInput&&a.ownerDocument.activeElement!==a&& 2481 a.setAttribute("value",""+b)}}},Ea=xa.HAS_STRING_BOOLEAN_VALUE,M={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Ga={Properties:{autoReverse:Ea,externalResourcesRequired:Ea,preserveAlpha:Ea},DOMAttributeNames:{autoReverse:"autoReverse",externalResourcesRequired:"externalResourcesRequired",preserveAlpha:"preserveAlpha"},DOMAttributeNamespaces:{xlinkActuate:M.xlink,xlinkArcrole:M.xlink,xlinkHref:M.xlink,xlinkRole:M.xlink,xlinkShow:M.xlink,xlinkTitle:M.xlink,xlinkType:M.xlink, 2482 xmlBase:M.xml,xmlLang:M.xml,xmlSpace:M.xml}},Ha=/[\-\:]([a-z])/g;function Ia(a){return a[1].toUpperCase()} 2483 "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode x-height xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xmlns:xlink xml:lang xml:space".split(" ").forEach(function(a){var b=a.replace(Ha, 2484 Ia);Ga.Properties[b]=0;Ga.DOMAttributeNames[b]=a});xa.injectDOMPropertyConfig(Da);xa.injectDOMPropertyConfig(Ga); 2485 var P={_caughtError:null,_hasCaughtError:!1,_rethrowError:null,_hasRethrowError:!1,injection:{injectErrorUtils:function(a){"function"!==typeof a.invokeGuardedCallback?E("197"):void 0;Ja=a.invokeGuardedCallback}},invokeGuardedCallback:function(a,b,c,d,e,f,g,h,k){Ja.apply(P,arguments)},invokeGuardedCallbackAndCatchFirstError:function(a,b,c,d,e,f,g,h,k){P.invokeGuardedCallback.apply(this,arguments);if(P.hasCaughtError()){var q=P.clearCaughtError();P._hasRethrowError||(P._hasRethrowError=!0,P._rethrowError= 2486 q)}},rethrowCaughtError:function(){return Ka.apply(P,arguments)},hasCaughtError:function(){return P._hasCaughtError},clearCaughtError:function(){if(P._hasCaughtError){var a=P._caughtError;P._caughtError=null;P._hasCaughtError=!1;return a}E("198")}};function Ja(a,b,c,d,e,f,g,h,k){P._hasCaughtError=!1;P._caughtError=null;var q=Array.prototype.slice.call(arguments,3);try{b.apply(c,q)}catch(v){P._caughtError=v,P._hasCaughtError=!0}} 2487 function Ka(){if(P._hasRethrowError){var a=P._rethrowError;P._rethrowError=null;P._hasRethrowError=!1;throw a;}}var La=null,Ma={}; 2488 function Na(){if(La)for(var a in Ma){var b=Ma[a],c=La.indexOf(a);-1<c?void 0:E("96",a);if(!Oa[c]){b.extractEvents?void 0:E("97",a);Oa[c]=b;c=b.eventTypes;for(var d in c){var e=void 0;var f=c[d],g=b,h=d;Pa.hasOwnProperty(h)?E("99",h):void 0;Pa[h]=f;var k=f.phasedRegistrationNames;if(k){for(e in k)k.hasOwnProperty(e)&&Qa(k[e],g,h);e=!0}else f.registrationName?(Qa(f.registrationName,g,h),e=!0):e=!1;e?void 0:E("98",d,a)}}}} 2489 function Qa(a,b,c){Ra[a]?E("100",a):void 0;Ra[a]=b;Sa[a]=b.eventTypes[c].dependencies}var Oa=[],Pa={},Ra={},Sa={};function Ta(a){La?E("101"):void 0;La=Array.prototype.slice.call(a);Na()}function Ua(a){var b=!1,c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];Ma.hasOwnProperty(c)&&Ma[c]===d||(Ma[c]?E("102",c):void 0,Ma[c]=d,b=!0)}b&&Na()} 2490 var Va=Object.freeze({plugins:Oa,eventNameDispatchConfigs:Pa,registrationNameModules:Ra,registrationNameDependencies:Sa,possibleRegistrationNames:null,injectEventPluginOrder:Ta,injectEventPluginsByName:Ua}),Wa=null,Xa=null,Ya=null;function Za(a,b,c,d){b=a.type||"unknown-event";a.currentTarget=Ya(d);P.invokeGuardedCallbackAndCatchFirstError(b,c,void 0,a);a.currentTarget=null} 2491 function $a(a,b){null==b?E("30"):void 0;if(null==a)return b;if(Array.isArray(a)){if(Array.isArray(b))return a.push.apply(a,b),a;a.push(b);return a}return Array.isArray(b)?[a].concat(b):[a,b]}function ab(a,b,c){Array.isArray(a)?a.forEach(b,c):a&&b.call(c,a)}var bb=null; 2492 function cb(a,b){if(a){var c=a._dispatchListeners,d=a._dispatchInstances;if(Array.isArray(c))for(var e=0;e<c.length&&!a.isPropagationStopped();e++)Za(a,b,c[e],d[e]);else c&&Za(a,b,c,d);a._dispatchListeners=null;a._dispatchInstances=null;a.isPersistent()||a.constructor.release(a)}}function db(a){return cb(a,!0)}function gb(a){return cb(a,!1)}var hb={injectEventPluginOrder:Ta,injectEventPluginsByName:Ua}; 2493 function ib(a,b){var c=a.stateNode;if(!c)return null;var d=Wa(c);if(!d)return null;c=d[b];a:switch(b){case "onClick":case "onClickCapture":case "onDoubleClick":case "onDoubleClickCapture":case "onMouseDown":case "onMouseDownCapture":case "onMouseMove":case "onMouseMoveCapture":case "onMouseUp":case "onMouseUpCapture":(d=!d.disabled)||(a=a.type,d=!("button"===a||"input"===a||"select"===a||"textarea"===a));a=!d;break a;default:a=!1}if(a)return null;c&&"function"!==typeof c?E("231",b,typeof c):void 0; 2494 return c}function jb(a,b,c,d){for(var e,f=0;f<Oa.length;f++){var g=Oa[f];g&&(g=g.extractEvents(a,b,c,d))&&(e=$a(e,g))}return e}function kb(a){a&&(bb=$a(bb,a))}function lb(a){var b=bb;bb=null;b&&(a?ab(b,db):ab(b,gb),bb?E("95"):void 0,P.rethrowCaughtError())}var mb=Object.freeze({injection:hb,getListener:ib,extractEvents:jb,enqueueEvents:kb,processEventQueue:lb}),nb=Math.random().toString(36).slice(2),Q="__reactInternalInstance$"+nb,ob="__reactEventHandlers$"+nb; 2495 function pb(a){if(a[Q])return a[Q];for(var b=[];!a[Q];)if(b.push(a),a.parentNode)a=a.parentNode;else return null;var c=void 0,d=a[Q];if(5===d.tag||6===d.tag)return d;for(;a&&(d=a[Q]);a=b.pop())c=d;return c}function qb(a){if(5===a.tag||6===a.tag)return a.stateNode;E("33")}function rb(a){return a[ob]||null} 2496 var sb=Object.freeze({precacheFiberNode:function(a,b){b[Q]=a},getClosestInstanceFromNode:pb,getInstanceFromNode:function(a){a=a[Q];return!a||5!==a.tag&&6!==a.tag?null:a},getNodeFromInstance:qb,getFiberCurrentPropsFromNode:rb,updateFiberProps:function(a,b){a[ob]=b}});function tb(a){do a=a["return"];while(a&&5!==a.tag);return a?a:null}function ub(a,b,c){for(var d=[];a;)d.push(a),a=tb(a);for(a=d.length;0<a--;)b(d[a],"captured",c);for(a=0;a<d.length;a++)b(d[a],"bubbled",c)} 2497 function vb(a,b,c){if(b=ib(a,c.dispatchConfig.phasedRegistrationNames[b]))c._dispatchListeners=$a(c._dispatchListeners,b),c._dispatchInstances=$a(c._dispatchInstances,a)}function wb(a){a&&a.dispatchConfig.phasedRegistrationNames&&ub(a._targetInst,vb,a)}function xb(a){if(a&&a.dispatchConfig.phasedRegistrationNames){var b=a._targetInst;b=b?tb(b):null;ub(b,vb,a)}} 2498 function yb(a,b,c){a&&c&&c.dispatchConfig.registrationName&&(b=ib(a,c.dispatchConfig.registrationName))&&(c._dispatchListeners=$a(c._dispatchListeners,b),c._dispatchInstances=$a(c._dispatchInstances,a))}function zb(a){a&&a.dispatchConfig.registrationName&&yb(a._targetInst,null,a)}function Ab(a){ab(a,wb)} 2499 function Bb(a,b,c,d){if(c&&d)a:{var e=c;for(var f=d,g=0,h=e;h;h=tb(h))g++;h=0;for(var k=f;k;k=tb(k))h++;for(;0<g-h;)e=tb(e),g--;for(;0<h-g;)f=tb(f),h--;for(;g--;){if(e===f||e===f.alternate)break a;e=tb(e);f=tb(f)}e=null}else e=null;f=e;for(e=[];c&&c!==f;){g=c.alternate;if(null!==g&&g===f)break;e.push(c);c=tb(c)}for(c=[];d&&d!==f;){g=d.alternate;if(null!==g&&g===f)break;c.push(d);d=tb(d)}for(d=0;d<e.length;d++)yb(e[d],"bubbled",a);for(a=c.length;0<a--;)yb(c[a],"captured",b)} 2500 var Cb=Object.freeze({accumulateTwoPhaseDispatches:Ab,accumulateTwoPhaseDispatchesSkipTarget:function(a){ab(a,xb)},accumulateEnterLeaveDispatches:Bb,accumulateDirectDispatches:function(a){ab(a,zb)}}),Db=null;function Eb(){!Db&&l.canUseDOM&&(Db="textContent"in document.documentElement?"textContent":"innerText");return Db}var S={_root:null,_startText:null,_fallbackText:null}; 2501 function Fb(){if(S._fallbackText)return S._fallbackText;var a,b=S._startText,c=b.length,d,e=Gb(),f=e.length;for(a=0;a<c&&b[a]===e[a];a++);var g=c-a;for(d=1;d<=g&&b[c-d]===e[f-d];d++);S._fallbackText=e.slice(a,1<d?1-d:void 0);return S._fallbackText}function Gb(){return"value"in S._root?S._root.value:S._root[Eb()]} 2502 var Hb="dispatchConfig _targetInst nativeEvent isDefaultPrevented isPropagationStopped _dispatchListeners _dispatchInstances".split(" "),Ib={type:null,target:null,currentTarget:C.thatReturnsNull,eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null}; 2503 function T(a,b,c,d){this.dispatchConfig=a;this._targetInst=b;this.nativeEvent=c;a=this.constructor.Interface;for(var e in a)a.hasOwnProperty(e)&&((b=a[e])?this[e]=b(c):"target"===e?this.target=d:this[e]=c[e]);this.isDefaultPrevented=(null!=c.defaultPrevented?c.defaultPrevented:!1===c.returnValue)?C.thatReturnsTrue:C.thatReturnsFalse;this.isPropagationStopped=C.thatReturnsFalse;return this} 2504 B(T.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():"unknown"!==typeof a.returnValue&&(a.returnValue=!1),this.isDefaultPrevented=C.thatReturnsTrue)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():"unknown"!==typeof a.cancelBubble&&(a.cancelBubble=!0),this.isPropagationStopped=C.thatReturnsTrue)},persist:function(){this.isPersistent=C.thatReturnsTrue},isPersistent:C.thatReturnsFalse, 2505 destructor:function(){var a=this.constructor.Interface,b;for(b in a)this[b]=null;for(a=0;a<Hb.length;a++)this[Hb[a]]=null}});T.Interface=Ib;T.augmentClass=function(a,b){function c(){}c.prototype=this.prototype;var d=new c;B(d,a.prototype);a.prototype=d;a.prototype.constructor=a;a.Interface=B({},this.Interface,b);a.augmentClass=this.augmentClass;Jb(a)};Jb(T);function Kb(a,b,c,d){if(this.eventPool.length){var e=this.eventPool.pop();this.call(e,a,b,c,d);return e}return new this(a,b,c,d)} 2506 function Lb(a){a instanceof this?void 0:E("223");a.destructor();10>this.eventPool.length&&this.eventPool.push(a)}function Jb(a){a.eventPool=[];a.getPooled=Kb;a.release=Lb}function Mb(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(Mb,{data:null});function Nb(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(Nb,{data:null});var Pb=[9,13,27,32],Vb=l.canUseDOM&&"CompositionEvent"in window,Wb=null;l.canUseDOM&&"documentMode"in document&&(Wb=document.documentMode);var Xb; 2507 if(Xb=l.canUseDOM&&"TextEvent"in window&&!Wb){var Yb=window.opera;Xb=!("object"===typeof Yb&&"function"===typeof Yb.version&&12>=parseInt(Yb.version(),10))} 2508 var Zb=Xb,$b=l.canUseDOM&&(!Vb||Wb&&8<Wb&&11>=Wb),ac=String.fromCharCode(32),bc={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"topBlur topCompositionEnd topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart", 2509 captured:"onCompositionStartCapture"},dependencies:"topBlur topCompositionStart topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"topBlur topCompositionUpdate topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")}},cc=!1; 2510 function dc(a,b){switch(a){case "topKeyUp":return-1!==Pb.indexOf(b.keyCode);case "topKeyDown":return 229!==b.keyCode;case "topKeyPress":case "topMouseDown":case "topBlur":return!0;default:return!1}}function ec(a){a=a.detail;return"object"===typeof a&&"data"in a?a.data:null}var fc=!1;function gc(a,b){switch(a){case "topCompositionEnd":return ec(b);case "topKeyPress":if(32!==b.which)return null;cc=!0;return ac;case "topTextInput":return a=b.data,a===ac&&cc?null:a;default:return null}} 2511 function hc(a,b){if(fc)return"topCompositionEnd"===a||!Vb&&dc(a,b)?(a=Fb(),S._root=null,S._startText=null,S._fallbackText=null,fc=!1,a):null;switch(a){case "topPaste":return null;case "topKeyPress":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1<b.char.length)return b.char;if(b.which)return String.fromCharCode(b.which)}return null;case "topCompositionEnd":return $b?null:b.data;default:return null}} 2512 var ic={eventTypes:bc,extractEvents:function(a,b,c,d){var e;if(Vb)b:{switch(a){case "topCompositionStart":var f=bc.compositionStart;break b;case "topCompositionEnd":f=bc.compositionEnd;break b;case "topCompositionUpdate":f=bc.compositionUpdate;break b}f=void 0}else fc?dc(a,c)&&(f=bc.compositionEnd):"topKeyDown"===a&&229===c.keyCode&&(f=bc.compositionStart);f?($b&&(fc||f!==bc.compositionStart?f===bc.compositionEnd&&fc&&(e=Fb()):(S._root=d,S._startText=Gb(),fc=!0)),f=Mb.getPooled(f,b,c,d),e?f.data= 2513 e:(e=ec(c),null!==e&&(f.data=e)),Ab(f),e=f):e=null;(a=Zb?gc(a,c):hc(a,c))?(b=Nb.getPooled(bc.beforeInput,b,c,d),b.data=a,Ab(b)):b=null;return[e,b]}},jc=null,kc=null,lc=null;function mc(a){if(a=Xa(a)){jc&&"function"===typeof jc.restoreControlledState?void 0:E("194");var b=Wa(a.stateNode);jc.restoreControlledState(a.stateNode,a.type,b)}}var nc={injectFiberControlledHostComponent:function(a){jc=a}};function oc(a){kc?lc?lc.push(a):lc=[a]:kc=a} 2514 function pc(){if(kc){var a=kc,b=lc;lc=kc=null;mc(a);if(b)for(a=0;a<b.length;a++)mc(b[a])}}var qc=Object.freeze({injection:nc,enqueueStateRestore:oc,restoreStateIfNeeded:pc});function rc(a,b){return a(b)}var sc=!1;function tc(a,b){if(sc)return rc(a,b);sc=!0;try{return rc(a,b)}finally{sc=!1,pc()}}var uc={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0}; 2515 function vc(a){var b=a&&a.nodeName&&a.nodeName.toLowerCase();return"input"===b?!!uc[a.type]:"textarea"===b?!0:!1}function wc(a){a=a.target||a.srcElement||window;a.correspondingUseElement&&(a=a.correspondingUseElement);return 3===a.nodeType?a.parentNode:a}var xc;l.canUseDOM&&(xc=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")); 2516 function yc(a,b){if(!l.canUseDOM||b&&!("addEventListener"in document))return!1;b="on"+a;var c=b in document;c||(c=document.createElement("div"),c.setAttribute(b,"return;"),c="function"===typeof c[b]);!c&&xc&&"wheel"===a&&(c=document.implementation.hasFeature("Events.wheel","3.0"));return c}function zc(a){var b=a.type;return(a=a.nodeName)&&"input"===a.toLowerCase()&&("checkbox"===b||"radio"===b)} 2517 function Ac(a){var b=zc(a)?"checked":"value",c=Object.getOwnPropertyDescriptor(a.constructor.prototype,b),d=""+a[b];if(!a.hasOwnProperty(b)&&"function"===typeof c.get&&"function"===typeof c.set)return Object.defineProperty(a,b,{enumerable:c.enumerable,configurable:!0,get:function(){return c.get.call(this)},set:function(a){d=""+a;c.set.call(this,a)}}),{getValue:function(){return d},setValue:function(a){d=""+a},stopTracking:function(){a._valueTracker=null;delete a[b]}}} 2518 function Bc(a){a._valueTracker||(a._valueTracker=Ac(a))}function Cc(a){if(!a)return!1;var b=a._valueTracker;if(!b)return!0;var c=b.getValue();var d="";a&&(d=zc(a)?a.checked?"true":"false":a.value);a=d;return a!==c?(b.setValue(a),!0):!1}var Dc={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"topBlur topChange topClick topFocus topInput topKeyDown topKeyUp topSelectionChange".split(" ")}}; 2519 function Ec(a,b,c){a=T.getPooled(Dc.change,a,b,c);a.type="change";oc(c);Ab(a);return a}var Fc=null,Gc=null;function Hc(a){kb(a);lb(!1)}function Ic(a){var b=qb(a);if(Cc(b))return a}function Jc(a,b){if("topChange"===a)return b}var Kc=!1;l.canUseDOM&&(Kc=yc("input")&&(!document.documentMode||9<document.documentMode));function Lc(){Fc&&(Fc.detachEvent("onpropertychange",Mc),Gc=Fc=null)}function Mc(a){"value"===a.propertyName&&Ic(Gc)&&(a=Ec(Gc,a,wc(a)),tc(Hc,a))} 2520 function Nc(a,b,c){"topFocus"===a?(Lc(),Fc=b,Gc=c,Fc.attachEvent("onpropertychange",Mc)):"topBlur"===a&&Lc()}function Oc(a){if("topSelectionChange"===a||"topKeyUp"===a||"topKeyDown"===a)return Ic(Gc)}function Pc(a,b){if("topClick"===a)return Ic(b)}function $c(a,b){if("topInput"===a||"topChange"===a)return Ic(b)} 2521 var ad={eventTypes:Dc,_isInputEventSupported:Kc,extractEvents:function(a,b,c,d){var e=b?qb(b):window,f=e.nodeName&&e.nodeName.toLowerCase();if("select"===f||"input"===f&&"file"===e.type)var g=Jc;else if(vc(e))if(Kc)g=$c;else{g=Oc;var h=Nc}else f=e.nodeName,!f||"input"!==f.toLowerCase()||"checkbox"!==e.type&&"radio"!==e.type||(g=Pc);if(g&&(g=g(a,b)))return Ec(g,c,d);h&&h(a,e,b);"topBlur"===a&&null!=b&&(a=b._wrapperState||e._wrapperState)&&a.controlled&&"number"===e.type&&(a=""+e.value,e.getAttribute("value")!== 2522 a&&e.setAttribute("value",a))}};function bd(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(bd,{view:null,detail:null});var cd={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dd(a){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(a):(a=cd[a])?!!b[a]:!1}function ed(){return dd}function fd(a,b,c,d){return T.call(this,a,b,c,d)} 2523 bd.augmentClass(fd,{screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:ed,button:null,buttons:null,relatedTarget:function(a){return a.relatedTarget||(a.fromElement===a.srcElement?a.toElement:a.fromElement)}}); 2524 var gd={mouseEnter:{registrationName:"onMouseEnter",dependencies:["topMouseOut","topMouseOver"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["topMouseOut","topMouseOver"]}},hd={eventTypes:gd,extractEvents:function(a,b,c,d){if("topMouseOver"===a&&(c.relatedTarget||c.fromElement)||"topMouseOut"!==a&&"topMouseOver"!==a)return null;var e=d.window===d?d:(e=d.ownerDocument)?e.defaultView||e.parentWindow:window;"topMouseOut"===a?(a=b,b=(b=c.relatedTarget||c.toElement)?pb(b):null):a=null;if(a=== 2525 b)return null;var f=null==a?e:qb(a);e=null==b?e:qb(b);var g=fd.getPooled(gd.mouseLeave,a,c,d);g.type="mouseleave";g.target=f;g.relatedTarget=e;c=fd.getPooled(gd.mouseEnter,b,c,d);c.type="mouseenter";c.target=e;c.relatedTarget=f;Bb(g,c,a,b);return[g,c]}},id=aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;function jd(a){a=a.type;return"string"===typeof a?a:"function"===typeof a?a.displayName||a.name:null} 2526 function kd(a){var b=a;if(a.alternate)for(;b["return"];)b=b["return"];else{if(0!==(b.effectTag&2))return 1;for(;b["return"];)if(b=b["return"],0!==(b.effectTag&2))return 1}return 3===b.tag?2:3}function ld(a){return(a=a._reactInternalFiber)?2===kd(a):!1}function md(a){2!==kd(a)?E("188"):void 0} 2527 function nd(a){var b=a.alternate;if(!b)return b=kd(a),3===b?E("188"):void 0,1===b?null:a;for(var c=a,d=b;;){var e=c["return"],f=e?e.alternate:null;if(!e||!f)break;if(e.child===f.child){for(var g=e.child;g;){if(g===c)return md(e),a;if(g===d)return md(e),b;g=g.sibling}E("188")}if(c["return"]!==d["return"])c=e,d=f;else{g=!1;for(var h=e.child;h;){if(h===c){g=!0;c=e;d=f;break}if(h===d){g=!0;d=e;c=f;break}h=h.sibling}if(!g){for(h=f.child;h;){if(h===c){g=!0;c=f;d=e;break}if(h===d){g=!0;d=f;c=e;break}h=h.sibling}g? 2528 void 0:E("189")}}c.alternate!==d?E("190"):void 0}3!==c.tag?E("188"):void 0;return c.stateNode.current===c?a:b}function od(a){a=nd(a);if(!a)return null;for(var b=a;;){if(5===b.tag||6===b.tag)return b;if(b.child)b.child["return"]=b,b=b.child;else{if(b===a)break;for(;!b.sibling;){if(!b["return"]||b["return"]===a)return null;b=b["return"]}b.sibling["return"]=b["return"];b=b.sibling}}return null} 2529 function pd(a){a=nd(a);if(!a)return null;for(var b=a;;){if(5===b.tag||6===b.tag)return b;if(b.child&&4!==b.tag)b.child["return"]=b,b=b.child;else{if(b===a)break;for(;!b.sibling;){if(!b["return"]||b["return"]===a)return null;b=b["return"]}b.sibling["return"]=b["return"];b=b.sibling}}return null}var qd=[]; 2530 function rd(a){var b=a.targetInst;do{if(!b){a.ancestors.push(b);break}var c;for(c=b;c["return"];)c=c["return"];c=3!==c.tag?null:c.stateNode.containerInfo;if(!c)break;a.ancestors.push(b);b=pb(c)}while(b);for(c=0;c<a.ancestors.length;c++)b=a.ancestors[c],sd(a.topLevelType,b,a.nativeEvent,wc(a.nativeEvent))}var td=!0,sd=void 0;function ud(a){td=!!a}function U(a,b,c){return c?ba.listen(c,b,vd.bind(null,a)):null}function wd(a,b,c){return c?ba.capture(c,b,vd.bind(null,a)):null} 2531 function vd(a,b){if(td){var c=wc(b);c=pb(c);null===c||"number"!==typeof c.tag||2===kd(c)||(c=null);if(qd.length){var d=qd.pop();d.topLevelType=a;d.nativeEvent=b;d.targetInst=c;a=d}else a={topLevelType:a,nativeEvent:b,targetInst:c,ancestors:[]};try{tc(rd,a)}finally{a.topLevelType=null,a.nativeEvent=null,a.targetInst=null,a.ancestors.length=0,10>qd.length&&qd.push(a)}}} 2532 var xd=Object.freeze({get _enabled(){return td},get _handleTopLevel(){return sd},setHandleTopLevel:function(a){sd=a},setEnabled:ud,isEnabled:function(){return td},trapBubbledEvent:U,trapCapturedEvent:wd,dispatchEvent:vd});function yd(a,b){var c={};c[a.toLowerCase()]=b.toLowerCase();c["Webkit"+a]="webkit"+b;c["Moz"+a]="moz"+b;c["ms"+a]="MS"+b;c["O"+a]="o"+b.toLowerCase();return c} 2533 var zd={animationend:yd("Animation","AnimationEnd"),animationiteration:yd("Animation","AnimationIteration"),animationstart:yd("Animation","AnimationStart"),transitionend:yd("Transition","TransitionEnd")},Ad={},Bd={};l.canUseDOM&&(Bd=document.createElement("div").style,"AnimationEvent"in window||(delete zd.animationend.animation,delete zd.animationiteration.animation,delete zd.animationstart.animation),"TransitionEvent"in window||delete zd.transitionend.transition); 2534 function Cd(a){if(Ad[a])return Ad[a];if(!zd[a])return a;var b=zd[a],c;for(c in b)if(b.hasOwnProperty(c)&&c in Bd)return Ad[a]=b[c];return""} 2535 var Dd={topAbort:"abort",topAnimationEnd:Cd("animationend")||"animationend",topAnimationIteration:Cd("animationiteration")||"animationiteration",topAnimationStart:Cd("animationstart")||"animationstart",topBlur:"blur",topCancel:"cancel",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topClose:"close",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy", 2536 topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoad:"load",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart", 2537 topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topToggle:"toggle",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove", 2538 topTouchStart:"touchstart",topTransitionEnd:Cd("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"},Ed={},Fd=0,Gd="_reactListenersID"+(""+Math.random()).slice(2);function Hd(a){Object.prototype.hasOwnProperty.call(a,Gd)||(a[Gd]=Fd++,Ed[a[Gd]]={});return Ed[a[Gd]]}function Id(a){for(;a&&a.firstChild;)a=a.firstChild;return a} 2539 function Jd(a,b){var c=Id(a);a=0;for(var d;c;){if(3===c.nodeType){d=a+c.textContent.length;if(a<=b&&d>=b)return{node:c,offset:b-a};a=d}a:{for(;c;){if(c.nextSibling){c=c.nextSibling;break a}c=c.parentNode}c=void 0}c=Id(c)}}function Kd(a){var b=a&&a.nodeName&&a.nodeName.toLowerCase();return b&&("input"===b&&"text"===a.type||"textarea"===b||"true"===a.contentEditable)} 2540 var Ld=l.canUseDOM&&"documentMode"in document&&11>=document.documentMode,Md={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"topBlur topContextMenu topFocus topKeyDown topKeyUp topMouseDown topMouseUp topSelectionChange".split(" ")}},Nd=null,Od=null,Pd=null,Qd=!1; 2541 function Rd(a,b){if(Qd||null==Nd||Nd!==da())return null;var c=Nd;"selectionStart"in c&&Kd(c)?c={start:c.selectionStart,end:c.selectionEnd}:window.getSelection?(c=window.getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}):c=void 0;return Pd&&ea(Pd,c)?null:(Pd=c,a=T.getPooled(Md.select,Od,a,b),a.type="select",a.target=Nd,Ab(a),a)} 2542 var Sd={eventTypes:Md,extractEvents:function(a,b,c,d){var e=d.window===d?d.document:9===d.nodeType?d:d.ownerDocument,f;if(!(f=!e)){a:{e=Hd(e);f=Sa.onSelect;for(var g=0;g<f.length;g++){var h=f[g];if(!e.hasOwnProperty(h)||!e[h]){e=!1;break a}}e=!0}f=!e}if(f)return null;e=b?qb(b):window;switch(a){case "topFocus":if(vc(e)||"true"===e.contentEditable)Nd=e,Od=b,Pd=null;break;case "topBlur":Pd=Od=Nd=null;break;case "topMouseDown":Qd=!0;break;case "topContextMenu":case "topMouseUp":return Qd=!1,Rd(c,d);case "topSelectionChange":if(Ld)break; 2543 case "topKeyDown":case "topKeyUp":return Rd(c,d)}return null}};function Td(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(Td,{animationName:null,elapsedTime:null,pseudoElement:null});function Ud(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(Ud,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}});function Vd(a,b,c,d){return T.call(this,a,b,c,d)}bd.augmentClass(Vd,{relatedTarget:null}); 2544 function Wd(a){var b=a.keyCode;"charCode"in a?(a=a.charCode,0===a&&13===b&&(a=13)):a=b;return 32<=a||13===a?a:0} 2545 var Xd={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Yd={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4", 2546 116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};function Zd(a,b,c,d){return T.call(this,a,b,c,d)} 2547 bd.augmentClass(Zd,{key:function(a){if(a.key){var b=Xd[a.key]||a.key;if("Unidentified"!==b)return b}return"keypress"===a.type?(a=Wd(a),13===a?"Enter":String.fromCharCode(a)):"keydown"===a.type||"keyup"===a.type?Yd[a.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:ed,charCode:function(a){return"keypress"===a.type?Wd(a):0},keyCode:function(a){return"keydown"===a.type||"keyup"===a.type?a.keyCode:0},which:function(a){return"keypress"=== 2548 a.type?Wd(a):"keydown"===a.type||"keyup"===a.type?a.keyCode:0}});function $d(a,b,c,d){return T.call(this,a,b,c,d)}fd.augmentClass($d,{dataTransfer:null});function ae(a,b,c,d){return T.call(this,a,b,c,d)}bd.augmentClass(ae,{touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:ed});function be(a,b,c,d){return T.call(this,a,b,c,d)}T.augmentClass(be,{propertyName:null,elapsedTime:null,pseudoElement:null}); 2549 function ce(a,b,c,d){return T.call(this,a,b,c,d)}fd.augmentClass(ce,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:null,deltaMode:null});var de={},ee={}; 2550 "abort animationEnd animationIteration animationStart blur cancel canPlay canPlayThrough click close contextMenu copy cut doubleClick drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error focus input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing progress rateChange reset scroll seeked seeking stalled submit suspend timeUpdate toggle touchCancel touchEnd touchMove touchStart transitionEnd volumeChange waiting wheel".split(" ").forEach(function(a){var b=a[0].toUpperCase()+ 2551 a.slice(1),c="on"+b;b="top"+b;c={phasedRegistrationNames:{bubbled:c,captured:c+"Capture"},dependencies:[b]};de[a]=c;ee[b]=c}); 2552 var fe={eventTypes:de,extractEvents:function(a,b,c,d){var e=ee[a];if(!e)return null;switch(a){case "topKeyPress":if(0===Wd(c))return null;case "topKeyDown":case "topKeyUp":a=Zd;break;case "topBlur":case "topFocus":a=Vd;break;case "topClick":if(2===c.button)return null;case "topDoubleClick":case "topMouseDown":case "topMouseMove":case "topMouseUp":case "topMouseOut":case "topMouseOver":case "topContextMenu":a=fd;break;case "topDrag":case "topDragEnd":case "topDragEnter":case "topDragExit":case "topDragLeave":case "topDragOver":case "topDragStart":case "topDrop":a= 2553 $d;break;case "topTouchCancel":case "topTouchEnd":case "topTouchMove":case "topTouchStart":a=ae;break;case "topAnimationEnd":case "topAnimationIteration":case "topAnimationStart":a=Td;break;case "topTransitionEnd":a=be;break;case "topScroll":a=bd;break;case "topWheel":a=ce;break;case "topCopy":case "topCut":case "topPaste":a=Ud;break;default:a=T}b=a.getPooled(e,b,c,d);Ab(b);return b}};sd=function(a,b,c,d){a=jb(a,b,c,d);kb(a);lb(!1)};hb.injectEventPluginOrder("ResponderEventPlugin SimpleEventPlugin TapEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" ")); 2554 Wa=sb.getFiberCurrentPropsFromNode;Xa=sb.getInstanceFromNode;Ya=sb.getNodeFromInstance;hb.injectEventPluginsByName({SimpleEventPlugin:fe,EnterLeaveEventPlugin:hd,ChangeEventPlugin:ad,SelectEventPlugin:Sd,BeforeInputEventPlugin:ic});var ge=[],he=-1;function V(a){0>he||(a.current=ge[he],ge[he]=null,he--)}function W(a,b){he++;ge[he]=a.current;a.current=b}new Set;var ie={current:D},X={current:!1},je=D;function ke(a){return le(a)?je:ie.current} 2555 function me(a,b){var c=a.type.contextTypes;if(!c)return D;var d=a.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===b)return d.__reactInternalMemoizedMaskedChildContext;var e={},f;for(f in c)e[f]=b[f];d&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=b,a.__reactInternalMemoizedMaskedChildContext=e);return e}function le(a){return 2===a.tag&&null!=a.type.childContextTypes}function ne(a){le(a)&&(V(X,a),V(ie,a))} 2556 function oe(a,b,c){null!=ie.cursor?E("168"):void 0;W(ie,b,a);W(X,c,a)}function pe(a,b){var c=a.stateNode,d=a.type.childContextTypes;if("function"!==typeof c.getChildContext)return b;c=c.getChildContext();for(var e in c)e in d?void 0:E("108",jd(a)||"Unknown",e);return B({},b,c)}function qe(a){if(!le(a))return!1;var b=a.stateNode;b=b&&b.__reactInternalMemoizedMergedChildContext||D;je=ie.current;W(ie,b,a);W(X,X.current,a);return!0} 2557 function re(a,b){var c=a.stateNode;c?void 0:E("169");if(b){var d=pe(a,je);c.__reactInternalMemoizedMergedChildContext=d;V(X,a);V(ie,a);W(ie,d,a)}else V(X,a);W(X,b,a)} 2558 function Y(a,b,c){this.tag=a;this.key=b;this.stateNode=this.type=null;this.sibling=this.child=this["return"]=null;this.index=0;this.memoizedState=this.updateQueue=this.memoizedProps=this.pendingProps=this.ref=null;this.internalContextTag=c;this.effectTag=0;this.lastEffect=this.firstEffect=this.nextEffect=null;this.expirationTime=0;this.alternate=null} 2559 function se(a,b,c){var d=a.alternate;null===d?(d=new Y(a.tag,a.key,a.internalContextTag),d.type=a.type,d.stateNode=a.stateNode,d.alternate=a,a.alternate=d):(d.effectTag=0,d.nextEffect=null,d.firstEffect=null,d.lastEffect=null);d.expirationTime=c;d.pendingProps=b;d.child=a.child;d.memoizedProps=a.memoizedProps;d.memoizedState=a.memoizedState;d.updateQueue=a.updateQueue;d.sibling=a.sibling;d.index=a.index;d.ref=a.ref;return d} 2560 function te(a,b,c){var d=void 0,e=a.type,f=a.key;"function"===typeof e?(d=e.prototype&&e.prototype.isReactComponent?new Y(2,f,b):new Y(0,f,b),d.type=e,d.pendingProps=a.props):"string"===typeof e?(d=new Y(5,f,b),d.type=e,d.pendingProps=a.props):"object"===typeof e&&null!==e&&"number"===typeof e.tag?(d=e,d.pendingProps=a.props):E("130",null==e?e:typeof e,"");d.expirationTime=c;return d}function ue(a,b,c,d){b=new Y(10,d,b);b.pendingProps=a;b.expirationTime=c;return b} 2561 function ve(a,b,c){b=new Y(6,null,b);b.pendingProps=a;b.expirationTime=c;return b}function we(a,b,c){b=new Y(7,a.key,b);b.type=a.handler;b.pendingProps=a;b.expirationTime=c;return b}function xe(a,b,c){a=new Y(9,null,b);a.expirationTime=c;return a}function ye(a,b,c){b=new Y(4,a.key,b);b.pendingProps=a.children||[];b.expirationTime=c;b.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation};return b}var ze=null,Ae=null; 2562 function Be(a){return function(b){try{return a(b)}catch(c){}}}function Ce(a){if("undefined"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var b=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(b.isDisabled||!b.supportsFiber)return!0;try{var c=b.inject(a);ze=Be(function(a){return b.onCommitFiberRoot(c,a)});Ae=Be(function(a){return b.onCommitFiberUnmount(c,a)})}catch(d){}return!0}function De(a){"function"===typeof ze&&ze(a)}function Ee(a){"function"===typeof Ae&&Ae(a)} 2563 function Fe(a){return{baseState:a,expirationTime:0,first:null,last:null,callbackList:null,hasForceUpdate:!1,isInitialized:!1}}function Ge(a,b){null===a.last?a.first=a.last=b:(a.last.next=b,a.last=b);if(0===a.expirationTime||a.expirationTime>b.expirationTime)a.expirationTime=b.expirationTime} 2564 function He(a,b){var c=a.alternate,d=a.updateQueue;null===d&&(d=a.updateQueue=Fe(null));null!==c?(a=c.updateQueue,null===a&&(a=c.updateQueue=Fe(null))):a=null;a=a!==d?a:null;null===a?Ge(d,b):null===d.last||null===a.last?(Ge(d,b),Ge(a,b)):(Ge(d,b),a.last=b)}function Ie(a,b,c,d){a=a.partialState;return"function"===typeof a?a.call(b,c,d):a} 2565 function Je(a,b,c,d,e,f){null!==a&&a.updateQueue===c&&(c=b.updateQueue={baseState:c.baseState,expirationTime:c.expirationTime,first:c.first,last:c.last,isInitialized:c.isInitialized,callbackList:null,hasForceUpdate:!1});c.expirationTime=0;c.isInitialized?a=c.baseState:(a=c.baseState=b.memoizedState,c.isInitialized=!0);for(var g=!0,h=c.first,k=!1;null!==h;){var q=h.expirationTime;if(q>f){var v=c.expirationTime;if(0===v||v>q)c.expirationTime=q;k||(k=!0,c.baseState=a)}else{k||(c.first=h.next,null=== 2566 c.first&&(c.last=null));if(h.isReplace)a=Ie(h,d,a,e),g=!0;else if(q=Ie(h,d,a,e))a=g?B({},a,q):B(a,q),g=!1;h.isForced&&(c.hasForceUpdate=!0);null!==h.callback&&(q=c.callbackList,null===q&&(q=c.callbackList=[]),q.push(h))}h=h.next}null!==c.callbackList?b.effectTag|=32:null!==c.first||c.hasForceUpdate||(b.updateQueue=null);k||(c.baseState=a);return a} 2567 function Ke(a,b){var c=a.callbackList;if(null!==c)for(a.callbackList=null,a=0;a<c.length;a++){var d=c[a],e=d.callback;d.callback=null;"function"!==typeof e?E("191",e):void 0;e.call(b)}} 2568 function Le(a,b,c,d){function e(a,b){b.updater=f;a.stateNode=b;b._reactInternalFiber=a}var f={isMounted:ld,enqueueSetState:function(c,d,e){c=c._reactInternalFiber;e=void 0===e?null:e;var g=b(c);He(c,{expirationTime:g,partialState:d,callback:e,isReplace:!1,isForced:!1,nextCallback:null,next:null});a(c,g)},enqueueReplaceState:function(c,d,e){c=c._reactInternalFiber;e=void 0===e?null:e;var g=b(c);He(c,{expirationTime:g,partialState:d,callback:e,isReplace:!0,isForced:!1,nextCallback:null,next:null}); 2569 a(c,g)},enqueueForceUpdate:function(c,d){c=c._reactInternalFiber;d=void 0===d?null:d;var e=b(c);He(c,{expirationTime:e,partialState:null,callback:d,isReplace:!1,isForced:!0,nextCallback:null,next:null});a(c,e)}};return{adoptClassInstance:e,constructClassInstance:function(a,b){var c=a.type,d=ke(a),f=2===a.tag&&null!=a.type.contextTypes,g=f?me(a,d):D;b=new c(b,g);e(a,b);f&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=d,a.__reactInternalMemoizedMaskedChildContext=g);return b},mountClassInstance:function(a, 2570 b){var c=a.alternate,d=a.stateNode,e=d.state||null,g=a.pendingProps;g?void 0:E("158");var h=ke(a);d.props=g;d.state=a.memoizedState=e;d.refs=D;d.context=me(a,h);null!=a.type&&null!=a.type.prototype&&!0===a.type.prototype.unstable_isAsyncReactComponent&&(a.internalContextTag|=1);"function"===typeof d.componentWillMount&&(e=d.state,d.componentWillMount(),e!==d.state&&f.enqueueReplaceState(d,d.state,null),e=a.updateQueue,null!==e&&(d.state=Je(c,a,e,d,g,b)));"function"===typeof d.componentDidMount&&(a.effectTag|= 2571 4)},updateClassInstance:function(a,b,e){var g=b.stateNode;g.props=b.memoizedProps;g.state=b.memoizedState;var h=b.memoizedProps,k=b.pendingProps;k||(k=h,null==k?E("159"):void 0);var u=g.context,z=ke(b);z=me(b,z);"function"!==typeof g.componentWillReceiveProps||h===k&&u===z||(u=g.state,g.componentWillReceiveProps(k,z),g.state!==u&&f.enqueueReplaceState(g,g.state,null));u=b.memoizedState;e=null!==b.updateQueue?Je(a,b,b.updateQueue,g,k,e):u;if(!(h!==k||u!==e||X.current||null!==b.updateQueue&&b.updateQueue.hasForceUpdate))return"function"!== 2572 typeof g.componentDidUpdate||h===a.memoizedProps&&u===a.memoizedState||(b.effectTag|=4),!1;var G=k;if(null===h||null!==b.updateQueue&&b.updateQueue.hasForceUpdate)G=!0;else{var I=b.stateNode,L=b.type;G="function"===typeof I.shouldComponentUpdate?I.shouldComponentUpdate(G,e,z):L.prototype&&L.prototype.isPureReactComponent?!ea(h,G)||!ea(u,e):!0}G?("function"===typeof g.componentWillUpdate&&g.componentWillUpdate(k,e,z),"function"===typeof g.componentDidUpdate&&(b.effectTag|=4)):("function"!==typeof g.componentDidUpdate|| 2573 h===a.memoizedProps&&u===a.memoizedState||(b.effectTag|=4),c(b,k),d(b,e));g.props=k;g.state=e;g.context=z;return G}}}var Qe="function"===typeof Symbol&&Symbol["for"],Re=Qe?Symbol["for"]("react.element"):60103,Se=Qe?Symbol["for"]("react.call"):60104,Te=Qe?Symbol["for"]("react.return"):60105,Ue=Qe?Symbol["for"]("react.portal"):60106,Ve=Qe?Symbol["for"]("react.fragment"):60107,We="function"===typeof Symbol&&Symbol.iterator; 2574 function Xe(a){if(null===a||"undefined"===typeof a)return null;a=We&&a[We]||a["@@iterator"];return"function"===typeof a?a:null}var Ye=Array.isArray; 2575 function Ze(a,b){var c=b.ref;if(null!==c&&"function"!==typeof c){if(b._owner){b=b._owner;var d=void 0;b&&(2!==b.tag?E("110"):void 0,d=b.stateNode);d?void 0:E("147",c);var e=""+c;if(null!==a&&null!==a.ref&&a.ref._stringRef===e)return a.ref;a=function(a){var b=d.refs===D?d.refs={}:d.refs;null===a?delete b[e]:b[e]=a};a._stringRef=e;return a}"string"!==typeof c?E("148"):void 0;b._owner?void 0:E("149",c)}return c} 2576 function $e(a,b){"textarea"!==a.type&&E("31","[object Object]"===Object.prototype.toString.call(b)?"object with keys {"+Object.keys(b).join(", ")+"}":b,"")} 2577 function af(a){function b(b,c){if(a){var d=b.lastEffect;null!==d?(d.nextEffect=c,b.lastEffect=c):b.firstEffect=b.lastEffect=c;c.nextEffect=null;c.effectTag=8}}function c(c,d){if(!a)return null;for(;null!==d;)b(c,d),d=d.sibling;return null}function d(a,b){for(a=new Map;null!==b;)null!==b.key?a.set(b.key,b):a.set(b.index,b),b=b.sibling;return a}function e(a,b,c){a=se(a,b,c);a.index=0;a.sibling=null;return a}function f(b,c,d){b.index=d;if(!a)return c;d=b.alternate;if(null!==d)return d=d.index,d<c?(b.effectTag= 2578 2,c):d;b.effectTag=2;return c}function g(b){a&&null===b.alternate&&(b.effectTag=2);return b}function h(a,b,c,d){if(null===b||6!==b.tag)return b=ve(c,a.internalContextTag,d),b["return"]=a,b;b=e(b,c,d);b["return"]=a;return b}function k(a,b,c,d){if(null!==b&&b.type===c.type)return d=e(b,c.props,d),d.ref=Ze(b,c),d["return"]=a,d;d=te(c,a.internalContextTag,d);d.ref=Ze(b,c);d["return"]=a;return d}function q(a,b,c,d){if(null===b||7!==b.tag)return b=we(c,a.internalContextTag,d),b["return"]=a,b;b=e(b,c,d); 2579 b["return"]=a;return b}function v(a,b,c,d){if(null===b||9!==b.tag)return b=xe(c,a.internalContextTag,d),b.type=c.value,b["return"]=a,b;b=e(b,null,d);b.type=c.value;b["return"]=a;return b}function y(a,b,c,d){if(null===b||4!==b.tag||b.stateNode.containerInfo!==c.containerInfo||b.stateNode.implementation!==c.implementation)return b=ye(c,a.internalContextTag,d),b["return"]=a,b;b=e(b,c.children||[],d);b["return"]=a;return b}function u(a,b,c,d,f){if(null===b||10!==b.tag)return b=ue(c,a.internalContextTag, 2580 d,f),b["return"]=a,b;b=e(b,c,d);b["return"]=a;return b}function z(a,b,c){if("string"===typeof b||"number"===typeof b)return b=ve(""+b,a.internalContextTag,c),b["return"]=a,b;if("object"===typeof b&&null!==b){switch(b.$$typeof){case Re:if(b.type===Ve)return b=ue(b.props.children,a.internalContextTag,c,b.key),b["return"]=a,b;c=te(b,a.internalContextTag,c);c.ref=Ze(null,b);c["return"]=a;return c;case Se:return b=we(b,a.internalContextTag,c),b["return"]=a,b;case Te:return c=xe(b,a.internalContextTag, 2581 c),c.type=b.value,c["return"]=a,c;case Ue:return b=ye(b,a.internalContextTag,c),b["return"]=a,b}if(Ye(b)||Xe(b))return b=ue(b,a.internalContextTag,c,null),b["return"]=a,b;$e(a,b)}return null}function G(a,b,c,d){var e=null!==b?b.key:null;if("string"===typeof c||"number"===typeof c)return null!==e?null:h(a,b,""+c,d);if("object"===typeof c&&null!==c){switch(c.$$typeof){case Re:return c.key===e?c.type===Ve?u(a,b,c.props.children,d,e):k(a,b,c,d):null;case Se:return c.key===e?q(a,b,c,d):null;case Te:return null=== 2582 e?v(a,b,c,d):null;case Ue:return c.key===e?y(a,b,c,d):null}if(Ye(c)||Xe(c))return null!==e?null:u(a,b,c,d,null);$e(a,c)}return null}function I(a,b,c,d,e){if("string"===typeof d||"number"===typeof d)return a=a.get(c)||null,h(b,a,""+d,e);if("object"===typeof d&&null!==d){switch(d.$$typeof){case Re:return a=a.get(null===d.key?c:d.key)||null,d.type===Ve?u(b,a,d.props.children,e,d.key):k(b,a,d,e);case Se:return a=a.get(null===d.key?c:d.key)||null,q(b,a,d,e);case Te:return a=a.get(c)||null,v(b,a,d,e);case Ue:return a= 2583 a.get(null===d.key?c:d.key)||null,y(b,a,d,e)}if(Ye(d)||Xe(d))return a=a.get(c)||null,u(b,a,d,e,null);$e(b,d)}return null}function L(e,g,m,A){for(var h=null,r=null,n=g,w=g=0,k=null;null!==n&&w<m.length;w++){n.index>w?(k=n,n=null):k=n.sibling;var x=G(e,n,m[w],A);if(null===x){null===n&&(n=k);break}a&&n&&null===x.alternate&&b(e,n);g=f(x,g,w);null===r?h=x:r.sibling=x;r=x;n=k}if(w===m.length)return c(e,n),h;if(null===n){for(;w<m.length;w++)if(n=z(e,m[w],A))g=f(n,g,w),null===r?h=n:r.sibling=n,r=n;return h}for(n= 2584 d(e,n);w<m.length;w++)if(k=I(n,e,w,m[w],A)){if(a&&null!==k.alternate)n["delete"](null===k.key?w:k.key);g=f(k,g,w);null===r?h=k:r.sibling=k;r=k}a&&n.forEach(function(a){return b(e,a)});return h}function N(e,g,m,A){var h=Xe(m);"function"!==typeof h?E("150"):void 0;m=h.call(m);null==m?E("151"):void 0;for(var r=h=null,n=g,w=g=0,k=null,x=m.next();null!==n&&!x.done;w++,x=m.next()){n.index>w?(k=n,n=null):k=n.sibling;var J=G(e,n,x.value,A);if(null===J){n||(n=k);break}a&&n&&null===J.alternate&&b(e,n);g=f(J, 2585 g,w);null===r?h=J:r.sibling=J;r=J;n=k}if(x.done)return c(e,n),h;if(null===n){for(;!x.done;w++,x=m.next())x=z(e,x.value,A),null!==x&&(g=f(x,g,w),null===r?h=x:r.sibling=x,r=x);return h}for(n=d(e,n);!x.done;w++,x=m.next())if(x=I(n,e,w,x.value,A),null!==x){if(a&&null!==x.alternate)n["delete"](null===x.key?w:x.key);g=f(x,g,w);null===r?h=x:r.sibling=x;r=x}a&&n.forEach(function(a){return b(e,a)});return h}return function(a,d,f,h){"object"===typeof f&&null!==f&&f.type===Ve&&null===f.key&&(f=f.props.children); 2586 var m="object"===typeof f&&null!==f;if(m)switch(f.$$typeof){case Re:a:{var r=f.key;for(m=d;null!==m;){if(m.key===r)if(10===m.tag?f.type===Ve:m.type===f.type){c(a,m.sibling);d=e(m,f.type===Ve?f.props.children:f.props,h);d.ref=Ze(m,f);d["return"]=a;a=d;break a}else{c(a,m);break}else b(a,m);m=m.sibling}f.type===Ve?(d=ue(f.props.children,a.internalContextTag,h,f.key),d["return"]=a,a=d):(h=te(f,a.internalContextTag,h),h.ref=Ze(d,f),h["return"]=a,a=h)}return g(a);case Se:a:{for(m=f.key;null!==d;){if(d.key=== 2587 m)if(7===d.tag){c(a,d.sibling);d=e(d,f,h);d["return"]=a;a=d;break a}else{c(a,d);break}else b(a,d);d=d.sibling}d=we(f,a.internalContextTag,h);d["return"]=a;a=d}return g(a);case Te:a:{if(null!==d)if(9===d.tag){c(a,d.sibling);d=e(d,null,h);d.type=f.value;d["return"]=a;a=d;break a}else c(a,d);d=xe(f,a.internalContextTag,h);d.type=f.value;d["return"]=a;a=d}return g(a);case Ue:a:{for(m=f.key;null!==d;){if(d.key===m)if(4===d.tag&&d.stateNode.containerInfo===f.containerInfo&&d.stateNode.implementation=== 2588 f.implementation){c(a,d.sibling);d=e(d,f.children||[],h);d["return"]=a;a=d;break a}else{c(a,d);break}else b(a,d);d=d.sibling}d=ye(f,a.internalContextTag,h);d["return"]=a;a=d}return g(a)}if("string"===typeof f||"number"===typeof f)return f=""+f,null!==d&&6===d.tag?(c(a,d.sibling),d=e(d,f,h)):(c(a,d),d=ve(f,a.internalContextTag,h)),d["return"]=a,a=d,g(a);if(Ye(f))return L(a,d,f,h);if(Xe(f))return N(a,d,f,h);m&&$e(a,f);if("undefined"===typeof f)switch(a.tag){case 2:case 1:h=a.type,E("152",h.displayName|| 2589 h.name||"Component")}return c(a,d)}}var bf=af(!0),cf=af(!1); 2590 function df(a,b,c,d,e){function f(a,b,c){var d=b.expirationTime;b.child=null===a?cf(b,null,c,d):bf(b,a.child,c,d)}function g(a,b){var c=b.ref;null===c||a&&a.ref===c||(b.effectTag|=128)}function h(a,b,c,d){g(a,b);if(!c)return d&&re(b,!1),q(a,b);c=b.stateNode;id.current=b;var e=c.render();b.effectTag|=1;f(a,b,e);b.memoizedState=c.state;b.memoizedProps=c.props;d&&re(b,!0);return b.child}function k(a){var b=a.stateNode;b.pendingContext?oe(a,b.pendingContext,b.pendingContext!==b.context):b.context&&oe(a, 2591 b.context,!1);I(a,b.containerInfo)}function q(a,b){null!==a&&b.child!==a.child?E("153"):void 0;if(null!==b.child){a=b.child;var c=se(a,a.pendingProps,a.expirationTime);b.child=c;for(c["return"]=b;null!==a.sibling;)a=a.sibling,c=c.sibling=se(a,a.pendingProps,a.expirationTime),c["return"]=b;c.sibling=null}return b.child}function v(a,b){switch(b.tag){case 3:k(b);break;case 2:qe(b);break;case 4:I(b,b.stateNode.containerInfo)}return null}var y=a.shouldSetTextContent,u=a.useSyncScheduling,z=a.shouldDeprioritizeSubtree, 2592 G=b.pushHostContext,I=b.pushHostContainer,L=c.enterHydrationState,N=c.resetHydrationState,J=c.tryToClaimNextHydratableInstance;a=Le(d,e,function(a,b){a.memoizedProps=b},function(a,b){a.memoizedState=b});var w=a.adoptClassInstance,m=a.constructClassInstance,A=a.mountClassInstance,Ob=a.updateClassInstance;return{beginWork:function(a,b,c){if(0===b.expirationTime||b.expirationTime>c)return v(a,b);switch(b.tag){case 0:null!==a?E("155"):void 0;var d=b.type,e=b.pendingProps,r=ke(b);r=me(b,r);d=d(e,r);b.effectTag|= 2593 1;"object"===typeof d&&null!==d&&"function"===typeof d.render?(b.tag=2,e=qe(b),w(b,d),A(b,c),b=h(a,b,!0,e)):(b.tag=1,f(a,b,d),b.memoizedProps=e,b=b.child);return b;case 1:a:{e=b.type;c=b.pendingProps;d=b.memoizedProps;if(X.current)null===c&&(c=d);else if(null===c||d===c){b=q(a,b);break a}d=ke(b);d=me(b,d);e=e(c,d);b.effectTag|=1;f(a,b,e);b.memoizedProps=c;b=b.child}return b;case 2:return e=qe(b),d=void 0,null===a?b.stateNode?E("153"):(m(b,b.pendingProps),A(b,c),d=!0):d=Ob(a,b,c),h(a,b,d,e);case 3:return k(b), 2594 e=b.updateQueue,null!==e?(d=b.memoizedState,e=Je(a,b,e,null,null,c),d===e?(N(),b=q(a,b)):(d=e.element,r=b.stateNode,(null===a||null===a.child)&&r.hydrate&&L(b)?(b.effectTag|=2,b.child=cf(b,null,d,c)):(N(),f(a,b,d)),b.memoizedState=e,b=b.child)):(N(),b=q(a,b)),b;case 5:G(b);null===a&&J(b);e=b.type;var n=b.memoizedProps;d=b.pendingProps;null===d&&(d=n,null===d?E("154"):void 0);r=null!==a?a.memoizedProps:null;X.current||null!==d&&n!==d?(n=d.children,y(e,d)?n=null:r&&y(e,r)&&(b.effectTag|=16),g(a,b), 2595 2147483647!==c&&!u&&z(e,d)?(b.expirationTime=2147483647,b=null):(f(a,b,n),b.memoizedProps=d,b=b.child)):b=q(a,b);return b;case 6:return null===a&&J(b),a=b.pendingProps,null===a&&(a=b.memoizedProps),b.memoizedProps=a,null;case 8:b.tag=7;case 7:e=b.pendingProps;if(X.current)null===e&&(e=a&&a.memoizedProps,null===e?E("154"):void 0);else if(null===e||b.memoizedProps===e)e=b.memoizedProps;d=e.children;b.stateNode=null===a?cf(b,b.stateNode,d,c):bf(b,b.stateNode,d,c);b.memoizedProps=e;return b.stateNode; 2596 case 9:return null;case 4:a:{I(b,b.stateNode.containerInfo);e=b.pendingProps;if(X.current)null===e&&(e=a&&a.memoizedProps,null==e?E("154"):void 0);else if(null===e||b.memoizedProps===e){b=q(a,b);break a}null===a?b.child=bf(b,null,e,c):f(a,b,e);b.memoizedProps=e;b=b.child}return b;case 10:a:{c=b.pendingProps;if(X.current)null===c&&(c=b.memoizedProps);else if(null===c||b.memoizedProps===c){b=q(a,b);break a}f(a,b,c);b.memoizedProps=c;b=b.child}return b;default:E("156")}},beginFailedWork:function(a,b, 2597 c){switch(b.tag){case 2:qe(b);break;case 3:k(b);break;default:E("157")}b.effectTag|=64;null===a?b.child=null:b.child!==a.child&&(b.child=a.child);if(0===b.expirationTime||b.expirationTime>c)return v(a,b);b.firstEffect=null;b.lastEffect=null;b.child=null===a?cf(b,null,null,c):bf(b,a.child,null,c);2===b.tag&&(a=b.stateNode,b.memoizedProps=a.props,b.memoizedState=a.state);return b.child}}} 2598 function ef(a,b,c){function d(a){a.effectTag|=4}var e=a.createInstance,f=a.createTextInstance,g=a.appendInitialChild,h=a.finalizeInitialChildren,k=a.prepareUpdate,q=a.persistence,v=b.getRootHostContainer,y=b.popHostContext,u=b.getHostContext,z=b.popHostContainer,G=c.prepareToHydrateHostInstance,I=c.prepareToHydrateHostTextInstance,L=c.popHydrationState,N=void 0,J=void 0,w=void 0;a.mutation?(N=function(){},J=function(a,b,c){(b.updateQueue=c)&&d(b)},w=function(a,b,c,e){c!==e&&d(b)}):q?E("235"):E("236"); 2599 return{completeWork:function(a,b,c){var m=b.pendingProps;if(null===m)m=b.memoizedProps;else if(2147483647!==b.expirationTime||2147483647===c)b.pendingProps=null;switch(b.tag){case 1:return null;case 2:return ne(b),null;case 3:z(b);V(X,b);V(ie,b);m=b.stateNode;m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null);if(null===a||null===a.child)L(b),b.effectTag&=-3;N(b);return null;case 5:y(b);c=v();var A=b.type;if(null!==a&&null!=b.stateNode){var p=a.memoizedProps,q=b.stateNode,x=u();q= 2600 k(q,A,p,m,c,x);J(a,b,q,A,p,m,c);a.ref!==b.ref&&(b.effectTag|=128)}else{if(!m)return null===b.stateNode?E("166"):void 0,null;a=u();if(L(b))G(b,c,a)&&d(b);else{a=e(A,m,c,a,b);a:for(p=b.child;null!==p;){if(5===p.tag||6===p.tag)g(a,p.stateNode);else if(4!==p.tag&&null!==p.child){p.child["return"]=p;p=p.child;continue}if(p===b)break;for(;null===p.sibling;){if(null===p["return"]||p["return"]===b)break a;p=p["return"]}p.sibling["return"]=p["return"];p=p.sibling}h(a,A,m,c)&&d(b);b.stateNode=a}null!==b.ref&& 2601 (b.effectTag|=128)}return null;case 6:if(a&&null!=b.stateNode)w(a,b,a.memoizedProps,m);else{if("string"!==typeof m)return null===b.stateNode?E("166"):void 0,null;a=v();c=u();L(b)?I(b)&&d(b):b.stateNode=f(m,a,c,b)}return null;case 7:(m=b.memoizedProps)?void 0:E("165");b.tag=8;A=[];a:for((p=b.stateNode)&&(p["return"]=b);null!==p;){if(5===p.tag||6===p.tag||4===p.tag)E("247");else if(9===p.tag)A.push(p.type);else if(null!==p.child){p.child["return"]=p;p=p.child;continue}for(;null===p.sibling;){if(null=== 2602 p["return"]||p["return"]===b)break a;p=p["return"]}p.sibling["return"]=p["return"];p=p.sibling}p=m.handler;m=p(m.props,A);b.child=bf(b,null!==a?a.child:null,m,c);return b.child;case 8:return b.tag=7,null;case 9:return null;case 10:return null;case 4:return z(b),N(b),null;case 0:E("167");default:E("156")}}}} 2603 function ff(a,b){function c(a){var c=a.ref;if(null!==c)try{c(null)}catch(A){b(a,A)}}function d(a){"function"===typeof Ee&&Ee(a);switch(a.tag){case 2:c(a);var d=a.stateNode;if("function"===typeof d.componentWillUnmount)try{d.props=a.memoizedProps,d.state=a.memoizedState,d.componentWillUnmount()}catch(A){b(a,A)}break;case 5:c(a);break;case 7:e(a.stateNode);break;case 4:k&&g(a)}}function e(a){for(var b=a;;)if(d(b),null===b.child||k&&4===b.tag){if(b===a)break;for(;null===b.sibling;){if(null===b["return"]|| 2604 b["return"]===a)return;b=b["return"]}b.sibling["return"]=b["return"];b=b.sibling}else b.child["return"]=b,b=b.child}function f(a){return 5===a.tag||3===a.tag||4===a.tag}function g(a){for(var b=a,c=!1,f=void 0,g=void 0;;){if(!c){c=b["return"];a:for(;;){null===c?E("160"):void 0;switch(c.tag){case 5:f=c.stateNode;g=!1;break a;case 3:f=c.stateNode.containerInfo;g=!0;break a;case 4:f=c.stateNode.containerInfo;g=!0;break a}c=c["return"]}c=!0}if(5===b.tag||6===b.tag)e(b),g?J(f,b.stateNode):N(f,b.stateNode); 2605 else if(4===b.tag?f=b.stateNode.containerInfo:d(b),null!==b.child){b.child["return"]=b;b=b.child;continue}if(b===a)break;for(;null===b.sibling;){if(null===b["return"]||b["return"]===a)return;b=b["return"];4===b.tag&&(c=!1)}b.sibling["return"]=b["return"];b=b.sibling}}var h=a.getPublicInstance,k=a.mutation;a=a.persistence;k||(a?E("235"):E("236"));var q=k.commitMount,v=k.commitUpdate,y=k.resetTextContent,u=k.commitTextUpdate,z=k.appendChild,G=k.appendChildToContainer,I=k.insertBefore,L=k.insertInContainerBefore, 2606 N=k.removeChild,J=k.removeChildFromContainer;return{commitResetTextContent:function(a){y(a.stateNode)},commitPlacement:function(a){a:{for(var b=a["return"];null!==b;){if(f(b)){var c=b;break a}b=b["return"]}E("160");c=void 0}var d=b=void 0;switch(c.tag){case 5:b=c.stateNode;d=!1;break;case 3:b=c.stateNode.containerInfo;d=!0;break;case 4:b=c.stateNode.containerInfo;d=!0;break;default:E("161")}c.effectTag&16&&(y(b),c.effectTag&=-17);a:b:for(c=a;;){for(;null===c.sibling;){if(null===c["return"]||f(c["return"])){c= 2607 null;break a}c=c["return"]}c.sibling["return"]=c["return"];for(c=c.sibling;5!==c.tag&&6!==c.tag;){if(c.effectTag&2)continue b;if(null===c.child||4===c.tag)continue b;else c.child["return"]=c,c=c.child}if(!(c.effectTag&2)){c=c.stateNode;break a}}for(var e=a;;){if(5===e.tag||6===e.tag)c?d?L(b,e.stateNode,c):I(b,e.stateNode,c):d?G(b,e.stateNode):z(b,e.stateNode);else if(4!==e.tag&&null!==e.child){e.child["return"]=e;e=e.child;continue}if(e===a)break;for(;null===e.sibling;){if(null===e["return"]||e["return"]=== 2608 a)return;e=e["return"]}e.sibling["return"]=e["return"];e=e.sibling}},commitDeletion:function(a){g(a);a["return"]=null;a.child=null;a.alternate&&(a.alternate.child=null,a.alternate["return"]=null)},commitWork:function(a,b){switch(b.tag){case 2:break;case 5:var c=b.stateNode;if(null!=c){var d=b.memoizedProps;a=null!==a?a.memoizedProps:d;var e=b.type,f=b.updateQueue;b.updateQueue=null;null!==f&&v(c,f,e,a,d,b)}break;case 6:null===b.stateNode?E("162"):void 0;c=b.memoizedProps;u(b.stateNode,null!==a?a.memoizedProps: 2609 c,c);break;case 3:break;default:E("163")}},commitLifeCycles:function(a,b){switch(b.tag){case 2:var c=b.stateNode;if(b.effectTag&4)if(null===a)c.props=b.memoizedProps,c.state=b.memoizedState,c.componentDidMount();else{var d=a.memoizedProps;a=a.memoizedState;c.props=b.memoizedProps;c.state=b.memoizedState;c.componentDidUpdate(d,a)}b=b.updateQueue;null!==b&&Ke(b,c);break;case 3:c=b.updateQueue;null!==c&&Ke(c,null!==b.child?b.child.stateNode:null);break;case 5:c=b.stateNode;null===a&&b.effectTag&4&&q(c, 2610 b.type,b.memoizedProps,b);break;case 6:break;case 4:break;default:E("163")}},commitAttachRef:function(a){var b=a.ref;if(null!==b){var c=a.stateNode;switch(a.tag){case 5:b(h(c));break;default:b(c)}}},commitDetachRef:function(a){a=a.ref;null!==a&&a(null)}}}var gf={}; 2611 function hf(a){function b(a){a===gf?E("174"):void 0;return a}var c=a.getChildHostContext,d=a.getRootHostContext,e={current:gf},f={current:gf},g={current:gf};return{getHostContext:function(){return b(e.current)},getRootHostContainer:function(){return b(g.current)},popHostContainer:function(a){V(e,a);V(f,a);V(g,a)},popHostContext:function(a){f.current===a&&(V(e,a),V(f,a))},pushHostContainer:function(a,b){W(g,b,a);b=d(b);W(f,a,a);W(e,b,a)},pushHostContext:function(a){var d=b(g.current),h=b(e.current); 2612 d=c(h,a.type,d);h!==d&&(W(f,a,a),W(e,d,a))},resetHostContainer:function(){e.current=gf;g.current=gf}}} 2613 function jf(a){function b(a,b){var c=new Y(5,null,0);c.type="DELETED";c.stateNode=b;c["return"]=a;c.effectTag=8;null!==a.lastEffect?(a.lastEffect.nextEffect=c,a.lastEffect=c):a.firstEffect=a.lastEffect=c}function c(a,b){switch(a.tag){case 5:return b=f(b,a.type,a.pendingProps),null!==b?(a.stateNode=b,!0):!1;case 6:return b=g(b,a.pendingProps),null!==b?(a.stateNode=b,!0):!1;default:return!1}}function d(a){for(a=a["return"];null!==a&&5!==a.tag&&3!==a.tag;)a=a["return"];y=a}var e=a.shouldSetTextContent; 2614 a=a.hydration;if(!a)return{enterHydrationState:function(){return!1},resetHydrationState:function(){},tryToClaimNextHydratableInstance:function(){},prepareToHydrateHostInstance:function(){E("175")},prepareToHydrateHostTextInstance:function(){E("176")},popHydrationState:function(){return!1}};var f=a.canHydrateInstance,g=a.canHydrateTextInstance,h=a.getNextHydratableSibling,k=a.getFirstHydratableChild,q=a.hydrateInstance,v=a.hydrateTextInstance,y=null,u=null,z=!1;return{enterHydrationState:function(a){u= 2615 k(a.stateNode.containerInfo);y=a;return z=!0},resetHydrationState:function(){u=y=null;z=!1},tryToClaimNextHydratableInstance:function(a){if(z){var d=u;if(d){if(!c(a,d)){d=h(d);if(!d||!c(a,d)){a.effectTag|=2;z=!1;y=a;return}b(y,u)}y=a;u=k(d)}else a.effectTag|=2,z=!1,y=a}},prepareToHydrateHostInstance:function(a,b,c){b=q(a.stateNode,a.type,a.memoizedProps,b,c,a);a.updateQueue=b;return null!==b?!0:!1},prepareToHydrateHostTextInstance:function(a){return v(a.stateNode,a.memoizedProps,a)},popHydrationState:function(a){if(a!== 2616 y)return!1;if(!z)return d(a),z=!0,!1;var c=a.type;if(5!==a.tag||"head"!==c&&"body"!==c&&!e(c,a.memoizedProps))for(c=u;c;)b(a,c),c=h(c);d(a);u=y?h(a.stateNode):null;return!0}}} 2617 function kf(a){function b(a){Qb=ja=!0;var b=a.stateNode;b.current===a?E("177"):void 0;b.isReadyForCommit=!1;id.current=null;if(1<a.effectTag)if(null!==a.lastEffect){a.lastEffect.nextEffect=a;var c=a.firstEffect}else c=a;else c=a.firstEffect;yg();for(t=c;null!==t;){var d=!1,e=void 0;try{for(;null!==t;){var f=t.effectTag;f&16&&zg(t);if(f&128){var g=t.alternate;null!==g&&Ag(g)}switch(f&-242){case 2:Ne(t);t.effectTag&=-3;break;case 6:Ne(t);t.effectTag&=-3;Oe(t.alternate,t);break;case 4:Oe(t.alternate, 2618 t);break;case 8:Sc=!0,Bg(t),Sc=!1}t=t.nextEffect}}catch(Tc){d=!0,e=Tc}d&&(null===t?E("178"):void 0,h(t,e),null!==t&&(t=t.nextEffect))}Cg();b.current=a;for(t=c;null!==t;){c=!1;d=void 0;try{for(;null!==t;){var k=t.effectTag;k&36&&Dg(t.alternate,t);k&128&&Eg(t);if(k&64)switch(e=t,f=void 0,null!==R&&(f=R.get(e),R["delete"](e),null==f&&null!==e.alternate&&(e=e.alternate,f=R.get(e),R["delete"](e))),null==f?E("184"):void 0,e.tag){case 2:e.stateNode.componentDidCatch(f.error,{componentStack:f.componentStack}); 2619 break;case 3:null===ca&&(ca=f.error);break;default:E("157")}var Qc=t.nextEffect;t.nextEffect=null;t=Qc}}catch(Tc){c=!0,d=Tc}c&&(null===t?E("178"):void 0,h(t,d),null!==t&&(t=t.nextEffect))}ja=Qb=!1;"function"===typeof De&&De(a.stateNode);ha&&(ha.forEach(G),ha=null);null!==ca&&(a=ca,ca=null,Ob(a));b=b.current.expirationTime;0===b&&(qa=R=null);return b}function c(a){for(;;){var b=Fg(a.alternate,a,H),c=a["return"],d=a.sibling;var e=a;if(2147483647===H||2147483647!==e.expirationTime){if(2!==e.tag&&3!== 2620 e.tag)var f=0;else f=e.updateQueue,f=null===f?0:f.expirationTime;for(var g=e.child;null!==g;)0!==g.expirationTime&&(0===f||f>g.expirationTime)&&(f=g.expirationTime),g=g.sibling;e.expirationTime=f}if(null!==b)return b;null!==c&&(null===c.firstEffect&&(c.firstEffect=a.firstEffect),null!==a.lastEffect&&(null!==c.lastEffect&&(c.lastEffect.nextEffect=a.firstEffect),c.lastEffect=a.lastEffect),1<a.effectTag&&(null!==c.lastEffect?c.lastEffect.nextEffect=a:c.firstEffect=a,c.lastEffect=a));if(null!==d)return d; 2621 if(null!==c)a=c;else{a.stateNode.isReadyForCommit=!0;break}}return null}function d(a){var b=rg(a.alternate,a,H);null===b&&(b=c(a));id.current=null;return b}function e(a){var b=Gg(a.alternate,a,H);null===b&&(b=c(a));id.current=null;return b}function f(a){if(null!==R){if(!(0===H||H>a))if(H<=Uc)for(;null!==F;)F=k(F)?e(F):d(F);else for(;null!==F&&!A();)F=k(F)?e(F):d(F)}else if(!(0===H||H>a))if(H<=Uc)for(;null!==F;)F=d(F);else for(;null!==F&&!A();)F=d(F)}function g(a,b){ja?E("243"):void 0;ja=!0;a.isReadyForCommit= 2622 !1;if(a!==ra||b!==H||null===F){for(;-1<he;)ge[he]=null,he--;je=D;ie.current=D;X.current=!1;x();ra=a;H=b;F=se(ra.current,null,b)}var c=!1,d=null;try{f(b)}catch(Rc){c=!0,d=Rc}for(;c;){if(eb){ca=d;break}var g=F;if(null===g)eb=!0;else{var k=h(g,d);null===k?E("183"):void 0;if(!eb){try{c=k;d=b;for(k=c;null!==g;){switch(g.tag){case 2:ne(g);break;case 5:qg(g);break;case 3:p(g);break;case 4:p(g)}if(g===k||g.alternate===k)break;g=g["return"]}F=e(c);f(d)}catch(Rc){c=!0;d=Rc;continue}break}}}b=ca;eb=ja=!1;ca= 2623 null;null!==b&&Ob(b);return a.isReadyForCommit?a.current.alternate:null}function h(a,b){var c=id.current=null,d=!1,e=!1,f=null;if(3===a.tag)c=a,q(a)&&(eb=!0);else for(var g=a["return"];null!==g&&null===c;){2===g.tag?"function"===typeof g.stateNode.componentDidCatch&&(d=!0,f=jd(g),c=g,e=!0):3===g.tag&&(c=g);if(q(g)){if(Sc||null!==ha&&(ha.has(g)||null!==g.alternate&&ha.has(g.alternate)))return null;c=null;e=!1}g=g["return"]}if(null!==c){null===qa&&(qa=new Set);qa.add(c);var h="";g=a;do{a:switch(g.tag){case 0:case 1:case 2:case 5:var k= 2624 g._debugOwner,Qc=g._debugSource;var m=jd(g);var n=null;k&&(n=jd(k));k=Qc;m="\n in "+(m||"Unknown")+(k?" (at "+k.fileName.replace(/^.*[\\\/]/,"")+":"+k.lineNumber+")":n?" (created by "+n+")":"");break a;default:m=""}h+=m;g=g["return"]}while(g);g=h;a=jd(a);null===R&&(R=new Map);b={componentName:a,componentStack:g,error:b,errorBoundary:d?c.stateNode:null,errorBoundaryFound:d,errorBoundaryName:f,willRetry:e};R.set(c,b);try{var p=b.error;p&&p.suppressReactErrorLogging||console.error(p)}catch(Vc){Vc&& 2625 Vc.suppressReactErrorLogging||console.error(Vc)}Qb?(null===ha&&(ha=new Set),ha.add(c)):G(c);return c}null===ca&&(ca=b);return null}function k(a){return null!==R&&(R.has(a)||null!==a.alternate&&R.has(a.alternate))}function q(a){return null!==qa&&(qa.has(a)||null!==a.alternate&&qa.has(a.alternate))}function v(){return 20*(((I()+100)/20|0)+1)}function y(a){return 0!==ka?ka:ja?Qb?1:H:!Hg||a.internalContextTag&1?v():1}function u(a,b){return z(a,b,!1)}function z(a,b){for(;null!==a;){if(0===a.expirationTime|| 2626 a.expirationTime>b)a.expirationTime=b;null!==a.alternate&&(0===a.alternate.expirationTime||a.alternate.expirationTime>b)&&(a.alternate.expirationTime=b);if(null===a["return"])if(3===a.tag){var c=a.stateNode;!ja&&c===ra&&b<H&&(F=ra=null,H=0);var d=c,e=b;Rb>Ig&&E("185");if(null===d.nextScheduledRoot)d.remainingExpirationTime=e,null===O?(sa=O=d,d.nextScheduledRoot=d):(O=O.nextScheduledRoot=d,O.nextScheduledRoot=sa);else{var f=d.remainingExpirationTime;if(0===f||e<f)d.remainingExpirationTime=e}Fa||(la? 2627 Sb&&(ma=d,na=1,m(ma,na)):1===e?w(1,null):L(e));!ja&&c===ra&&b<H&&(F=ra=null,H=0)}else break;a=a["return"]}}function G(a){z(a,1,!0)}function I(){return Uc=((Wc()-Pe)/10|0)+2}function L(a){if(0!==Tb){if(a>Tb)return;Jg(Xc)}var b=Wc()-Pe;Tb=a;Xc=Kg(J,{timeout:10*(a-2)-b})}function N(){var a=0,b=null;if(null!==O)for(var c=O,d=sa;null!==d;){var e=d.remainingExpirationTime;if(0===e){null===c||null===O?E("244"):void 0;if(d===d.nextScheduledRoot){sa=O=d.nextScheduledRoot=null;break}else if(d===sa)sa=e=d.nextScheduledRoot, 2628 O.nextScheduledRoot=e,d.nextScheduledRoot=null;else if(d===O){O=c;O.nextScheduledRoot=sa;d.nextScheduledRoot=null;break}else c.nextScheduledRoot=d.nextScheduledRoot,d.nextScheduledRoot=null;d=c.nextScheduledRoot}else{if(0===a||e<a)a=e,b=d;if(d===O)break;c=d;d=d.nextScheduledRoot}}c=ma;null!==c&&c===b?Rb++:Rb=0;ma=b;na=a}function J(a){w(0,a)}function w(a,b){fb=b;for(N();null!==ma&&0!==na&&(0===a||na<=a)&&!Yc;)m(ma,na),N();null!==fb&&(Tb=0,Xc=-1);0!==na&&L(na);fb=null;Yc=!1;Rb=0;if(Ub)throw a=Zc,Zc= 2629 null,Ub=!1,a;}function m(a,c){Fa?E("245"):void 0;Fa=!0;if(c<=I()){var d=a.finishedWork;null!==d?(a.finishedWork=null,a.remainingExpirationTime=b(d)):(a.finishedWork=null,d=g(a,c),null!==d&&(a.remainingExpirationTime=b(d)))}else d=a.finishedWork,null!==d?(a.finishedWork=null,a.remainingExpirationTime=b(d)):(a.finishedWork=null,d=g(a,c),null!==d&&(A()?a.finishedWork=d:a.remainingExpirationTime=b(d)));Fa=!1}function A(){return null===fb||fb.timeRemaining()>Lg?!1:Yc=!0}function Ob(a){null===ma?E("246"): 2630 void 0;ma.remainingExpirationTime=0;Ub||(Ub=!0,Zc=a)}var r=hf(a),n=jf(a),p=r.popHostContainer,qg=r.popHostContext,x=r.resetHostContainer,Me=df(a,r,n,u,y),rg=Me.beginWork,Gg=Me.beginFailedWork,Fg=ef(a,r,n).completeWork;r=ff(a,h);var zg=r.commitResetTextContent,Ne=r.commitPlacement,Bg=r.commitDeletion,Oe=r.commitWork,Dg=r.commitLifeCycles,Eg=r.commitAttachRef,Ag=r.commitDetachRef,Wc=a.now,Kg=a.scheduleDeferredCallback,Jg=a.cancelDeferredCallback,Hg=a.useSyncScheduling,yg=a.prepareForCommit,Cg=a.resetAfterCommit, 2631 Pe=Wc(),Uc=2,ka=0,ja=!1,F=null,ra=null,H=0,t=null,R=null,qa=null,ha=null,ca=null,eb=!1,Qb=!1,Sc=!1,sa=null,O=null,Tb=0,Xc=-1,Fa=!1,ma=null,na=0,Yc=!1,Ub=!1,Zc=null,fb=null,la=!1,Sb=!1,Ig=1E3,Rb=0,Lg=1;return{computeAsyncExpiration:v,computeExpirationForFiber:y,scheduleWork:u,batchedUpdates:function(a,b){var c=la;la=!0;try{return a(b)}finally{(la=c)||Fa||w(1,null)}},unbatchedUpdates:function(a){if(la&&!Sb){Sb=!0;try{return a()}finally{Sb=!1}}return a()},flushSync:function(a){var b=la;la=!0;try{a:{var c= 2632 ka;ka=1;try{var d=a();break a}finally{ka=c}d=void 0}return d}finally{la=b,Fa?E("187"):void 0,w(1,null)}},deferredUpdates:function(a){var b=ka;ka=v();try{return a()}finally{ka=b}}}} 2633 function lf(a){function b(a){a=od(a);return null===a?null:a.stateNode}var c=a.getPublicInstance;a=kf(a);var d=a.computeAsyncExpiration,e=a.computeExpirationForFiber,f=a.scheduleWork;return{createContainer:function(a,b){var c=new Y(3,null,0);a={current:c,containerInfo:a,pendingChildren:null,remainingExpirationTime:0,isReadyForCommit:!1,finishedWork:null,context:null,pendingContext:null,hydrate:b,nextScheduledRoot:null};return c.stateNode=a},updateContainer:function(a,b,c,q){var g=b.current;if(c){c= 2634 c._reactInternalFiber;var h;b:{2===kd(c)&&2===c.tag?void 0:E("170");for(h=c;3!==h.tag;){if(le(h)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break b}(h=h["return"])?void 0:E("171")}h=h.stateNode.context}c=le(c)?pe(c,h):h}else c=D;null===b.context?b.context=c:b.pendingContext=c;b=q;b=void 0===b?null:b;q=null!=a&&null!=a.type&&null!=a.type.prototype&&!0===a.type.prototype.unstable_isAsyncReactComponent?d():e(g);He(g,{expirationTime:q,partialState:{element:a},callback:b,isReplace:!1,isForced:!1, 2635 nextCallback:null,next:null});f(g,q)},batchedUpdates:a.batchedUpdates,unbatchedUpdates:a.unbatchedUpdates,deferredUpdates:a.deferredUpdates,flushSync:a.flushSync,getPublicRootInstance:function(a){a=a.current;if(!a.child)return null;switch(a.child.tag){case 5:return c(a.child.stateNode);default:return a.child.stateNode}},findHostInstance:b,findHostInstanceWithNoPortals:function(a){a=pd(a);return null===a?null:a.stateNode},injectIntoDevTools:function(a){var c=a.findFiberByHostInstance;return Ce(B({}, 2636 a,{findHostInstanceByFiber:function(a){return b(a)},findFiberByHostInstance:function(a){return c?c(a):null}}))}}}var mf=Object.freeze({default:lf}),nf=mf&&lf||mf,of=nf["default"]?nf["default"]:nf;function pf(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:Ue,key:null==d?null:""+d,children:a,containerInfo:b,implementation:c}}var qf="object"===typeof performance&&"function"===typeof performance.now,rf=void 0;rf=qf?function(){return performance.now()}:function(){return Date.now()}; 2637 var sf=void 0,tf=void 0; 2638 if(l.canUseDOM)if("function"!==typeof requestIdleCallback||"function"!==typeof cancelIdleCallback){var uf=null,vf=!1,wf=-1,xf=!1,yf=0,zf=33,Af=33,Bf;Bf=qf?{didTimeout:!1,timeRemaining:function(){var a=yf-performance.now();return 0<a?a:0}}:{didTimeout:!1,timeRemaining:function(){var a=yf-Date.now();return 0<a?a:0}};var Cf="__reactIdleCallback$"+Math.random().toString(36).slice(2);window.addEventListener("message",function(a){if(a.source===window&&a.data===Cf){vf=!1;a=rf();if(0>=yf-a)if(-1!==wf&&wf<= 2639 a)Bf.didTimeout=!0;else{xf||(xf=!0,requestAnimationFrame(Df));return}else Bf.didTimeout=!1;wf=-1;a=uf;uf=null;null!==a&&a(Bf)}},!1);var Df=function(a){xf=!1;var b=a-yf+Af;b<Af&&zf<Af?(8>b&&(b=8),Af=b<zf?zf:b):zf=b;yf=a+Af;vf||(vf=!0,window.postMessage(Cf,"*"))};sf=function(a,b){uf=a;null!=b&&"number"===typeof b.timeout&&(wf=rf()+b.timeout);xf||(xf=!0,requestAnimationFrame(Df));return 0};tf=function(){uf=null;vf=!1;wf=-1}}else sf=window.requestIdleCallback,tf=window.cancelIdleCallback;else sf=function(a){return setTimeout(function(){a({timeRemaining:function(){return Infinity}})})}, 2640 tf=function(a){clearTimeout(a)};var Ef=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ff={},Gf={}; 2641 function Hf(a){if(Gf.hasOwnProperty(a))return!0;if(Ff.hasOwnProperty(a))return!1;if(Ef.test(a))return Gf[a]=!0;Ff[a]=!0;return!1} 2642 function If(a,b,c){var d=wa(b);if(d&&va(b,c)){var e=d.mutationMethod;e?e(a,c):null==c||d.hasBooleanValue&&!c||d.hasNumericValue&&isNaN(c)||d.hasPositiveNumericValue&&1>c||d.hasOverloadedBooleanValue&&!1===c?Jf(a,b):d.mustUseProperty?a[d.propertyName]=c:(b=d.attributeName,(e=d.attributeNamespace)?a.setAttributeNS(e,b,""+c):d.hasBooleanValue||d.hasOverloadedBooleanValue&&!0===c?a.setAttribute(b,""):a.setAttribute(b,""+c))}else Kf(a,b,va(b,c)?c:null)} 2643 function Kf(a,b,c){Hf(b)&&(null==c?a.removeAttribute(b):a.setAttribute(b,""+c))}function Jf(a,b){var c=wa(b);c?(b=c.mutationMethod)?b(a,void 0):c.mustUseProperty?a[c.propertyName]=c.hasBooleanValue?!1:"":a.removeAttribute(c.attributeName):a.removeAttribute(b)} 2644 function Lf(a,b){var c=b.value,d=b.checked;return B({type:void 0,step:void 0,min:void 0,max:void 0},b,{defaultChecked:void 0,defaultValue:void 0,value:null!=c?c:a._wrapperState.initialValue,checked:null!=d?d:a._wrapperState.initialChecked})}function Mf(a,b){var c=b.defaultValue;a._wrapperState={initialChecked:null!=b.checked?b.checked:b.defaultChecked,initialValue:null!=b.value?b.value:c,controlled:"checkbox"===b.type||"radio"===b.type?null!=b.checked:null!=b.value}} 2645 function Nf(a,b){b=b.checked;null!=b&&If(a,"checked",b)}function Of(a,b){Nf(a,b);var c=b.value;if(null!=c)if(0===c&&""===a.value)a.value="0";else if("number"===b.type){if(b=parseFloat(a.value)||0,c!=b||c==b&&a.value!=c)a.value=""+c}else a.value!==""+c&&(a.value=""+c);else null==b.value&&null!=b.defaultValue&&a.defaultValue!==""+b.defaultValue&&(a.defaultValue=""+b.defaultValue),null==b.checked&&null!=b.defaultChecked&&(a.defaultChecked=!!b.defaultChecked)} 2646 function Pf(a,b){switch(b.type){case "submit":case "reset":break;case "color":case "date":case "datetime":case "datetime-local":case "month":case "time":case "week":a.value="";a.value=a.defaultValue;break;default:a.value=a.value}b=a.name;""!==b&&(a.name="");a.defaultChecked=!a.defaultChecked;a.defaultChecked=!a.defaultChecked;""!==b&&(a.name=b)}function Qf(a){var b="";aa.Children.forEach(a,function(a){null==a||"string"!==typeof a&&"number"!==typeof a||(b+=a)});return b} 2647 function Rf(a,b){a=B({children:void 0},b);if(b=Qf(b.children))a.children=b;return a}function Sf(a,b,c,d){a=a.options;if(b){b={};for(var e=0;e<c.length;e++)b["$"+c[e]]=!0;for(c=0;c<a.length;c++)e=b.hasOwnProperty("$"+a[c].value),a[c].selected!==e&&(a[c].selected=e),e&&d&&(a[c].defaultSelected=!0)}else{c=""+c;b=null;for(e=0;e<a.length;e++){if(a[e].value===c){a[e].selected=!0;d&&(a[e].defaultSelected=!0);return}null!==b||a[e].disabled||(b=a[e])}null!==b&&(b.selected=!0)}} 2648 function Tf(a,b){var c=b.value;a._wrapperState={initialValue:null!=c?c:b.defaultValue,wasMultiple:!!b.multiple}}function Uf(a,b){null!=b.dangerouslySetInnerHTML?E("91"):void 0;return B({},b,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Vf(a,b){var c=b.value;null==c&&(c=b.defaultValue,b=b.children,null!=b&&(null!=c?E("92"):void 0,Array.isArray(b)&&(1>=b.length?void 0:E("93"),b=b[0]),c=""+b),null==c&&(c=""));a._wrapperState={initialValue:""+c}} 2649 function Wf(a,b){var c=b.value;null!=c&&(c=""+c,c!==a.value&&(a.value=c),null==b.defaultValue&&(a.defaultValue=c));null!=b.defaultValue&&(a.defaultValue=b.defaultValue)}function Xf(a){var b=a.textContent;b===a._wrapperState.initialValue&&(a.value=b)}var Yf={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"}; 2650 function Zf(a){switch(a){case "svg":return"http://www.w3.org/2000/svg";case "math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function $f(a,b){return null==a||"http://www.w3.org/1999/xhtml"===a?Zf(b):"http://www.w3.org/2000/svg"===a&&"foreignObject"===b?"http://www.w3.org/1999/xhtml":a} 2651 var ag=void 0,bg=function(a){return"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(b,c,d,e){MSApp.execUnsafeLocalFunction(function(){return a(b,c,d,e)})}:a}(function(a,b){if(a.namespaceURI!==Yf.svg||"innerHTML"in a)a.innerHTML=b;else{ag=ag||document.createElement("div");ag.innerHTML="\x3csvg\x3e"+b+"\x3c/svg\x3e";for(b=ag.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;b.firstChild;)a.appendChild(b.firstChild)}}); 2652 function cg(a,b){if(b){var c=a.firstChild;if(c&&c===a.lastChild&&3===c.nodeType){c.nodeValue=b;return}}a.textContent=b} 2653 var dg={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0, 2654 stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},eg=["Webkit","ms","Moz","O"];Object.keys(dg).forEach(function(a){eg.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);dg[b]=dg[a]})}); 2655 function fg(a,b){a=a.style;for(var c in b)if(b.hasOwnProperty(c)){var d=0===c.indexOf("--");var e=c;var f=b[c];e=null==f||"boolean"===typeof f||""===f?"":d||"number"!==typeof f||0===f||dg.hasOwnProperty(e)&&dg[e]?(""+f).trim():f+"px";"float"===c&&(c="cssFloat");d?a.setProperty(c,e):a[c]=e}}var gg=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}); 2656 function hg(a,b,c){b&&(gg[a]&&(null!=b.children||null!=b.dangerouslySetInnerHTML?E("137",a,c()):void 0),null!=b.dangerouslySetInnerHTML&&(null!=b.children?E("60"):void 0,"object"===typeof b.dangerouslySetInnerHTML&&"__html"in b.dangerouslySetInnerHTML?void 0:E("61")),null!=b.style&&"object"!==typeof b.style?E("62",c()):void 0)} 2657 function ig(a,b){if(-1===a.indexOf("-"))return"string"===typeof b.is;switch(a){case "annotation-xml":case "color-profile":case "font-face":case "font-face-src":case "font-face-uri":case "font-face-format":case "font-face-name":case "missing-glyph":return!1;default:return!0}}var jg=Yf.html,kg=C.thatReturns(""); 2658 function lg(a,b){a=9===a.nodeType||11===a.nodeType?a:a.ownerDocument;var c=Hd(a);b=Sa[b];for(var d=0;d<b.length;d++){var e=b[d];c.hasOwnProperty(e)&&c[e]||("topScroll"===e?wd("topScroll","scroll",a):"topFocus"===e||"topBlur"===e?(wd("topFocus","focus",a),wd("topBlur","blur",a),c.topBlur=!0,c.topFocus=!0):"topCancel"===e?(yc("cancel",!0)&&wd("topCancel","cancel",a),c.topCancel=!0):"topClose"===e?(yc("close",!0)&&wd("topClose","close",a),c.topClose=!0):Dd.hasOwnProperty(e)&&U(e,Dd[e],a),c[e]=!0)}} 2659 var mg={topAbort:"abort",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topSeeked:"seeked",topSeeking:"seeking",topStalled:"stalled",topSuspend:"suspend",topTimeUpdate:"timeupdate",topVolumeChange:"volumechange", 2660 topWaiting:"waiting"};function ng(a,b,c,d){c=9===c.nodeType?c:c.ownerDocument;d===jg&&(d=Zf(a));d===jg?"script"===a?(a=c.createElement("div"),a.innerHTML="\x3cscript\x3e\x3c/script\x3e",a=a.removeChild(a.firstChild)):a="string"===typeof b.is?c.createElement(a,{is:b.is}):c.createElement(a):a=c.createElementNS(d,a);return a}function og(a,b){return(9===b.nodeType?b:b.ownerDocument).createTextNode(a)} 2661 function pg(a,b,c,d){var e=ig(b,c);switch(b){case "iframe":case "object":U("topLoad","load",a);var f=c;break;case "video":case "audio":for(f in mg)mg.hasOwnProperty(f)&&U(f,mg[f],a);f=c;break;case "source":U("topError","error",a);f=c;break;case "img":case "image":U("topError","error",a);U("topLoad","load",a);f=c;break;case "form":U("topReset","reset",a);U("topSubmit","submit",a);f=c;break;case "details":U("topToggle","toggle",a);f=c;break;case "input":Mf(a,c);f=Lf(a,c);U("topInvalid","invalid",a); 2662 lg(d,"onChange");break;case "option":f=Rf(a,c);break;case "select":Tf(a,c);f=B({},c,{value:void 0});U("topInvalid","invalid",a);lg(d,"onChange");break;case "textarea":Vf(a,c);f=Uf(a,c);U("topInvalid","invalid",a);lg(d,"onChange");break;default:f=c}hg(b,f,kg);var g=f,h;for(h in g)if(g.hasOwnProperty(h)){var k=g[h];"style"===h?fg(a,k,kg):"dangerouslySetInnerHTML"===h?(k=k?k.__html:void 0,null!=k&&bg(a,k)):"children"===h?"string"===typeof k?("textarea"!==b||""!==k)&&cg(a,k):"number"===typeof k&&cg(a, 2663 ""+k):"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&"autoFocus"!==h&&(Ra.hasOwnProperty(h)?null!=k&&lg(d,h):e?Kf(a,h,k):null!=k&&If(a,h,k))}switch(b){case "input":Bc(a);Pf(a,c);break;case "textarea":Bc(a);Xf(a,c);break;case "option":null!=c.value&&a.setAttribute("value",c.value);break;case "select":a.multiple=!!c.multiple;b=c.value;null!=b?Sf(a,!!c.multiple,b,!1):null!=c.defaultValue&&Sf(a,!!c.multiple,c.defaultValue,!0);break;default:"function"===typeof f.onClick&&(a.onclick= 2664 C)}} 2665 function sg(a,b,c,d,e){var f=null;switch(b){case "input":c=Lf(a,c);d=Lf(a,d);f=[];break;case "option":c=Rf(a,c);d=Rf(a,d);f=[];break;case "select":c=B({},c,{value:void 0});d=B({},d,{value:void 0});f=[];break;case "textarea":c=Uf(a,c);d=Uf(a,d);f=[];break;default:"function"!==typeof c.onClick&&"function"===typeof d.onClick&&(a.onclick=C)}hg(b,d,kg);var g,h;a=null;for(g in c)if(!d.hasOwnProperty(g)&&c.hasOwnProperty(g)&&null!=c[g])if("style"===g)for(h in b=c[g],b)b.hasOwnProperty(h)&&(a||(a={}),a[h]= 2666 "");else"dangerouslySetInnerHTML"!==g&&"children"!==g&&"suppressContentEditableWarning"!==g&&"suppressHydrationWarning"!==g&&"autoFocus"!==g&&(Ra.hasOwnProperty(g)?f||(f=[]):(f=f||[]).push(g,null));for(g in d){var k=d[g];b=null!=c?c[g]:void 0;if(d.hasOwnProperty(g)&&k!==b&&(null!=k||null!=b))if("style"===g)if(b){for(h in b)!b.hasOwnProperty(h)||k&&k.hasOwnProperty(h)||(a||(a={}),a[h]="");for(h in k)k.hasOwnProperty(h)&&b[h]!==k[h]&&(a||(a={}),a[h]=k[h])}else a||(f||(f=[]),f.push(g,a)),a=k;else"dangerouslySetInnerHTML"=== 2667 g?(k=k?k.__html:void 0,b=b?b.__html:void 0,null!=k&&b!==k&&(f=f||[]).push(g,""+k)):"children"===g?b===k||"string"!==typeof k&&"number"!==typeof k||(f=f||[]).push(g,""+k):"suppressContentEditableWarning"!==g&&"suppressHydrationWarning"!==g&&(Ra.hasOwnProperty(g)?(null!=k&&lg(e,g),f||b===k||(f=[])):(f=f||[]).push(g,k))}a&&(f=f||[]).push("style",a);return f} 2668 function tg(a,b,c,d,e){"input"===c&&"radio"===e.type&&null!=e.name&&Nf(a,e);ig(c,d);d=ig(c,e);for(var f=0;f<b.length;f+=2){var g=b[f],h=b[f+1];"style"===g?fg(a,h,kg):"dangerouslySetInnerHTML"===g?bg(a,h):"children"===g?cg(a,h):d?null!=h?Kf(a,g,h):a.removeAttribute(g):null!=h?If(a,g,h):Jf(a,g)}switch(c){case "input":Of(a,e);break;case "textarea":Wf(a,e);break;case "select":a._wrapperState.initialValue=void 0,b=a._wrapperState.wasMultiple,a._wrapperState.wasMultiple=!!e.multiple,c=e.value,null!=c?Sf(a, 2669 !!e.multiple,c,!1):b!==!!e.multiple&&(null!=e.defaultValue?Sf(a,!!e.multiple,e.defaultValue,!0):Sf(a,!!e.multiple,e.multiple?[]:"",!1))}} 2670 function ug(a,b,c,d,e){switch(b){case "iframe":case "object":U("topLoad","load",a);break;case "video":case "audio":for(var f in mg)mg.hasOwnProperty(f)&&U(f,mg[f],a);break;case "source":U("topError","error",a);break;case "img":case "image":U("topError","error",a);U("topLoad","load",a);break;case "form":U("topReset","reset",a);U("topSubmit","submit",a);break;case "details":U("topToggle","toggle",a);break;case "input":Mf(a,c);U("topInvalid","invalid",a);lg(e,"onChange");break;case "select":Tf(a,c); 2671 U("topInvalid","invalid",a);lg(e,"onChange");break;case "textarea":Vf(a,c),U("topInvalid","invalid",a),lg(e,"onChange")}hg(b,c,kg);d=null;for(var g in c)c.hasOwnProperty(g)&&(f=c[g],"children"===g?"string"===typeof f?a.textContent!==f&&(d=["children",f]):"number"===typeof f&&a.textContent!==""+f&&(d=["children",""+f]):Ra.hasOwnProperty(g)&&null!=f&&lg(e,g));switch(b){case "input":Bc(a);Pf(a,c);break;case "textarea":Bc(a);Xf(a,c);break;case "select":case "option":break;default:"function"===typeof c.onClick&& 2672 (a.onclick=C)}return d}function vg(a,b){return a.nodeValue!==b} 2673 var wg=Object.freeze({createElement:ng,createTextNode:og,setInitialProperties:pg,diffProperties:sg,updateProperties:tg,diffHydratedProperties:ug,diffHydratedText:vg,warnForUnmatchedText:function(){},warnForDeletedHydratableElement:function(){},warnForDeletedHydratableText:function(){},warnForInsertedHydratedElement:function(){},warnForInsertedHydratedText:function(){},restoreControlledState:function(a,b,c){switch(b){case "input":Of(a,c);b=c.name;if("radio"===c.type&&null!=b){for(c=a;c.parentNode;)c= 2674 c.parentNode;c=c.querySelectorAll("input[name\x3d"+JSON.stringify(""+b)+'][type\x3d"radio"]');for(b=0;b<c.length;b++){var d=c[b];if(d!==a&&d.form===a.form){var e=rb(d);e?void 0:E("90");Cc(d);Of(d,e)}}}break;case "textarea":Wf(a,c);break;case "select":b=c.value,null!=b&&Sf(a,!!c.multiple,b,!1)}}});nc.injectFiberControlledHostComponent(wg);var xg=null,Mg=null;function Ng(a){return!(!a||1!==a.nodeType&&9!==a.nodeType&&11!==a.nodeType&&(8!==a.nodeType||" react-mount-point-unstable "!==a.nodeValue))} 2675 function Og(a){a=a?9===a.nodeType?a.documentElement:a.firstChild:null;return!(!a||1!==a.nodeType||!a.hasAttribute("data-reactroot"))} 2676 var Z=of({getRootHostContext:function(a){var b=a.nodeType;switch(b){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:$f(null,"");break;default:b=8===b?a.parentNode:a,a=b.namespaceURI||null,b=b.tagName,a=$f(a,b)}return a},getChildHostContext:function(a,b){return $f(a,b)},getPublicInstance:function(a){return a},prepareForCommit:function(){xg=td;var a=da();if(Kd(a)){if("selectionStart"in a)var b={start:a.selectionStart,end:a.selectionEnd};else a:{var c=window.getSelection&&window.getSelection(); 2677 if(c&&0!==c.rangeCount){b=c.anchorNode;var d=c.anchorOffset,e=c.focusNode;c=c.focusOffset;try{b.nodeType,e.nodeType}catch(z){b=null;break a}var f=0,g=-1,h=-1,k=0,q=0,v=a,y=null;b:for(;;){for(var u;;){v!==b||0!==d&&3!==v.nodeType||(g=f+d);v!==e||0!==c&&3!==v.nodeType||(h=f+c);3===v.nodeType&&(f+=v.nodeValue.length);if(null===(u=v.firstChild))break;y=v;v=u}for(;;){if(v===a)break b;y===b&&++k===d&&(g=f);y===e&&++q===c&&(h=f);if(null!==(u=v.nextSibling))break;v=y;y=v.parentNode}v=u}b=-1===g||-1===h?null: 2678 {start:g,end:h}}else b=null}b=b||{start:0,end:0}}else b=null;Mg={focusedElem:a,selectionRange:b};ud(!1)},resetAfterCommit:function(){var a=Mg,b=da(),c=a.focusedElem,d=a.selectionRange;if(b!==c&&fa(document.documentElement,c)){if(Kd(c))if(b=d.start,a=d.end,void 0===a&&(a=b),"selectionStart"in c)c.selectionStart=b,c.selectionEnd=Math.min(a,c.value.length);else if(window.getSelection){b=window.getSelection();var e=c[Eb()].length;a=Math.min(d.start,e);d=void 0===d.end?a:Math.min(d.end,e);!b.extend&&a> 2679 d&&(e=d,d=a,a=e);e=Jd(c,a);var f=Jd(c,d);if(e&&f&&(1!==b.rangeCount||b.anchorNode!==e.node||b.anchorOffset!==e.offset||b.focusNode!==f.node||b.focusOffset!==f.offset)){var g=document.createRange();g.setStart(e.node,e.offset);b.removeAllRanges();a>d?(b.addRange(g),b.extend(f.node,f.offset)):(g.setEnd(f.node,f.offset),b.addRange(g))}}b=[];for(a=c;a=a.parentNode;)1===a.nodeType&&b.push({element:a,left:a.scrollLeft,top:a.scrollTop});ia(c);for(c=0;c<b.length;c++)a=b[c],a.element.scrollLeft=a.left,a.element.scrollTop= 2680 a.top}Mg=null;ud(xg);xg=null},createInstance:function(a,b,c,d,e){a=ng(a,b,c,d);a[Q]=e;a[ob]=b;return a},appendInitialChild:function(a,b){a.appendChild(b)},finalizeInitialChildren:function(a,b,c,d){pg(a,b,c,d);a:{switch(b){case "button":case "input":case "select":case "textarea":a=!!c.autoFocus;break a}a=!1}return a},prepareUpdate:function(a,b,c,d,e){return sg(a,b,c,d,e)},shouldSetTextContent:function(a,b){return"textarea"===a||"string"===typeof b.children||"number"===typeof b.children||"object"=== 2681 typeof b.dangerouslySetInnerHTML&&null!==b.dangerouslySetInnerHTML&&"string"===typeof b.dangerouslySetInnerHTML.__html},shouldDeprioritizeSubtree:function(a,b){return!!b.hidden},createTextInstance:function(a,b,c,d){a=og(a,b);a[Q]=d;return a},now:rf,mutation:{commitMount:function(a){a.focus()},commitUpdate:function(a,b,c,d,e){a[ob]=e;tg(a,b,c,d,e)},resetTextContent:function(a){a.textContent=""},commitTextUpdate:function(a,b,c){a.nodeValue=c},appendChild:function(a,b){a.appendChild(b)},appendChildToContainer:function(a, 2682 b){8===a.nodeType?a.parentNode.insertBefore(b,a):a.appendChild(b)},insertBefore:function(a,b,c){a.insertBefore(b,c)},insertInContainerBefore:function(a,b,c){8===a.nodeType?a.parentNode.insertBefore(b,c):a.insertBefore(b,c)},removeChild:function(a,b){a.removeChild(b)},removeChildFromContainer:function(a,b){8===a.nodeType?a.parentNode.removeChild(b):a.removeChild(b)}},hydration:{canHydrateInstance:function(a,b){return 1!==a.nodeType||b.toLowerCase()!==a.nodeName.toLowerCase()?null:a},canHydrateTextInstance:function(a, 2683 b){return""===b||3!==a.nodeType?null:a},getNextHydratableSibling:function(a){for(a=a.nextSibling;a&&1!==a.nodeType&&3!==a.nodeType;)a=a.nextSibling;return a},getFirstHydratableChild:function(a){for(a=a.firstChild;a&&1!==a.nodeType&&3!==a.nodeType;)a=a.nextSibling;return a},hydrateInstance:function(a,b,c,d,e,f){a[Q]=f;a[ob]=c;return ug(a,b,c,e,d)},hydrateTextInstance:function(a,b,c){a[Q]=c;return vg(a,b)},didNotMatchHydratedContainerTextInstance:function(){},didNotMatchHydratedTextInstance:function(){}, 2684 didNotHydrateContainerInstance:function(){},didNotHydrateInstance:function(){},didNotFindHydratableContainerInstance:function(){},didNotFindHydratableContainerTextInstance:function(){},didNotFindHydratableInstance:function(){},didNotFindHydratableTextInstance:function(){}},scheduleDeferredCallback:sf,cancelDeferredCallback:tf,useSyncScheduling:!0});rc=Z.batchedUpdates; 2685 function Pg(a,b,c,d,e){Ng(c)?void 0:E("200");var f=c._reactRootContainer;if(f)Z.updateContainer(b,f,a,e);else{d=d||Og(c);if(!d)for(f=void 0;f=c.lastChild;)c.removeChild(f);var g=Z.createContainer(c,d);f=c._reactRootContainer=g;Z.unbatchedUpdates(function(){Z.updateContainer(b,g,a,e)})}return Z.getPublicRootInstance(f)}function Qg(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;Ng(b)?void 0:E("200");return pf(a,b,null,c)} 2686 function Rg(a,b){this._reactRootContainer=Z.createContainer(a,b)}Rg.prototype.render=function(a,b){Z.updateContainer(a,this._reactRootContainer,null,b)};Rg.prototype.unmount=function(a){Z.updateContainer(null,this._reactRootContainer,null,a)}; 2687 var Sg={createPortal:Qg,findDOMNode:function(a){if(null==a)return null;if(1===a.nodeType)return a;var b=a._reactInternalFiber;if(b)return Z.findHostInstance(b);"function"===typeof a.render?E("188"):E("213",Object.keys(a))},hydrate:function(a,b,c){return Pg(null,a,b,!0,c)},render:function(a,b,c){return Pg(null,a,b,!1,c)},unstable_renderSubtreeIntoContainer:function(a,b,c,d){null==a||void 0===a._reactInternalFiber?E("38"):void 0;return Pg(a,b,c,!1,d)},unmountComponentAtNode:function(a){Ng(a)?void 0: 2688 E("40");return a._reactRootContainer?(Z.unbatchedUpdates(function(){Pg(null,null,a,!1,function(){a._reactRootContainer=null})}),!0):!1},unstable_createPortal:Qg,unstable_batchedUpdates:tc,unstable_deferredUpdates:Z.deferredUpdates,flushSync:Z.flushSync,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{EventPluginHub:mb,EventPluginRegistry:Va,EventPropagators:Cb,ReactControlledComponent:qc,ReactDOMComponentTree:sb,ReactDOMEventListener:xd}}; 2689 Z.injectIntoDevTools({findFiberByHostInstance:pb,bundleType:0,version:"16.2.0",rendererPackageName:"react-dom"});var Tg=Object.freeze({default:Sg}),Ug=Tg&&Sg||Tg;module.exports=Ug["default"]?Ug["default"]:Ug; 2690 2691 2692 /***/ }), 2693 /* 22 */ 2694 /***/ (function(module, exports, __webpack_require__) { 2695 2696 "use strict"; 2697 2698 2699 /** 2700 * Copyright (c) 2013-present, Facebook, Inc. 2701 * 2702 * This source code is licensed under the MIT license found in the 2703 * LICENSE file in the root directory of this source tree. 2704 * 2705 * @typechecks 2706 */ 2707 2708 var isNode = __webpack_require__(23); 2709 2710 /** 2711 * @param {*} object The object to check. 2712 * @return {boolean} Whether or not the object is a DOM text node. 2713 */ 2714 function isTextNode(object) { 2715 return isNode(object) && object.nodeType == 3; 2716 } 2717 2718 module.exports = isTextNode; 2719 2720 /***/ }), 2721 /* 23 */ 2722 /***/ (function(module, exports, __webpack_require__) { 2723 2724 "use strict"; 2725 2726 2727 /** 2728 * Copyright (c) 2013-present, Facebook, Inc. 2729 * 2730 * This source code is licensed under the MIT license found in the 2731 * LICENSE file in the root directory of this source tree. 2732 * 2733 * @typechecks 2734 */ 2735 2736 /** 2737 * @param {*} object The object to check. 2738 * @return {boolean} Whether or not the object is a DOM node. 2739 */ 2740 function isNode(object) { 2741 var doc = object ? object.ownerDocument || object : document; 2742 var defaultView = doc.defaultView || window; 2743 return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); 2744 } 2745 2746 module.exports = isNode; 2747 2748 /***/ }), 2749 /* 24 */ 2750 /***/ (function(module, exports, __webpack_require__) { 2751 2752 "use strict"; 2753 /* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.2.0 2754 * react-dom.development.js 2755 * 2756 * Copyright (c) 2013-present, Facebook, Inc. 2757 * 2758 * This source code is licensed under the MIT license found in the 2759 * LICENSE file in the root directory of this source tree. 2760 */ 2761 2762 2763 2764 2765 2766 if (process.env.NODE_ENV !== "production") { 2767 (function() { 2768 'use strict'; 2769 2770 var React = __webpack_require__(3); 2771 var invariant = __webpack_require__(5); 2772 var warning = __webpack_require__(6); 2773 var ExecutionEnvironment = __webpack_require__(7); 2774 var _assign = __webpack_require__(2); 2775 var emptyFunction = __webpack_require__(1); 2776 var EventListener = __webpack_require__(10); 2777 var getActiveElement = __webpack_require__(11); 2778 var shallowEqual = __webpack_require__(12); 2779 var containsNode = __webpack_require__(13); 2780 var focusNode = __webpack_require__(14); 2781 var emptyObject = __webpack_require__(4); 2782 var checkPropTypes = __webpack_require__(8); 2783 var hyphenateStyleName = __webpack_require__(25); 2784 var camelizeStyleName = __webpack_require__(27); 2785 2786 /** 2787 * WARNING: DO NOT manually require this module. 2788 * This is a replacement for `invariant(...)` used by the error code system 2789 * and will _only_ be required by the corresponding babel pass. 2790 * It always throws. 2791 */ 2792 2793 !React ? invariant(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0; 2794 2795 // These attributes should be all lowercase to allow for 2796 // case insensitive checks 2797 var RESERVED_PROPS = { 2798 children: true, 2799 dangerouslySetInnerHTML: true, 2800 defaultValue: true, 2801 defaultChecked: true, 2802 innerHTML: true, 2803 suppressContentEditableWarning: true, 2804 suppressHydrationWarning: true, 2805 style: true 2806 }; 2807 2808 function checkMask(value, bitmask) { 2809 return (value & bitmask) === bitmask; 2810 } 2811 2812 var DOMPropertyInjection = { 2813 /** 2814 * Mapping from normalized, camelcased property names to a configuration that 2815 * specifies how the associated DOM property should be accessed or rendered. 2816 */ 2817 MUST_USE_PROPERTY: 0x1, 2818 HAS_BOOLEAN_VALUE: 0x4, 2819 HAS_NUMERIC_VALUE: 0x8, 2820 HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8, 2821 HAS_OVERLOADED_BOOLEAN_VALUE: 0x20, 2822 HAS_STRING_BOOLEAN_VALUE: 0x40, 2823 2824 /** 2825 * Inject some specialized knowledge about the DOM. This takes a config object 2826 * with the following properties: 2827 * 2828 * Properties: object mapping DOM property name to one of the 2829 * DOMPropertyInjection constants or null. If your attribute isn't in here, 2830 * it won't get written to the DOM. 2831 * 2832 * DOMAttributeNames: object mapping React attribute name to the DOM 2833 * attribute name. Attribute names not specified use the **lowercase** 2834 * normalized name. 2835 * 2836 * DOMAttributeNamespaces: object mapping React attribute name to the DOM 2837 * attribute namespace URL. (Attribute names not specified use no namespace.) 2838 * 2839 * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. 2840 * Property names not specified use the normalized name. 2841 * 2842 * DOMMutationMethods: Properties that require special mutation methods. If 2843 * `value` is undefined, the mutation method should unset the property. 2844 * 2845 * @param {object} domPropertyConfig the config as described above. 2846 */ 2847 injectDOMPropertyConfig: function (domPropertyConfig) { 2848 var Injection = DOMPropertyInjection; 2849 var Properties = domPropertyConfig.Properties || {}; 2850 var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; 2851 var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; 2852 var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; 2853 2854 for (var propName in Properties) { 2855 !!properties.hasOwnProperty(propName) ? invariant(false, "injectDOMPropertyConfig(...): You're trying to inject DOM property '%s' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.", propName) : void 0; 2856 2857 var lowerCased = propName.toLowerCase(); 2858 var propConfig = Properties[propName]; 2859 2860 var propertyInfo = { 2861 attributeName: lowerCased, 2862 attributeNamespace: null, 2863 propertyName: propName, 2864 mutationMethod: null, 2865 2866 mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), 2867 hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), 2868 hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), 2869 hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), 2870 hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE), 2871 hasStringBooleanValue: checkMask(propConfig, Injection.HAS_STRING_BOOLEAN_VALUE) 2872 }; 2873 !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? invariant(false, "DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s", propName) : void 0; 2874 2875 if (DOMAttributeNames.hasOwnProperty(propName)) { 2876 var attributeName = DOMAttributeNames[propName]; 2877 2878 propertyInfo.attributeName = attributeName; 2879 } 2880 2881 if (DOMAttributeNamespaces.hasOwnProperty(propName)) { 2882 propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; 2883 } 2884 2885 if (DOMMutationMethods.hasOwnProperty(propName)) { 2886 propertyInfo.mutationMethod = DOMMutationMethods[propName]; 2887 } 2888 2889 // Downcase references to whitelist properties to check for membership 2890 // without case-sensitivity. This allows the whitelist to pick up 2891 // `allowfullscreen`, which should be written using the property configuration 2892 // for `allowFullscreen` 2893 properties[propName] = propertyInfo; 2894 } 2895 } 2896 }; 2897 2898 /* eslint-disable max-len */ 2899 var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; 2900 /* eslint-enable max-len */ 2901 var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; 2902 2903 2904 var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 2905 2906 /** 2907 * Map from property "standard name" to an object with info about how to set 2908 * the property in the DOM. Each object contains: 2909 * 2910 * attributeName: 2911 * Used when rendering markup or with `*Attribute()`. 2912 * attributeNamespace 2913 * propertyName: 2914 * Used on DOM node instances. (This includes properties that mutate due to 2915 * external factors.) 2916 * mutationMethod: 2917 * If non-null, used instead of the property or `setAttribute()` after 2918 * initial render. 2919 * mustUseProperty: 2920 * Whether the property must be accessed and mutated as an object property. 2921 * hasBooleanValue: 2922 * Whether the property should be removed when set to a falsey value. 2923 * hasNumericValue: 2924 * Whether the property must be numeric or parse as a numeric and should be 2925 * removed when set to a falsey value. 2926 * hasPositiveNumericValue: 2927 * Whether the property must be positive numeric or parse as a positive 2928 * numeric and should be removed when set to a falsey value. 2929 * hasOverloadedBooleanValue: 2930 * Whether the property can be used as a flag as well as with a value. 2931 * Removed when strictly equal to false; present without a value when 2932 * strictly equal to true; present with a value otherwise. 2933 */ 2934 var properties = {}; 2935 2936 /** 2937 * Checks whether a property name is a writeable attribute. 2938 * @method 2939 */ 2940 function shouldSetAttribute(name, value) { 2941 if (isReservedProp(name)) { 2942 return false; 2943 } 2944 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 2945 return false; 2946 } 2947 if (value === null) { 2948 return true; 2949 } 2950 switch (typeof value) { 2951 case 'boolean': 2952 return shouldAttributeAcceptBooleanValue(name); 2953 case 'undefined': 2954 case 'number': 2955 case 'string': 2956 case 'object': 2957 return true; 2958 default: 2959 // function, symbol 2960 return false; 2961 } 2962 } 2963 2964 function getPropertyInfo(name) { 2965 return properties.hasOwnProperty(name) ? properties[name] : null; 2966 } 2967 2968 function shouldAttributeAcceptBooleanValue(name) { 2969 if (isReservedProp(name)) { 2970 return true; 2971 } 2972 var propertyInfo = getPropertyInfo(name); 2973 if (propertyInfo) { 2974 return propertyInfo.hasBooleanValue || propertyInfo.hasStringBooleanValue || propertyInfo.hasOverloadedBooleanValue; 2975 } 2976 var prefix = name.toLowerCase().slice(0, 5); 2977 return prefix === 'data-' || prefix === 'aria-'; 2978 } 2979 2980 /** 2981 * Checks to see if a property name is within the list of properties 2982 * reserved for internal React operations. These properties should 2983 * not be set on an HTML element. 2984 * 2985 * @private 2986 * @param {string} name 2987 * @return {boolean} If the name is within reserved props 2988 */ 2989 function isReservedProp(name) { 2990 return RESERVED_PROPS.hasOwnProperty(name); 2991 } 2992 2993 var injection = DOMPropertyInjection; 2994 2995 var MUST_USE_PROPERTY = injection.MUST_USE_PROPERTY; 2996 var HAS_BOOLEAN_VALUE = injection.HAS_BOOLEAN_VALUE; 2997 var HAS_NUMERIC_VALUE = injection.HAS_NUMERIC_VALUE; 2998 var HAS_POSITIVE_NUMERIC_VALUE = injection.HAS_POSITIVE_NUMERIC_VALUE; 2999 var HAS_OVERLOADED_BOOLEAN_VALUE = injection.HAS_OVERLOADED_BOOLEAN_VALUE; 3000 var HAS_STRING_BOOLEAN_VALUE = injection.HAS_STRING_BOOLEAN_VALUE; 3001 3002 var HTMLDOMPropertyConfig = { 3003 // When adding attributes to this list, be sure to also add them to 3004 // the `possibleStandardNames` module to ensure casing and incorrect 3005 // name warnings. 3006 Properties: { 3007 allowFullScreen: HAS_BOOLEAN_VALUE, 3008 // specifies target context for links with `preload` type 3009 async: HAS_BOOLEAN_VALUE, 3010 // Note: there is a special case that prevents it from being written to the DOM 3011 // on the client side because the browsers are inconsistent. Instead we call focus(). 3012 autoFocus: HAS_BOOLEAN_VALUE, 3013 autoPlay: HAS_BOOLEAN_VALUE, 3014 capture: HAS_OVERLOADED_BOOLEAN_VALUE, 3015 checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, 3016 cols: HAS_POSITIVE_NUMERIC_VALUE, 3017 contentEditable: HAS_STRING_BOOLEAN_VALUE, 3018 controls: HAS_BOOLEAN_VALUE, 3019 'default': HAS_BOOLEAN_VALUE, 3020 defer: HAS_BOOLEAN_VALUE, 3021 disabled: HAS_BOOLEAN_VALUE, 3022 download: HAS_OVERLOADED_BOOLEAN_VALUE, 3023 draggable: HAS_STRING_BOOLEAN_VALUE, 3024 formNoValidate: HAS_BOOLEAN_VALUE, 3025 hidden: HAS_BOOLEAN_VALUE, 3026 loop: HAS_BOOLEAN_VALUE, 3027 // Caution; `option.selected` is not updated if `select.multiple` is 3028 // disabled with `removeAttribute`. 3029 multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, 3030 muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, 3031 noValidate: HAS_BOOLEAN_VALUE, 3032 open: HAS_BOOLEAN_VALUE, 3033 playsInline: HAS_BOOLEAN_VALUE, 3034 readOnly: HAS_BOOLEAN_VALUE, 3035 required: HAS_BOOLEAN_VALUE, 3036 reversed: HAS_BOOLEAN_VALUE, 3037 rows: HAS_POSITIVE_NUMERIC_VALUE, 3038 rowSpan: HAS_NUMERIC_VALUE, 3039 scoped: HAS_BOOLEAN_VALUE, 3040 seamless: HAS_BOOLEAN_VALUE, 3041 selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, 3042 size: HAS_POSITIVE_NUMERIC_VALUE, 3043 start: HAS_NUMERIC_VALUE, 3044 // support for projecting regular DOM Elements via V1 named slots ( shadow dom ) 3045 span: HAS_POSITIVE_NUMERIC_VALUE, 3046 spellCheck: HAS_STRING_BOOLEAN_VALUE, 3047 // Style must be explicitly set in the attribute list. React components 3048 // expect a style object 3049 style: 0, 3050 // Keep it in the whitelist because it is case-sensitive for SVG. 3051 tabIndex: 0, 3052 // itemScope is for for Microdata support. 3053 // See http://schema.org/docs/gs.html 3054 itemScope: HAS_BOOLEAN_VALUE, 3055 // These attributes must stay in the white-list because they have 3056 // different attribute names (see DOMAttributeNames below) 3057 acceptCharset: 0, 3058 className: 0, 3059 htmlFor: 0, 3060 httpEquiv: 0, 3061 // Attributes with mutation methods must be specified in the whitelist 3062 // Set the string boolean flag to allow the behavior 3063 value: HAS_STRING_BOOLEAN_VALUE 3064 }, 3065 DOMAttributeNames: { 3066 acceptCharset: 'accept-charset', 3067 className: 'class', 3068 htmlFor: 'for', 3069 httpEquiv: 'http-equiv' 3070 }, 3071 DOMMutationMethods: { 3072 value: function (node, value) { 3073 if (value == null) { 3074 return node.removeAttribute('value'); 3075 } 3076 3077 // Number inputs get special treatment due to some edge cases in 3078 // Chrome. Let everything else assign the value attribute as normal. 3079 // https://github.com/facebook/react/issues/7253#issuecomment-236074326 3080 if (node.type !== 'number' || node.hasAttribute('value') === false) { 3081 node.setAttribute('value', '' + value); 3082 } else if (node.validity && !node.validity.badInput && node.ownerDocument.activeElement !== node) { 3083 // Don't assign an attribute if validation reports bad 3084 // input. Chrome will clear the value. Additionally, don't 3085 // operate on inputs that have focus, otherwise Chrome might 3086 // strip off trailing decimal places and cause the user's 3087 // cursor position to jump to the beginning of the input. 3088 // 3089 // In ReactDOMInput, we have an onBlur event that will trigger 3090 // this function again when focus is lost. 3091 node.setAttribute('value', '' + value); 3092 } 3093 } 3094 } 3095 }; 3096 3097 var HAS_STRING_BOOLEAN_VALUE$1 = injection.HAS_STRING_BOOLEAN_VALUE; 3098 3099 3100 var NS = { 3101 xlink: 'http://www.w3.org/1999/xlink', 3102 xml: 'http://www.w3.org/XML/1998/namespace' 3103 }; 3104 3105 /** 3106 * This is a list of all SVG attributes that need special casing, 3107 * namespacing, or boolean value assignment. 3108 * 3109 * When adding attributes to this list, be sure to also add them to 3110 * the `possibleStandardNames` module to ensure casing and incorrect 3111 * name warnings. 3112 * 3113 * SVG Attributes List: 3114 * https://www.w3.org/TR/SVG/attindex.html 3115 * SMIL Spec: 3116 * https://www.w3.org/TR/smil 3117 */ 3118 var ATTRS = ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'x-height', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xmlns:xlink', 'xml:lang', 'xml:space']; 3119 3120 var SVGDOMPropertyConfig = { 3121 Properties: { 3122 autoReverse: HAS_STRING_BOOLEAN_VALUE$1, 3123 externalResourcesRequired: HAS_STRING_BOOLEAN_VALUE$1, 3124 preserveAlpha: HAS_STRING_BOOLEAN_VALUE$1 3125 }, 3126 DOMAttributeNames: { 3127 autoReverse: 'autoReverse', 3128 externalResourcesRequired: 'externalResourcesRequired', 3129 preserveAlpha: 'preserveAlpha' 3130 }, 3131 DOMAttributeNamespaces: { 3132 xlinkActuate: NS.xlink, 3133 xlinkArcrole: NS.xlink, 3134 xlinkHref: NS.xlink, 3135 xlinkRole: NS.xlink, 3136 xlinkShow: NS.xlink, 3137 xlinkTitle: NS.xlink, 3138 xlinkType: NS.xlink, 3139 xmlBase: NS.xml, 3140 xmlLang: NS.xml, 3141 xmlSpace: NS.xml 3142 } 3143 }; 3144 3145 var CAMELIZE = /[\-\:]([a-z])/g; 3146 var capitalize = function (token) { 3147 return token[1].toUpperCase(); 3148 }; 3149 3150 ATTRS.forEach(function (original) { 3151 var reactName = original.replace(CAMELIZE, capitalize); 3152 3153 SVGDOMPropertyConfig.Properties[reactName] = 0; 3154 SVGDOMPropertyConfig.DOMAttributeNames[reactName] = original; 3155 }); 3156 3157 injection.injectDOMPropertyConfig(HTMLDOMPropertyConfig); 3158 injection.injectDOMPropertyConfig(SVGDOMPropertyConfig); 3159 3160 var ReactErrorUtils = { 3161 // Used by Fiber to simulate a try-catch. 3162 _caughtError: null, 3163 _hasCaughtError: false, 3164 3165 // Used by event system to capture/rethrow the first error. 3166 _rethrowError: null, 3167 _hasRethrowError: false, 3168 3169 injection: { 3170 injectErrorUtils: function (injectedErrorUtils) { 3171 !(typeof injectedErrorUtils.invokeGuardedCallback === 'function') ? invariant(false, 'Injected invokeGuardedCallback() must be a function.') : void 0; 3172 invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback; 3173 } 3174 }, 3175 3176 /** 3177 * Call a function while guarding against errors that happens within it. 3178 * Returns an error if it throws, otherwise null. 3179 * 3180 * In production, this is implemented using a try-catch. The reason we don't 3181 * use a try-catch directly is so that we can swap out a different 3182 * implementation in DEV mode. 3183 * 3184 * @param {String} name of the guard to use for logging or debugging 3185 * @param {Function} func The function to invoke 3186 * @param {*} context The context to use when calling the function 3187 * @param {...*} args Arguments for function 3188 */ 3189 invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) { 3190 invokeGuardedCallback.apply(ReactErrorUtils, arguments); 3191 }, 3192 3193 /** 3194 * Same as invokeGuardedCallback, but instead of returning an error, it stores 3195 * it in a global so it can be rethrown by `rethrowCaughtError` later. 3196 * TODO: See if _caughtError and _rethrowError can be unified. 3197 * 3198 * @param {String} name of the guard to use for logging or debugging 3199 * @param {Function} func The function to invoke 3200 * @param {*} context The context to use when calling the function 3201 * @param {...*} args Arguments for function 3202 */ 3203 invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) { 3204 ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); 3205 if (ReactErrorUtils.hasCaughtError()) { 3206 var error = ReactErrorUtils.clearCaughtError(); 3207 if (!ReactErrorUtils._hasRethrowError) { 3208 ReactErrorUtils._hasRethrowError = true; 3209 ReactErrorUtils._rethrowError = error; 3210 } 3211 } 3212 }, 3213 3214 /** 3215 * During execution of guarded functions we will capture the first error which 3216 * we will rethrow to be handled by the top level error handler. 3217 */ 3218 rethrowCaughtError: function () { 3219 return rethrowCaughtError.apply(ReactErrorUtils, arguments); 3220 }, 3221 3222 hasCaughtError: function () { 3223 return ReactErrorUtils._hasCaughtError; 3224 }, 3225 3226 clearCaughtError: function () { 3227 if (ReactErrorUtils._hasCaughtError) { 3228 var error = ReactErrorUtils._caughtError; 3229 ReactErrorUtils._caughtError = null; 3230 ReactErrorUtils._hasCaughtError = false; 3231 return error; 3232 } else { 3233 invariant(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.'); 3234 } 3235 } 3236 }; 3237 3238 var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) { 3239 ReactErrorUtils._hasCaughtError = false; 3240 ReactErrorUtils._caughtError = null; 3241 var funcArgs = Array.prototype.slice.call(arguments, 3); 3242 try { 3243 func.apply(context, funcArgs); 3244 } catch (error) { 3245 ReactErrorUtils._caughtError = error; 3246 ReactErrorUtils._hasCaughtError = true; 3247 } 3248 }; 3249 3250 { 3251 // In DEV mode, we swap out invokeGuardedCallback for a special version 3252 // that plays more nicely with the browser's DevTools. The idea is to preserve 3253 // "Pause on exceptions" behavior. Because React wraps all user-provided 3254 // functions in invokeGuardedCallback, and the production version of 3255 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 3256 // like caught exceptions, and the DevTools won't pause unless the developer 3257 // takes the extra step of enabling pause on caught exceptions. This is 3258 // untintuitive, though, because even though React has caught the error, from 3259 // the developer's perspective, the error is uncaught. 3260 // 3261 // To preserve the expected "Pause on exceptions" behavior, we don't use a 3262 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 3263 // DOM node, and call the user-provided callback from inside an event handler 3264 // for that fake event. If the callback throws, the error is "captured" using 3265 // a global event handler. But because the error happens in a different 3266 // event loop context, it does not interrupt the normal program flow. 3267 // Effectively, this gives us try-catch behavior without actually using 3268 // try-catch. Neat! 3269 3270 // Check that the browser supports the APIs we need to implement our special 3271 // DEV version of invokeGuardedCallback 3272 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 3273 var fakeNode = document.createElement('react'); 3274 3275 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { 3276 // Keeps track of whether the user-provided callback threw an error. We 3277 // set this to true at the beginning, then set it to false right after 3278 // calling the function. If the function errors, `didError` will never be 3279 // set to false. This strategy works even if the browser is flaky and 3280 // fails to call our global error handler, because it doesn't rely on 3281 // the error event at all. 3282 var didError = true; 3283 3284 // Create an event handler for our fake event. We will synchronously 3285 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 3286 // call the user-provided callback. 3287 var funcArgs = Array.prototype.slice.call(arguments, 3); 3288 function callCallback() { 3289 // We immediately remove the callback from event listeners so that 3290 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 3291 // nested call would trigger the fake event handlers of any call higher 3292 // in the stack. 3293 fakeNode.removeEventListener(evtType, callCallback, false); 3294 func.apply(context, funcArgs); 3295 didError = false; 3296 } 3297 3298 // Create a global error event handler. We use this to capture the value 3299 // that was thrown. It's possible that this error handler will fire more 3300 // than once; for example, if non-React code also calls `dispatchEvent` 3301 // and a handler for that event throws. We should be resilient to most of 3302 // those cases. Even if our error event handler fires more than once, the 3303 // last error event is always used. If the callback actually does error, 3304 // we know that the last error event is the correct one, because it's not 3305 // possible for anything else to have happened in between our callback 3306 // erroring and the code that follows the `dispatchEvent` call below. If 3307 // the callback doesn't error, but the error event was fired, we know to 3308 // ignore it because `didError` will be false, as described above. 3309 var error = void 0; 3310 // Use this to track whether the error event is ever called. 3311 var didSetError = false; 3312 var isCrossOriginError = false; 3313 3314 function onError(event) { 3315 error = event.error; 3316 didSetError = true; 3317 if (error === null && event.colno === 0 && event.lineno === 0) { 3318 isCrossOriginError = true; 3319 } 3320 } 3321 3322 // Create a fake event type. 3323 var evtType = 'react-' + (name ? name : 'invokeguardedcallback'); 3324 3325 // Attach our event handlers 3326 window.addEventListener('error', onError); 3327 fakeNode.addEventListener(evtType, callCallback, false); 3328 3329 // Synchronously dispatch our fake event. If the user-provided function 3330 // errors, it will trigger our global error handler. 3331 var evt = document.createEvent('Event'); 3332 evt.initEvent(evtType, false, false); 3333 fakeNode.dispatchEvent(evt); 3334 3335 if (didError) { 3336 if (!didSetError) { 3337 // The callback errored, but the error event never fired. 3338 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.'); 3339 } else if (isCrossOriginError) { 3340 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.'); 3341 } 3342 ReactErrorUtils._hasCaughtError = true; 3343 ReactErrorUtils._caughtError = error; 3344 } else { 3345 ReactErrorUtils._hasCaughtError = false; 3346 ReactErrorUtils._caughtError = null; 3347 } 3348 3349 // Remove our event listeners 3350 window.removeEventListener('error', onError); 3351 }; 3352 3353 invokeGuardedCallback = invokeGuardedCallbackDev; 3354 } 3355 } 3356 3357 var rethrowCaughtError = function () { 3358 if (ReactErrorUtils._hasRethrowError) { 3359 var error = ReactErrorUtils._rethrowError; 3360 ReactErrorUtils._rethrowError = null; 3361 ReactErrorUtils._hasRethrowError = false; 3362 throw error; 3363 } 3364 }; 3365 3366 /** 3367 * Injectable ordering of event plugins. 3368 */ 3369 var eventPluginOrder = null; 3370 3371 /** 3372 * Injectable mapping from names to event plugin modules. 3373 */ 3374 var namesToPlugins = {}; 3375 3376 /** 3377 * Recomputes the plugin list using the injected plugins and plugin ordering. 3378 * 3379 * @private 3380 */ 3381 function recomputePluginOrdering() { 3382 if (!eventPluginOrder) { 3383 // Wait until an `eventPluginOrder` is injected. 3384 return; 3385 } 3386 for (var pluginName in namesToPlugins) { 3387 var pluginModule = namesToPlugins[pluginName]; 3388 var pluginIndex = eventPluginOrder.indexOf(pluginName); 3389 !(pluginIndex > -1) ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0; 3390 if (plugins[pluginIndex]) { 3391 continue; 3392 } 3393 !pluginModule.extractEvents ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0; 3394 plugins[pluginIndex] = pluginModule; 3395 var publishedEvents = pluginModule.eventTypes; 3396 for (var eventName in publishedEvents) { 3397 !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0; 3398 } 3399 } 3400 } 3401 3402 /** 3403 * Publishes an event so that it can be dispatched by the supplied plugin. 3404 * 3405 * @param {object} dispatchConfig Dispatch configuration for the event. 3406 * @param {object} PluginModule Plugin publishing the event. 3407 * @return {boolean} True if the event was successfully published. 3408 * @private 3409 */ 3410 function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { 3411 !!eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0; 3412 eventNameDispatchConfigs[eventName] = dispatchConfig; 3413 3414 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; 3415 if (phasedRegistrationNames) { 3416 for (var phaseName in phasedRegistrationNames) { 3417 if (phasedRegistrationNames.hasOwnProperty(phaseName)) { 3418 var phasedRegistrationName = phasedRegistrationNames[phaseName]; 3419 publishRegistrationName(phasedRegistrationName, pluginModule, eventName); 3420 } 3421 } 3422 return true; 3423 } else if (dispatchConfig.registrationName) { 3424 publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); 3425 return true; 3426 } 3427 return false; 3428 } 3429 3430 /** 3431 * Publishes a registration name that is used to identify dispatched events. 3432 * 3433 * @param {string} registrationName Registration name to add. 3434 * @param {object} PluginModule Plugin publishing the event. 3435 * @private 3436 */ 3437 function publishRegistrationName(registrationName, pluginModule, eventName) { 3438 !!registrationNameModules[registrationName] ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0; 3439 registrationNameModules[registrationName] = pluginModule; 3440 registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; 3441 3442 { 3443 var lowerCasedName = registrationName.toLowerCase(); 3444 possibleRegistrationNames[lowerCasedName] = registrationName; 3445 3446 if (registrationName === 'onDoubleClick') { 3447 possibleRegistrationNames.ondblclick = registrationName; 3448 } 3449 } 3450 } 3451 3452 /** 3453 * Registers plugins so that they can extract and dispatch events. 3454 * 3455 * @see {EventPluginHub} 3456 */ 3457 3458 /** 3459 * Ordered list of injected plugins. 3460 */ 3461 var plugins = []; 3462 3463 /** 3464 * Mapping from event name to dispatch config 3465 */ 3466 var eventNameDispatchConfigs = {}; 3467 3468 /** 3469 * Mapping from registration name to plugin module 3470 */ 3471 var registrationNameModules = {}; 3472 3473 /** 3474 * Mapping from registration name to event name 3475 */ 3476 var registrationNameDependencies = {}; 3477 3478 /** 3479 * Mapping from lowercase registration names to the properly cased version, 3480 * used to warn in the case of missing event handlers. Available 3481 * only in true. 3482 * @type {Object} 3483 */ 3484 var possibleRegistrationNames = {}; 3485 // Trust the developer to only use possibleRegistrationNames in true 3486 3487 /** 3488 * Injects an ordering of plugins (by plugin name). This allows the ordering 3489 * to be decoupled from injection of the actual plugins so that ordering is 3490 * always deterministic regardless of packaging, on-the-fly injection, etc. 3491 * 3492 * @param {array} InjectedEventPluginOrder 3493 * @internal 3494 * @see {EventPluginHub.injection.injectEventPluginOrder} 3495 */ 3496 function injectEventPluginOrder(injectedEventPluginOrder) { 3497 !!eventPluginOrder ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0; 3498 // Clone the ordering so it cannot be dynamically mutated. 3499 eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); 3500 recomputePluginOrdering(); 3501 } 3502 3503 /** 3504 * Injects plugins to be used by `EventPluginHub`. The plugin names must be 3505 * in the ordering injected by `injectEventPluginOrder`. 3506 * 3507 * Plugins can be injected as part of page initialization or on-the-fly. 3508 * 3509 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 3510 * @internal 3511 * @see {EventPluginHub.injection.injectEventPluginsByName} 3512 */ 3513 function injectEventPluginsByName(injectedNamesToPlugins) { 3514 var isOrderingDirty = false; 3515 for (var pluginName in injectedNamesToPlugins) { 3516 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { 3517 continue; 3518 } 3519 var pluginModule = injectedNamesToPlugins[pluginName]; 3520 if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { 3521 !!namesToPlugins[pluginName] ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : void 0; 3522 namesToPlugins[pluginName] = pluginModule; 3523 isOrderingDirty = true; 3524 } 3525 } 3526 if (isOrderingDirty) { 3527 recomputePluginOrdering(); 3528 } 3529 } 3530 3531 var EventPluginRegistry = Object.freeze({ 3532 plugins: plugins, 3533 eventNameDispatchConfigs: eventNameDispatchConfigs, 3534 registrationNameModules: registrationNameModules, 3535 registrationNameDependencies: registrationNameDependencies, 3536 possibleRegistrationNames: possibleRegistrationNames, 3537 injectEventPluginOrder: injectEventPluginOrder, 3538 injectEventPluginsByName: injectEventPluginsByName 3539 }); 3540 3541 var getFiberCurrentPropsFromNode = null; 3542 var getInstanceFromNode = null; 3543 var getNodeFromInstance = null; 3544 3545 var injection$2 = { 3546 injectComponentTree: function (Injected) { 3547 getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode; 3548 getInstanceFromNode = Injected.getInstanceFromNode; 3549 getNodeFromInstance = Injected.getNodeFromInstance; 3550 3551 { 3552 warning(getNodeFromInstance && getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); 3553 } 3554 } 3555 }; 3556 3557 3558 3559 3560 3561 3562 var validateEventDispatches; 3563 { 3564 validateEventDispatches = function (event) { 3565 var dispatchListeners = event._dispatchListeners; 3566 var dispatchInstances = event._dispatchInstances; 3567 3568 var listenersIsArr = Array.isArray(dispatchListeners); 3569 var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; 3570 3571 var instancesIsArr = Array.isArray(dispatchInstances); 3572 var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; 3573 3574 warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.'); 3575 }; 3576 } 3577 3578 /** 3579 * Dispatch the event to the listener. 3580 * @param {SyntheticEvent} event SyntheticEvent to handle 3581 * @param {boolean} simulated If the event is simulated (changes exn behavior) 3582 * @param {function} listener Application-level callback 3583 * @param {*} inst Internal component instance 3584 */ 3585 function executeDispatch(event, simulated, listener, inst) { 3586 var type = event.type || 'unknown-event'; 3587 event.currentTarget = getNodeFromInstance(inst); 3588 ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 3589 event.currentTarget = null; 3590 } 3591 3592 /** 3593 * Standard/simple iteration through an event's collected dispatches. 3594 */ 3595 function executeDispatchesInOrder(event, simulated) { 3596 var dispatchListeners = event._dispatchListeners; 3597 var dispatchInstances = event._dispatchInstances; 3598 { 3599 validateEventDispatches(event); 3600 } 3601 if (Array.isArray(dispatchListeners)) { 3602 for (var i = 0; i < dispatchListeners.length; i++) { 3603 if (event.isPropagationStopped()) { 3604 break; 3605 } 3606 // Listeners and Instances are two parallel arrays that are always in sync. 3607 executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]); 3608 } 3609 } else if (dispatchListeners) { 3610 executeDispatch(event, simulated, dispatchListeners, dispatchInstances); 3611 } 3612 event._dispatchListeners = null; 3613 event._dispatchInstances = null; 3614 } 3615 3616 /** 3617 * @see executeDispatchesInOrderStopAtTrueImpl 3618 */ 3619 3620 3621 /** 3622 * Execution of a "direct" dispatch - there must be at most one dispatch 3623 * accumulated on the event or it is considered an error. It doesn't really make 3624 * sense for an event with multiple dispatches (bubbled) to keep track of the 3625 * return values at each dispatch execution, but it does tend to make sense when 3626 * dealing with "direct" dispatches. 3627 * 3628 * @return {*} The return value of executing the single dispatch. 3629 */ 3630 3631 3632 /** 3633 * @param {SyntheticEvent} event 3634 * @return {boolean} True iff number of dispatches accumulated is greater than 0. 3635 */ 3636 3637 /** 3638 * Accumulates items that must not be null or undefined into the first one. This 3639 * is used to conserve memory by avoiding array allocations, and thus sacrifices 3640 * API cleanness. Since `current` can be null before being passed in and not 3641 * null after this function, make sure to assign it back to `current`: 3642 * 3643 * `a = accumulateInto(a, b);` 3644 * 3645 * This API should be sparingly used. Try `accumulate` for something cleaner. 3646 * 3647 * @return {*|array<*>} An accumulation of items. 3648 */ 3649 3650 function accumulateInto(current, next) { 3651 !(next != null) ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0; 3652 3653 if (current == null) { 3654 return next; 3655 } 3656 3657 // Both are not empty. Warning: Never call x.concat(y) when you are not 3658 // certain that x is an Array (x could be a string with concat method). 3659 if (Array.isArray(current)) { 3660 if (Array.isArray(next)) { 3661 current.push.apply(current, next); 3662 return current; 3663 } 3664 current.push(next); 3665 return current; 3666 } 3667 3668 if (Array.isArray(next)) { 3669 // A bit too dangerous to mutate `next`. 3670 return [current].concat(next); 3671 } 3672 3673 return [current, next]; 3674 } 3675 3676 /** 3677 * @param {array} arr an "accumulation" of items which is either an Array or 3678 * a single item. Useful when paired with the `accumulate` module. This is a 3679 * simple utility that allows us to reason about a collection of items, but 3680 * handling the case when there is exactly one item (and we do not need to 3681 * allocate an array). 3682 * @param {function} cb Callback invoked with each element or a collection. 3683 * @param {?} [scope] Scope used as `this` in a callback. 3684 */ 3685 function forEachAccumulated(arr, cb, scope) { 3686 if (Array.isArray(arr)) { 3687 arr.forEach(cb, scope); 3688 } else if (arr) { 3689 cb.call(scope, arr); 3690 } 3691 } 3692 3693 /** 3694 * Internal queue of events that have accumulated their dispatches and are 3695 * waiting to have their dispatches executed. 3696 */ 3697 var eventQueue = null; 3698 3699 /** 3700 * Dispatches an event and releases it back into the pool, unless persistent. 3701 * 3702 * @param {?object} event Synthetic event to be dispatched. 3703 * @param {boolean} simulated If the event is simulated (changes exn behavior) 3704 * @private 3705 */ 3706 var executeDispatchesAndRelease = function (event, simulated) { 3707 if (event) { 3708 executeDispatchesInOrder(event, simulated); 3709 3710 if (!event.isPersistent()) { 3711 event.constructor.release(event); 3712 } 3713 } 3714 }; 3715 var executeDispatchesAndReleaseSimulated = function (e) { 3716 return executeDispatchesAndRelease(e, true); 3717 }; 3718 var executeDispatchesAndReleaseTopLevel = function (e) { 3719 return executeDispatchesAndRelease(e, false); 3720 }; 3721 3722 function isInteractive(tag) { 3723 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 3724 } 3725 3726 function shouldPreventMouseEvent(name, type, props) { 3727 switch (name) { 3728 case 'onClick': 3729 case 'onClickCapture': 3730 case 'onDoubleClick': 3731 case 'onDoubleClickCapture': 3732 case 'onMouseDown': 3733 case 'onMouseDownCapture': 3734 case 'onMouseMove': 3735 case 'onMouseMoveCapture': 3736 case 'onMouseUp': 3737 case 'onMouseUpCapture': 3738 return !!(props.disabled && isInteractive(type)); 3739 default: 3740 return false; 3741 } 3742 } 3743 3744 /** 3745 * This is a unified interface for event plugins to be installed and configured. 3746 * 3747 * Event plugins can implement the following properties: 3748 * 3749 * `extractEvents` {function(string, DOMEventTarget, string, object): *} 3750 * Required. When a top-level event is fired, this method is expected to 3751 * extract synthetic events that will in turn be queued and dispatched. 3752 * 3753 * `eventTypes` {object} 3754 * Optional, plugins that fire events must publish a mapping of registration 3755 * names that are used to register listeners. Values of this mapping must 3756 * be objects that contain `registrationName` or `phasedRegistrationNames`. 3757 * 3758 * `executeDispatch` {function(object, function, string)} 3759 * Optional, allows plugins to override how an event gets dispatched. By 3760 * default, the listener is simply invoked. 3761 * 3762 * Each plugin that is injected into `EventsPluginHub` is immediately operable. 3763 * 3764 * @public 3765 */ 3766 3767 /** 3768 * Methods for injecting dependencies. 3769 */ 3770 var injection$1 = { 3771 /** 3772 * @param {array} InjectedEventPluginOrder 3773 * @public 3774 */ 3775 injectEventPluginOrder: injectEventPluginOrder, 3776 3777 /** 3778 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 3779 */ 3780 injectEventPluginsByName: injectEventPluginsByName 3781 }; 3782 3783 /** 3784 * @param {object} inst The instance, which is the source of events. 3785 * @param {string} registrationName Name of listener (e.g. `onClick`). 3786 * @return {?function} The stored callback. 3787 */ 3788 function getListener(inst, registrationName) { 3789 var listener; 3790 3791 // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not 3792 // live here; needs to be moved to a better place soon 3793 var stateNode = inst.stateNode; 3794 if (!stateNode) { 3795 // Work in progress (ex: onload events in incremental mode). 3796 return null; 3797 } 3798 var props = getFiberCurrentPropsFromNode(stateNode); 3799 if (!props) { 3800 // Work in progress. 3801 return null; 3802 } 3803 listener = props[registrationName]; 3804 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 3805 return null; 3806 } 3807 !(!listener || typeof listener === 'function') ? invariant(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0; 3808 return listener; 3809 } 3810 3811 /** 3812 * Allows registered plugins an opportunity to extract events from top-level 3813 * native browser events. 3814 * 3815 * @return {*} An accumulation of synthetic events. 3816 * @internal 3817 */ 3818 function extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 3819 var events; 3820 for (var i = 0; i < plugins.length; i++) { 3821 // Not every plugin in the ordering may be loaded at runtime. 3822 var possiblePlugin = plugins[i]; 3823 if (possiblePlugin) { 3824 var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); 3825 if (extractedEvents) { 3826 events = accumulateInto(events, extractedEvents); 3827 } 3828 } 3829 } 3830 return events; 3831 } 3832 3833 /** 3834 * Enqueues a synthetic event that should be dispatched when 3835 * `processEventQueue` is invoked. 3836 * 3837 * @param {*} events An accumulation of synthetic events. 3838 * @internal 3839 */ 3840 function enqueueEvents(events) { 3841 if (events) { 3842 eventQueue = accumulateInto(eventQueue, events); 3843 } 3844 } 3845 3846 /** 3847 * Dispatches all synthetic events on the event queue. 3848 * 3849 * @internal 3850 */ 3851 function processEventQueue(simulated) { 3852 // Set `eventQueue` to null before processing it so that we can tell if more 3853 // events get enqueued while processing. 3854 var processingEventQueue = eventQueue; 3855 eventQueue = null; 3856 3857 if (!processingEventQueue) { 3858 return; 3859 } 3860 3861 if (simulated) { 3862 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated); 3863 } else { 3864 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); 3865 } 3866 !!eventQueue ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0; 3867 // This would be a good time to rethrow if any of the event handlers threw. 3868 ReactErrorUtils.rethrowCaughtError(); 3869 } 3870 3871 var EventPluginHub = Object.freeze({ 3872 injection: injection$1, 3873 getListener: getListener, 3874 extractEvents: extractEvents, 3875 enqueueEvents: enqueueEvents, 3876 processEventQueue: processEventQueue 3877 }); 3878 3879 var IndeterminateComponent = 0; // Before we know whether it is functional or class 3880 var FunctionalComponent = 1; 3881 var ClassComponent = 2; 3882 var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 3883 var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 3884 var HostComponent = 5; 3885 var HostText = 6; 3886 var CallComponent = 7; 3887 var CallHandlerPhase = 8; 3888 var ReturnComponent = 9; 3889 var Fragment = 10; 3890 3891 var randomKey = Math.random().toString(36).slice(2); 3892 var internalInstanceKey = '__reactInternalInstance$' + randomKey; 3893 var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; 3894 3895 function precacheFiberNode$1(hostInst, node) { 3896 node[internalInstanceKey] = hostInst; 3897 } 3898 3899 /** 3900 * Given a DOM node, return the closest ReactDOMComponent or 3901 * ReactDOMTextComponent instance ancestor. 3902 */ 3903 function getClosestInstanceFromNode(node) { 3904 if (node[internalInstanceKey]) { 3905 return node[internalInstanceKey]; 3906 } 3907 3908 // Walk up the tree until we find an ancestor whose instance we have cached. 3909 var parents = []; 3910 while (!node[internalInstanceKey]) { 3911 parents.push(node); 3912 if (node.parentNode) { 3913 node = node.parentNode; 3914 } else { 3915 // Top of the tree. This node must not be part of a React tree (or is 3916 // unmounted, potentially). 3917 return null; 3918 } 3919 } 3920 3921 var closest = void 0; 3922 var inst = node[internalInstanceKey]; 3923 if (inst.tag === HostComponent || inst.tag === HostText) { 3924 // In Fiber, this will always be the deepest root. 3925 return inst; 3926 } 3927 for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) { 3928 closest = inst; 3929 } 3930 3931 return closest; 3932 } 3933 3934 /** 3935 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 3936 * instance, or null if the node was not rendered by this React. 3937 */ 3938 function getInstanceFromNode$1(node) { 3939 var inst = node[internalInstanceKey]; 3940 if (inst) { 3941 if (inst.tag === HostComponent || inst.tag === HostText) { 3942 return inst; 3943 } else { 3944 return null; 3945 } 3946 } 3947 return null; 3948 } 3949 3950 /** 3951 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 3952 * DOM node. 3953 */ 3954 function getNodeFromInstance$1(inst) { 3955 if (inst.tag === HostComponent || inst.tag === HostText) { 3956 // In Fiber this, is just the state node right now. We assume it will be 3957 // a host component or host text. 3958 return inst.stateNode; 3959 } 3960 3961 // Without this first invariant, passing a non-DOM-component triggers the next 3962 // invariant for a missing parent, which is super confusing. 3963 invariant(false, 'getNodeFromInstance: Invalid argument.'); 3964 } 3965 3966 function getFiberCurrentPropsFromNode$1(node) { 3967 return node[internalEventHandlersKey] || null; 3968 } 3969 3970 function updateFiberProps$1(node, props) { 3971 node[internalEventHandlersKey] = props; 3972 } 3973 3974 var ReactDOMComponentTree = Object.freeze({ 3975 precacheFiberNode: precacheFiberNode$1, 3976 getClosestInstanceFromNode: getClosestInstanceFromNode, 3977 getInstanceFromNode: getInstanceFromNode$1, 3978 getNodeFromInstance: getNodeFromInstance$1, 3979 getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode$1, 3980 updateFiberProps: updateFiberProps$1 3981 }); 3982 3983 function getParent(inst) { 3984 do { 3985 inst = inst['return']; 3986 // TODO: If this is a HostRoot we might want to bail out. 3987 // That is depending on if we want nested subtrees (layers) to bubble 3988 // events to their parent. We could also go through parentNode on the 3989 // host node but that wouldn't work for React Native and doesn't let us 3990 // do the portal feature. 3991 } while (inst && inst.tag !== HostComponent); 3992 if (inst) { 3993 return inst; 3994 } 3995 return null; 3996 } 3997 3998 /** 3999 * Return the lowest common ancestor of A and B, or null if they are in 4000 * different trees. 4001 */ 4002 function getLowestCommonAncestor(instA, instB) { 4003 var depthA = 0; 4004 for (var tempA = instA; tempA; tempA = getParent(tempA)) { 4005 depthA++; 4006 } 4007 var depthB = 0; 4008 for (var tempB = instB; tempB; tempB = getParent(tempB)) { 4009 depthB++; 4010 } 4011 4012 // If A is deeper, crawl up. 4013 while (depthA - depthB > 0) { 4014 instA = getParent(instA); 4015 depthA--; 4016 } 4017 4018 // If B is deeper, crawl up. 4019 while (depthB - depthA > 0) { 4020 instB = getParent(instB); 4021 depthB--; 4022 } 4023 4024 // Walk in lockstep until we find a match. 4025 var depth = depthA; 4026 while (depth--) { 4027 if (instA === instB || instA === instB.alternate) { 4028 return instA; 4029 } 4030 instA = getParent(instA); 4031 instB = getParent(instB); 4032 } 4033 return null; 4034 } 4035 4036 /** 4037 * Return if A is an ancestor of B. 4038 */ 4039 4040 4041 /** 4042 * Return the parent instance of the passed-in instance. 4043 */ 4044 function getParentInstance(inst) { 4045 return getParent(inst); 4046 } 4047 4048 /** 4049 * Simulates the traversal of a two-phase, capture/bubble event dispatch. 4050 */ 4051 function traverseTwoPhase(inst, fn, arg) { 4052 var path = []; 4053 while (inst) { 4054 path.push(inst); 4055 inst = getParent(inst); 4056 } 4057 var i; 4058 for (i = path.length; i-- > 0;) { 4059 fn(path[i], 'captured', arg); 4060 } 4061 for (i = 0; i < path.length; i++) { 4062 fn(path[i], 'bubbled', arg); 4063 } 4064 } 4065 4066 /** 4067 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that 4068 * should would receive a `mouseEnter` or `mouseLeave` event. 4069 * 4070 * Does not invoke the callback on the nearest common ancestor because nothing 4071 * "entered" or "left" that element. 4072 */ 4073 function traverseEnterLeave(from, to, fn, argFrom, argTo) { 4074 var common = from && to ? getLowestCommonAncestor(from, to) : null; 4075 var pathFrom = []; 4076 while (true) { 4077 if (!from) { 4078 break; 4079 } 4080 if (from === common) { 4081 break; 4082 } 4083 var alternate = from.alternate; 4084 if (alternate !== null && alternate === common) { 4085 break; 4086 } 4087 pathFrom.push(from); 4088 from = getParent(from); 4089 } 4090 var pathTo = []; 4091 while (true) { 4092 if (!to) { 4093 break; 4094 } 4095 if (to === common) { 4096 break; 4097 } 4098 var _alternate = to.alternate; 4099 if (_alternate !== null && _alternate === common) { 4100 break; 4101 } 4102 pathTo.push(to); 4103 to = getParent(to); 4104 } 4105 for (var i = 0; i < pathFrom.length; i++) { 4106 fn(pathFrom[i], 'bubbled', argFrom); 4107 } 4108 for (var _i = pathTo.length; _i-- > 0;) { 4109 fn(pathTo[_i], 'captured', argTo); 4110 } 4111 } 4112 4113 /** 4114 * Some event types have a notion of different registration names for different 4115 * "phases" of propagation. This finds listeners by a given phase. 4116 */ 4117 function listenerAtPhase(inst, event, propagationPhase) { 4118 var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; 4119 return getListener(inst, registrationName); 4120 } 4121 4122 /** 4123 * A small set of propagation patterns, each of which will accept a small amount 4124 * of information, and generate a set of "dispatch ready event objects" - which 4125 * are sets of events that have already been annotated with a set of dispatched 4126 * listener functions/ids. The API is designed this way to discourage these 4127 * propagation strategies from actually executing the dispatches, since we 4128 * always want to collect the entire set of dispatches before executing even a 4129 * single one. 4130 */ 4131 4132 /** 4133 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function 4134 * here, allows us to not have to bind or create functions for each event. 4135 * Mutating the event's members allows us to not have to create a wrapping 4136 * "dispatch" object that pairs the event with the listener. 4137 */ 4138 function accumulateDirectionalDispatches(inst, phase, event) { 4139 { 4140 warning(inst, 'Dispatching inst must not be null'); 4141 } 4142 var listener = listenerAtPhase(inst, event, phase); 4143 if (listener) { 4144 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 4145 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 4146 } 4147 } 4148 4149 /** 4150 * Collect dispatches (must be entirely collected before dispatching - see unit 4151 * tests). Lazily allocate the array to conserve memory. We must loop through 4152 * each event and perform the traversal for each one. We cannot perform a 4153 * single traversal for the entire collection of events because each event may 4154 * have a different target. 4155 */ 4156 function accumulateTwoPhaseDispatchesSingle(event) { 4157 if (event && event.dispatchConfig.phasedRegistrationNames) { 4158 traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); 4159 } 4160 } 4161 4162 /** 4163 * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. 4164 */ 4165 function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { 4166 if (event && event.dispatchConfig.phasedRegistrationNames) { 4167 var targetInst = event._targetInst; 4168 var parentInst = targetInst ? getParentInstance(targetInst) : null; 4169 traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); 4170 } 4171 } 4172 4173 /** 4174 * Accumulates without regard to direction, does not look for phased 4175 * registration names. Same as `accumulateDirectDispatchesSingle` but without 4176 * requiring that the `dispatchMarker` be the same as the dispatched ID. 4177 */ 4178 function accumulateDispatches(inst, ignoredDirection, event) { 4179 if (inst && event && event.dispatchConfig.registrationName) { 4180 var registrationName = event.dispatchConfig.registrationName; 4181 var listener = getListener(inst, registrationName); 4182 if (listener) { 4183 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 4184 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 4185 } 4186 } 4187 } 4188 4189 /** 4190 * Accumulates dispatches on an `SyntheticEvent`, but only for the 4191 * `dispatchMarker`. 4192 * @param {SyntheticEvent} event 4193 */ 4194 function accumulateDirectDispatchesSingle(event) { 4195 if (event && event.dispatchConfig.registrationName) { 4196 accumulateDispatches(event._targetInst, null, event); 4197 } 4198 } 4199 4200 function accumulateTwoPhaseDispatches(events) { 4201 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); 4202 } 4203 4204 function accumulateTwoPhaseDispatchesSkipTarget(events) { 4205 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); 4206 } 4207 4208 function accumulateEnterLeaveDispatches(leave, enter, from, to) { 4209 traverseEnterLeave(from, to, accumulateDispatches, leave, enter); 4210 } 4211 4212 function accumulateDirectDispatches(events) { 4213 forEachAccumulated(events, accumulateDirectDispatchesSingle); 4214 } 4215 4216 var EventPropagators = Object.freeze({ 4217 accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches, 4218 accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget, 4219 accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches, 4220 accumulateDirectDispatches: accumulateDirectDispatches 4221 }); 4222 4223 var contentKey = null; 4224 4225 /** 4226 * Gets the key used to access text content on a DOM node. 4227 * 4228 * @return {?string} Key used to access text content. 4229 * @internal 4230 */ 4231 function getTextContentAccessor() { 4232 if (!contentKey && ExecutionEnvironment.canUseDOM) { 4233 // Prefer textContent to innerText because many browsers support both but 4234 // SVG <text> elements don't support innerText even when <div> does. 4235 contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText'; 4236 } 4237 return contentKey; 4238 } 4239 4240 /** 4241 * This helper object stores information about text content of a target node, 4242 * allowing comparison of content before and after a given event. 4243 * 4244 * Identify the node where selection currently begins, then observe 4245 * both its text content and its current position in the DOM. Since the 4246 * browser may natively replace the target node during composition, we can 4247 * use its position to find its replacement. 4248 * 4249 * 4250 */ 4251 var compositionState = { 4252 _root: null, 4253 _startText: null, 4254 _fallbackText: null 4255 }; 4256 4257 function initialize(nativeEventTarget) { 4258 compositionState._root = nativeEventTarget; 4259 compositionState._startText = getText(); 4260 return true; 4261 } 4262 4263 function reset() { 4264 compositionState._root = null; 4265 compositionState._startText = null; 4266 compositionState._fallbackText = null; 4267 } 4268 4269 function getData() { 4270 if (compositionState._fallbackText) { 4271 return compositionState._fallbackText; 4272 } 4273 4274 var start; 4275 var startValue = compositionState._startText; 4276 var startLength = startValue.length; 4277 var end; 4278 var endValue = getText(); 4279 var endLength = endValue.length; 4280 4281 for (start = 0; start < startLength; start++) { 4282 if (startValue[start] !== endValue[start]) { 4283 break; 4284 } 4285 } 4286 4287 var minEnd = startLength - start; 4288 for (end = 1; end <= minEnd; end++) { 4289 if (startValue[startLength - end] !== endValue[endLength - end]) { 4290 break; 4291 } 4292 } 4293 4294 var sliceTail = end > 1 ? 1 - end : undefined; 4295 compositionState._fallbackText = endValue.slice(start, sliceTail); 4296 return compositionState._fallbackText; 4297 } 4298 4299 function getText() { 4300 if ('value' in compositionState._root) { 4301 return compositionState._root.value; 4302 } 4303 return compositionState._root[getTextContentAccessor()]; 4304 } 4305 4306 /* eslint valid-typeof: 0 */ 4307 4308 var didWarnForAddedNewProperty = false; 4309 var isProxySupported = typeof Proxy === 'function'; 4310 var EVENT_POOL_SIZE = 10; 4311 4312 var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; 4313 4314 /** 4315 * @interface Event 4316 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 4317 */ 4318 var EventInterface = { 4319 type: null, 4320 target: null, 4321 // currentTarget is set when dispatching; no use in copying it here 4322 currentTarget: emptyFunction.thatReturnsNull, 4323 eventPhase: null, 4324 bubbles: null, 4325 cancelable: null, 4326 timeStamp: function (event) { 4327 return event.timeStamp || Date.now(); 4328 }, 4329 defaultPrevented: null, 4330 isTrusted: null 4331 }; 4332 4333 /** 4334 * Synthetic events are dispatched by event plugins, typically in response to a 4335 * top-level event delegation handler. 4336 * 4337 * These systems should generally use pooling to reduce the frequency of garbage 4338 * collection. The system should check `isPersistent` to determine whether the 4339 * event should be released into the pool after being dispatched. Users that 4340 * need a persisted event should invoke `persist`. 4341 * 4342 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 4343 * normalizing browser quirks. Subclasses do not necessarily have to implement a 4344 * DOM interface; custom application-specific events can also subclass this. 4345 * 4346 * @param {object} dispatchConfig Configuration used to dispatch this event. 4347 * @param {*} targetInst Marker identifying the event target. 4348 * @param {object} nativeEvent Native browser event. 4349 * @param {DOMEventTarget} nativeEventTarget Target node. 4350 */ 4351 function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { 4352 { 4353 // these have a getter/setter for warnings 4354 delete this.nativeEvent; 4355 delete this.preventDefault; 4356 delete this.stopPropagation; 4357 } 4358 4359 this.dispatchConfig = dispatchConfig; 4360 this._targetInst = targetInst; 4361 this.nativeEvent = nativeEvent; 4362 4363 var Interface = this.constructor.Interface; 4364 for (var propName in Interface) { 4365 if (!Interface.hasOwnProperty(propName)) { 4366 continue; 4367 } 4368 { 4369 delete this[propName]; // this has a getter/setter for warnings 4370 } 4371 var normalize = Interface[propName]; 4372 if (normalize) { 4373 this[propName] = normalize(nativeEvent); 4374 } else { 4375 if (propName === 'target') { 4376 this.target = nativeEventTarget; 4377 } else { 4378 this[propName] = nativeEvent[propName]; 4379 } 4380 } 4381 } 4382 4383 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 4384 if (defaultPrevented) { 4385 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 4386 } else { 4387 this.isDefaultPrevented = emptyFunction.thatReturnsFalse; 4388 } 4389 this.isPropagationStopped = emptyFunction.thatReturnsFalse; 4390 return this; 4391 } 4392 4393 _assign(SyntheticEvent.prototype, { 4394 preventDefault: function () { 4395 this.defaultPrevented = true; 4396 var event = this.nativeEvent; 4397 if (!event) { 4398 return; 4399 } 4400 4401 if (event.preventDefault) { 4402 event.preventDefault(); 4403 } else if (typeof event.returnValue !== 'unknown') { 4404 event.returnValue = false; 4405 } 4406 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 4407 }, 4408 4409 stopPropagation: function () { 4410 var event = this.nativeEvent; 4411 if (!event) { 4412 return; 4413 } 4414 4415 if (event.stopPropagation) { 4416 event.stopPropagation(); 4417 } else if (typeof event.cancelBubble !== 'unknown') { 4418 // The ChangeEventPlugin registers a "propertychange" event for 4419 // IE. This event does not support bubbling or cancelling, and 4420 // any references to cancelBubble throw "Member not found". A 4421 // typeof check of "unknown" circumvents this issue (and is also 4422 // IE specific). 4423 event.cancelBubble = true; 4424 } 4425 4426 this.isPropagationStopped = emptyFunction.thatReturnsTrue; 4427 }, 4428 4429 /** 4430 * We release all dispatched `SyntheticEvent`s after each event loop, adding 4431 * them back into the pool. This allows a way to hold onto a reference that 4432 * won't be added back into the pool. 4433 */ 4434 persist: function () { 4435 this.isPersistent = emptyFunction.thatReturnsTrue; 4436 }, 4437 4438 /** 4439 * Checks if this event should be released back into the pool. 4440 * 4441 * @return {boolean} True if this should not be released, false otherwise. 4442 */ 4443 isPersistent: emptyFunction.thatReturnsFalse, 4444 4445 /** 4446 * `PooledClass` looks for `destructor` on each instance it releases. 4447 */ 4448 destructor: function () { 4449 var Interface = this.constructor.Interface; 4450 for (var propName in Interface) { 4451 { 4452 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); 4453 } 4454 } 4455 for (var i = 0; i < shouldBeReleasedProperties.length; i++) { 4456 this[shouldBeReleasedProperties[i]] = null; 4457 } 4458 { 4459 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); 4460 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction)); 4461 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction)); 4462 } 4463 } 4464 }); 4465 4466 SyntheticEvent.Interface = EventInterface; 4467 4468 /** 4469 * Helper to reduce boilerplate when creating subclasses. 4470 * 4471 * @param {function} Class 4472 * @param {?object} Interface 4473 */ 4474 SyntheticEvent.augmentClass = function (Class, Interface) { 4475 var Super = this; 4476 4477 var E = function () {}; 4478 E.prototype = Super.prototype; 4479 var prototype = new E(); 4480 4481 _assign(prototype, Class.prototype); 4482 Class.prototype = prototype; 4483 Class.prototype.constructor = Class; 4484 4485 Class.Interface = _assign({}, Super.Interface, Interface); 4486 Class.augmentClass = Super.augmentClass; 4487 addEventPoolingTo(Class); 4488 }; 4489 4490 /** Proxying after everything set on SyntheticEvent 4491 * to resolve Proxy issue on some WebKit browsers 4492 * in which some Event properties are set to undefined (GH#10010) 4493 */ 4494 { 4495 if (isProxySupported) { 4496 /*eslint-disable no-func-assign */ 4497 SyntheticEvent = new Proxy(SyntheticEvent, { 4498 construct: function (target, args) { 4499 return this.apply(target, Object.create(target.prototype), args); 4500 }, 4501 apply: function (constructor, that, args) { 4502 return new Proxy(constructor.apply(that, args), { 4503 set: function (target, prop, value) { 4504 if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { 4505 warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); 4506 didWarnForAddedNewProperty = true; 4507 } 4508 target[prop] = value; 4509 return true; 4510 } 4511 }); 4512 } 4513 }); 4514 /*eslint-enable no-func-assign */ 4515 } 4516 } 4517 4518 addEventPoolingTo(SyntheticEvent); 4519 4520 /** 4521 * Helper to nullify syntheticEvent instance properties when destructing 4522 * 4523 * @param {String} propName 4524 * @param {?object} getVal 4525 * @return {object} defineProperty object 4526 */ 4527 function getPooledWarningPropertyDefinition(propName, getVal) { 4528 var isFunction = typeof getVal === 'function'; 4529 return { 4530 configurable: true, 4531 set: set, 4532 get: get 4533 }; 4534 4535 function set(val) { 4536 var action = isFunction ? 'setting the method' : 'setting the property'; 4537 warn(action, 'This is effectively a no-op'); 4538 return val; 4539 } 4540 4541 function get() { 4542 var action = isFunction ? 'accessing the method' : 'accessing the property'; 4543 var result = isFunction ? 'This is a no-op function' : 'This is set to null'; 4544 warn(action, result); 4545 return getVal; 4546 } 4547 4548 function warn(action, result) { 4549 var warningCondition = false; 4550 warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); 4551 } 4552 } 4553 4554 function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { 4555 var EventConstructor = this; 4556 if (EventConstructor.eventPool.length) { 4557 var instance = EventConstructor.eventPool.pop(); 4558 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); 4559 return instance; 4560 } 4561 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); 4562 } 4563 4564 function releasePooledEvent(event) { 4565 var EventConstructor = this; 4566 !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0; 4567 event.destructor(); 4568 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { 4569 EventConstructor.eventPool.push(event); 4570 } 4571 } 4572 4573 function addEventPoolingTo(EventConstructor) { 4574 EventConstructor.eventPool = []; 4575 EventConstructor.getPooled = getPooledEvent; 4576 EventConstructor.release = releasePooledEvent; 4577 } 4578 4579 var SyntheticEvent$1 = SyntheticEvent; 4580 4581 /** 4582 * @interface Event 4583 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 4584 */ 4585 var CompositionEventInterface = { 4586 data: null 4587 }; 4588 4589 /** 4590 * @param {object} dispatchConfig Configuration used to dispatch this event. 4591 * @param {string} dispatchMarker Marker identifying the event target. 4592 * @param {object} nativeEvent Native browser event. 4593 * @extends {SyntheticEvent} 4594 */ 4595 function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 4596 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 4597 } 4598 4599 SyntheticEvent$1.augmentClass(SyntheticCompositionEvent, CompositionEventInterface); 4600 4601 /** 4602 * @interface Event 4603 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 4604 * /#events-inputevents 4605 */ 4606 var InputEventInterface = { 4607 data: null 4608 }; 4609 4610 /** 4611 * @param {object} dispatchConfig Configuration used to dispatch this event. 4612 * @param {string} dispatchMarker Marker identifying the event target. 4613 * @param {object} nativeEvent Native browser event. 4614 * @extends {SyntheticEvent} 4615 */ 4616 function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 4617 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 4618 } 4619 4620 SyntheticEvent$1.augmentClass(SyntheticInputEvent, InputEventInterface); 4621 4622 var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 4623 var START_KEYCODE = 229; 4624 4625 var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window; 4626 4627 var documentMode = null; 4628 if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) { 4629 documentMode = document.documentMode; 4630 } 4631 4632 // Webkit offers a very useful `textInput` event that can be used to 4633 // directly represent `beforeInput`. The IE `textinput` event is not as 4634 // useful, so we don't use it. 4635 var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto(); 4636 4637 // In IE9+, we have access to composition events, but the data supplied 4638 // by the native compositionend event may be incorrect. Japanese ideographic 4639 // spaces, for instance (\u3000) are not recorded correctly. 4640 var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 4641 4642 /** 4643 * Opera <= 12 includes TextEvent in window, but does not fire 4644 * text input events. Rely on keypress instead. 4645 */ 4646 function isPresto() { 4647 var opera = window.opera; 4648 return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; 4649 } 4650 4651 var SPACEBAR_CODE = 32; 4652 var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); 4653 4654 // Events and their corresponding property names. 4655 var eventTypes = { 4656 beforeInput: { 4657 phasedRegistrationNames: { 4658 bubbled: 'onBeforeInput', 4659 captured: 'onBeforeInputCapture' 4660 }, 4661 dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste'] 4662 }, 4663 compositionEnd: { 4664 phasedRegistrationNames: { 4665 bubbled: 'onCompositionEnd', 4666 captured: 'onCompositionEndCapture' 4667 }, 4668 dependencies: ['topBlur', 'topCompositionEnd', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] 4669 }, 4670 compositionStart: { 4671 phasedRegistrationNames: { 4672 bubbled: 'onCompositionStart', 4673 captured: 'onCompositionStartCapture' 4674 }, 4675 dependencies: ['topBlur', 'topCompositionStart', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] 4676 }, 4677 compositionUpdate: { 4678 phasedRegistrationNames: { 4679 bubbled: 'onCompositionUpdate', 4680 captured: 'onCompositionUpdateCapture' 4681 }, 4682 dependencies: ['topBlur', 'topCompositionUpdate', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] 4683 } 4684 }; 4685 4686 // Track whether we've ever handled a keypress on the space key. 4687 var hasSpaceKeypress = false; 4688 4689 /** 4690 * Return whether a native keypress event is assumed to be a command. 4691 * This is required because Firefox fires `keypress` events for key commands 4692 * (cut, copy, select-all, etc.) even though no character is inserted. 4693 */ 4694 function isKeypressCommand(nativeEvent) { 4695 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && 4696 // ctrlKey && altKey is equivalent to AltGr, and is not a command. 4697 !(nativeEvent.ctrlKey && nativeEvent.altKey); 4698 } 4699 4700 /** 4701 * Translate native top level events into event types. 4702 * 4703 * @param {string} topLevelType 4704 * @return {object} 4705 */ 4706 function getCompositionEventType(topLevelType) { 4707 switch (topLevelType) { 4708 case 'topCompositionStart': 4709 return eventTypes.compositionStart; 4710 case 'topCompositionEnd': 4711 return eventTypes.compositionEnd; 4712 case 'topCompositionUpdate': 4713 return eventTypes.compositionUpdate; 4714 } 4715 } 4716 4717 /** 4718 * Does our fallback best-guess model think this event signifies that 4719 * composition has begun? 4720 * 4721 * @param {string} topLevelType 4722 * @param {object} nativeEvent 4723 * @return {boolean} 4724 */ 4725 function isFallbackCompositionStart(topLevelType, nativeEvent) { 4726 return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE; 4727 } 4728 4729 /** 4730 * Does our fallback mode think that this event is the end of composition? 4731 * 4732 * @param {string} topLevelType 4733 * @param {object} nativeEvent 4734 * @return {boolean} 4735 */ 4736 function isFallbackCompositionEnd(topLevelType, nativeEvent) { 4737 switch (topLevelType) { 4738 case 'topKeyUp': 4739 // Command keys insert or clear IME input. 4740 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 4741 case 'topKeyDown': 4742 // Expect IME keyCode on each keydown. If we get any other 4743 // code we must have exited earlier. 4744 return nativeEvent.keyCode !== START_KEYCODE; 4745 case 'topKeyPress': 4746 case 'topMouseDown': 4747 case 'topBlur': 4748 // Events are not possible without cancelling IME. 4749 return true; 4750 default: 4751 return false; 4752 } 4753 } 4754 4755 /** 4756 * Google Input Tools provides composition data via a CustomEvent, 4757 * with the `data` property populated in the `detail` object. If this 4758 * is available on the event object, use it. If not, this is a plain 4759 * composition event and we have nothing special to extract. 4760 * 4761 * @param {object} nativeEvent 4762 * @return {?string} 4763 */ 4764 function getDataFromCustomEvent(nativeEvent) { 4765 var detail = nativeEvent.detail; 4766 if (typeof detail === 'object' && 'data' in detail) { 4767 return detail.data; 4768 } 4769 return null; 4770 } 4771 4772 // Track the current IME composition status, if any. 4773 var isComposing = false; 4774 4775 /** 4776 * @return {?object} A SyntheticCompositionEvent. 4777 */ 4778 function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 4779 var eventType; 4780 var fallbackData; 4781 4782 if (canUseCompositionEvent) { 4783 eventType = getCompositionEventType(topLevelType); 4784 } else if (!isComposing) { 4785 if (isFallbackCompositionStart(topLevelType, nativeEvent)) { 4786 eventType = eventTypes.compositionStart; 4787 } 4788 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { 4789 eventType = eventTypes.compositionEnd; 4790 } 4791 4792 if (!eventType) { 4793 return null; 4794 } 4795 4796 if (useFallbackCompositionData) { 4797 // The current composition is stored statically and must not be 4798 // overwritten while composition continues. 4799 if (!isComposing && eventType === eventTypes.compositionStart) { 4800 isComposing = initialize(nativeEventTarget); 4801 } else if (eventType === eventTypes.compositionEnd) { 4802 if (isComposing) { 4803 fallbackData = getData(); 4804 } 4805 } 4806 } 4807 4808 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); 4809 4810 if (fallbackData) { 4811 // Inject data generated from fallback path into the synthetic event. 4812 // This matches the property of native CompositionEventInterface. 4813 event.data = fallbackData; 4814 } else { 4815 var customData = getDataFromCustomEvent(nativeEvent); 4816 if (customData !== null) { 4817 event.data = customData; 4818 } 4819 } 4820 4821 accumulateTwoPhaseDispatches(event); 4822 return event; 4823 } 4824 4825 /** 4826 * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`. 4827 * @param {object} nativeEvent Native browser event. 4828 * @return {?string} The string corresponding to this `beforeInput` event. 4829 */ 4830 function getNativeBeforeInputChars(topLevelType, nativeEvent) { 4831 switch (topLevelType) { 4832 case 'topCompositionEnd': 4833 return getDataFromCustomEvent(nativeEvent); 4834 case 'topKeyPress': 4835 /** 4836 * If native `textInput` events are available, our goal is to make 4837 * use of them. However, there is a special case: the spacebar key. 4838 * In Webkit, preventing default on a spacebar `textInput` event 4839 * cancels character insertion, but it *also* causes the browser 4840 * to fall back to its default spacebar behavior of scrolling the 4841 * page. 4842 * 4843 * Tracking at: 4844 * https://code.google.com/p/chromium/issues/detail?id=355103 4845 * 4846 * To avoid this issue, use the keypress event as if no `textInput` 4847 * event is available. 4848 */ 4849 var which = nativeEvent.which; 4850 if (which !== SPACEBAR_CODE) { 4851 return null; 4852 } 4853 4854 hasSpaceKeypress = true; 4855 return SPACEBAR_CHAR; 4856 4857 case 'topTextInput': 4858 // Record the characters to be added to the DOM. 4859 var chars = nativeEvent.data; 4860 4861 // If it's a spacebar character, assume that we have already handled 4862 // it at the keypress level and bail immediately. Android Chrome 4863 // doesn't give us keycodes, so we need to blacklist it. 4864 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 4865 return null; 4866 } 4867 4868 return chars; 4869 4870 default: 4871 // For other native event types, do nothing. 4872 return null; 4873 } 4874 } 4875 4876 /** 4877 * For browsers that do not provide the `textInput` event, extract the 4878 * appropriate string to use for SyntheticInputEvent. 4879 * 4880 * @param {string} topLevelType Record from `BrowserEventConstants`. 4881 * @param {object} nativeEvent Native browser event. 4882 * @return {?string} The fallback string for this `beforeInput` event. 4883 */ 4884 function getFallbackBeforeInputChars(topLevelType, nativeEvent) { 4885 // If we are currently composing (IME) and using a fallback to do so, 4886 // try to extract the composed characters from the fallback object. 4887 // If composition event is available, we extract a string only at 4888 // compositionevent, otherwise extract it at fallback events. 4889 if (isComposing) { 4890 if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { 4891 var chars = getData(); 4892 reset(); 4893 isComposing = false; 4894 return chars; 4895 } 4896 return null; 4897 } 4898 4899 switch (topLevelType) { 4900 case 'topPaste': 4901 // If a paste event occurs after a keypress, throw out the input 4902 // chars. Paste events should not lead to BeforeInput events. 4903 return null; 4904 case 'topKeyPress': 4905 /** 4906 * As of v27, Firefox may fire keypress events even when no character 4907 * will be inserted. A few possibilities: 4908 * 4909 * - `which` is `0`. Arrow keys, Esc key, etc. 4910 * 4911 * - `which` is the pressed key code, but no char is available. 4912 * Ex: 'AltGr + d` in Polish. There is no modified character for 4913 * this key combination and no character is inserted into the 4914 * document, but FF fires the keypress for char code `100` anyway. 4915 * No `input` event will occur. 4916 * 4917 * - `which` is the pressed key code, but a command combination is 4918 * being used. Ex: `Cmd+C`. No character is inserted, and no 4919 * `input` event will occur. 4920 */ 4921 if (!isKeypressCommand(nativeEvent)) { 4922 // IE fires the `keypress` event when a user types an emoji via 4923 // Touch keyboard of Windows. In such a case, the `char` property 4924 // holds an emoji character like `\uD83D\uDE0A`. Because its length 4925 // is 2, the property `which` does not represent an emoji correctly. 4926 // In such a case, we directly return the `char` property instead of 4927 // using `which`. 4928 if (nativeEvent.char && nativeEvent.char.length > 1) { 4929 return nativeEvent.char; 4930 } else if (nativeEvent.which) { 4931 return String.fromCharCode(nativeEvent.which); 4932 } 4933 } 4934 return null; 4935 case 'topCompositionEnd': 4936 return useFallbackCompositionData ? null : nativeEvent.data; 4937 default: 4938 return null; 4939 } 4940 } 4941 4942 /** 4943 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 4944 * `textInput` or fallback behavior. 4945 * 4946 * @return {?object} A SyntheticInputEvent. 4947 */ 4948 function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 4949 var chars; 4950 4951 if (canUseTextInputEvent) { 4952 chars = getNativeBeforeInputChars(topLevelType, nativeEvent); 4953 } else { 4954 chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); 4955 } 4956 4957 // If no characters are being inserted, no BeforeInput event should 4958 // be fired. 4959 if (!chars) { 4960 return null; 4961 } 4962 4963 var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); 4964 4965 event.data = chars; 4966 accumulateTwoPhaseDispatches(event); 4967 return event; 4968 } 4969 4970 /** 4971 * Create an `onBeforeInput` event to match 4972 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 4973 * 4974 * This event plugin is based on the native `textInput` event 4975 * available in Chrome, Safari, Opera, and IE. This event fires after 4976 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 4977 * 4978 * `beforeInput` is spec'd but not implemented in any browsers, and 4979 * the `input` event does not provide any useful information about what has 4980 * actually been added, contrary to the spec. Thus, `textInput` is the best 4981 * available event to identify the characters that have actually been inserted 4982 * into the target node. 4983 * 4984 * This plugin is also responsible for emitting `composition` events, thus 4985 * allowing us to share composition fallback code for both `beforeInput` and 4986 * `composition` event types. 4987 */ 4988 var BeforeInputEventPlugin = { 4989 eventTypes: eventTypes, 4990 4991 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 4992 return [extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget)]; 4993 } 4994 }; 4995 4996 // Use to restore controlled state after a change event has fired. 4997 4998 var fiberHostComponent = null; 4999 5000 var ReactControlledComponentInjection = { 5001 injectFiberControlledHostComponent: function (hostComponentImpl) { 5002 // The fiber implementation doesn't use dynamic dispatch so we need to 5003 // inject the implementation. 5004 fiberHostComponent = hostComponentImpl; 5005 } 5006 }; 5007 5008 var restoreTarget = null; 5009 var restoreQueue = null; 5010 5011 function restoreStateOfTarget(target) { 5012 // We perform this translation at the end of the event loop so that we 5013 // always receive the correct fiber here 5014 var internalInstance = getInstanceFromNode(target); 5015 if (!internalInstance) { 5016 // Unmounted 5017 return; 5018 } 5019 !(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function') ? invariant(false, 'Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue.') : void 0; 5020 var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); 5021 fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props); 5022 } 5023 5024 var injection$3 = ReactControlledComponentInjection; 5025 5026 function enqueueStateRestore(target) { 5027 if (restoreTarget) { 5028 if (restoreQueue) { 5029 restoreQueue.push(target); 5030 } else { 5031 restoreQueue = [target]; 5032 } 5033 } else { 5034 restoreTarget = target; 5035 } 5036 } 5037 5038 function restoreStateIfNeeded() { 5039 if (!restoreTarget) { 5040 return; 5041 } 5042 var target = restoreTarget; 5043 var queuedTargets = restoreQueue; 5044 restoreTarget = null; 5045 restoreQueue = null; 5046 5047 restoreStateOfTarget(target); 5048 if (queuedTargets) { 5049 for (var i = 0; i < queuedTargets.length; i++) { 5050 restoreStateOfTarget(queuedTargets[i]); 5051 } 5052 } 5053 } 5054 5055 var ReactControlledComponent = Object.freeze({ 5056 injection: injection$3, 5057 enqueueStateRestore: enqueueStateRestore, 5058 restoreStateIfNeeded: restoreStateIfNeeded 5059 }); 5060 5061 // Used as a way to call batchedUpdates when we don't have a reference to 5062 // the renderer. Such as when we're dispatching events or if third party 5063 // libraries need to call batchedUpdates. Eventually, this API will go away when 5064 // everything is batched by default. We'll then have a similar API to opt-out of 5065 // scheduled work and instead do synchronous work. 5066 5067 // Defaults 5068 var fiberBatchedUpdates = function (fn, bookkeeping) { 5069 return fn(bookkeeping); 5070 }; 5071 5072 var isNestingBatched = false; 5073 function batchedUpdates(fn, bookkeeping) { 5074 if (isNestingBatched) { 5075 // If we are currently inside another batch, we need to wait until it 5076 // fully completes before restoring state. Therefore, we add the target to 5077 // a queue of work. 5078 return fiberBatchedUpdates(fn, bookkeeping); 5079 } 5080 isNestingBatched = true; 5081 try { 5082 return fiberBatchedUpdates(fn, bookkeeping); 5083 } finally { 5084 // Here we wait until all updates have propagated, which is important 5085 // when using controlled components within layers: 5086 // https://github.com/facebook/react/issues/1698 5087 // Then we restore state of any controlled component. 5088 isNestingBatched = false; 5089 restoreStateIfNeeded(); 5090 } 5091 } 5092 5093 var ReactGenericBatchingInjection = { 5094 injectFiberBatchedUpdates: function (_batchedUpdates) { 5095 fiberBatchedUpdates = _batchedUpdates; 5096 } 5097 }; 5098 5099 var injection$4 = ReactGenericBatchingInjection; 5100 5101 /** 5102 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 5103 */ 5104 var supportedInputTypes = { 5105 color: true, 5106 date: true, 5107 datetime: true, 5108 'datetime-local': true, 5109 email: true, 5110 month: true, 5111 number: true, 5112 password: true, 5113 range: true, 5114 search: true, 5115 tel: true, 5116 text: true, 5117 time: true, 5118 url: true, 5119 week: true 5120 }; 5121 5122 function isTextInputElement(elem) { 5123 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 5124 5125 if (nodeName === 'input') { 5126 return !!supportedInputTypes[elem.type]; 5127 } 5128 5129 if (nodeName === 'textarea') { 5130 return true; 5131 } 5132 5133 return false; 5134 } 5135 5136 /** 5137 * HTML nodeType values that represent the type of the node 5138 */ 5139 5140 var ELEMENT_NODE = 1; 5141 var TEXT_NODE = 3; 5142 var COMMENT_NODE = 8; 5143 var DOCUMENT_NODE = 9; 5144 var DOCUMENT_FRAGMENT_NODE = 11; 5145 5146 /** 5147 * Gets the target node from a native browser event by accounting for 5148 * inconsistencies in browser DOM APIs. 5149 * 5150 * @param {object} nativeEvent Native browser event. 5151 * @return {DOMEventTarget} Target node. 5152 */ 5153 function getEventTarget(nativeEvent) { 5154 var target = nativeEvent.target || nativeEvent.srcElement || window; 5155 5156 // Normalize SVG <use> element events #4963 5157 if (target.correspondingUseElement) { 5158 target = target.correspondingUseElement; 5159 } 5160 5161 // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 5162 // @see http://www.quirksmode.org/js/events_properties.html 5163 return target.nodeType === TEXT_NODE ? target.parentNode : target; 5164 } 5165 5166 var useHasFeature; 5167 if (ExecutionEnvironment.canUseDOM) { 5168 useHasFeature = document.implementation && document.implementation.hasFeature && 5169 // always returns true in newer browsers as per the standard. 5170 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature 5171 document.implementation.hasFeature('', '') !== true; 5172 } 5173 5174 /** 5175 * Checks if an event is supported in the current execution environment. 5176 * 5177 * NOTE: This will not work correctly for non-generic events such as `change`, 5178 * `reset`, `load`, `error`, and `select`. 5179 * 5180 * Borrows from Modernizr. 5181 * 5182 * @param {string} eventNameSuffix Event name, e.g. "click". 5183 * @param {?boolean} capture Check if the capture phase is supported. 5184 * @return {boolean} True if the event is supported. 5185 * @internal 5186 * @license Modernizr 3.0.0pre (Custom Build) | MIT 5187 */ 5188 function isEventSupported(eventNameSuffix, capture) { 5189 if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) { 5190 return false; 5191 } 5192 5193 var eventName = 'on' + eventNameSuffix; 5194 var isSupported = eventName in document; 5195 5196 if (!isSupported) { 5197 var element = document.createElement('div'); 5198 element.setAttribute(eventName, 'return;'); 5199 isSupported = typeof element[eventName] === 'function'; 5200 } 5201 5202 if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { 5203 // This is the only way to test support for the `wheel` event in IE9+. 5204 isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); 5205 } 5206 5207 return isSupported; 5208 } 5209 5210 function isCheckable(elem) { 5211 var type = elem.type; 5212 var nodeName = elem.nodeName; 5213 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 5214 } 5215 5216 function getTracker(node) { 5217 return node._valueTracker; 5218 } 5219 5220 function detachTracker(node) { 5221 node._valueTracker = null; 5222 } 5223 5224 function getValueFromNode(node) { 5225 var value = ''; 5226 if (!node) { 5227 return value; 5228 } 5229 5230 if (isCheckable(node)) { 5231 value = node.checked ? 'true' : 'false'; 5232 } else { 5233 value = node.value; 5234 } 5235 5236 return value; 5237 } 5238 5239 function trackValueOnNode(node) { 5240 var valueField = isCheckable(node) ? 'checked' : 'value'; 5241 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 5242 5243 var currentValue = '' + node[valueField]; 5244 5245 // if someone has already defined a value or Safari, then bail 5246 // and don't track value will cause over reporting of changes, 5247 // but it's better then a hard failure 5248 // (needed for certain tests that spyOn input values and Safari) 5249 if (node.hasOwnProperty(valueField) || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 5250 return; 5251 } 5252 5253 Object.defineProperty(node, valueField, { 5254 enumerable: descriptor.enumerable, 5255 configurable: true, 5256 get: function () { 5257 return descriptor.get.call(this); 5258 }, 5259 set: function (value) { 5260 currentValue = '' + value; 5261 descriptor.set.call(this, value); 5262 } 5263 }); 5264 5265 var tracker = { 5266 getValue: function () { 5267 return currentValue; 5268 }, 5269 setValue: function (value) { 5270 currentValue = '' + value; 5271 }, 5272 stopTracking: function () { 5273 detachTracker(node); 5274 delete node[valueField]; 5275 } 5276 }; 5277 return tracker; 5278 } 5279 5280 function track(node) { 5281 if (getTracker(node)) { 5282 return; 5283 } 5284 5285 // TODO: Once it's just Fiber we can move this to node._wrapperState 5286 node._valueTracker = trackValueOnNode(node); 5287 } 5288 5289 function updateValueIfChanged(node) { 5290 if (!node) { 5291 return false; 5292 } 5293 5294 var tracker = getTracker(node); 5295 // if there is no tracker at this point it's unlikely 5296 // that trying again will succeed 5297 if (!tracker) { 5298 return true; 5299 } 5300 5301 var lastValue = tracker.getValue(); 5302 var nextValue = getValueFromNode(node); 5303 if (nextValue !== lastValue) { 5304 tracker.setValue(nextValue); 5305 return true; 5306 } 5307 return false; 5308 } 5309 5310 var eventTypes$1 = { 5311 change: { 5312 phasedRegistrationNames: { 5313 bubbled: 'onChange', 5314 captured: 'onChangeCapture' 5315 }, 5316 dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange'] 5317 } 5318 }; 5319 5320 function createAndAccumulateChangeEvent(inst, nativeEvent, target) { 5321 var event = SyntheticEvent$1.getPooled(eventTypes$1.change, inst, nativeEvent, target); 5322 event.type = 'change'; 5323 // Flag this event loop as needing state restore. 5324 enqueueStateRestore(target); 5325 accumulateTwoPhaseDispatches(event); 5326 return event; 5327 } 5328 /** 5329 * For IE shims 5330 */ 5331 var activeElement = null; 5332 var activeElementInst = null; 5333 5334 /** 5335 * SECTION: handle `change` event 5336 */ 5337 function shouldUseChangeEvent(elem) { 5338 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 5339 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 5340 } 5341 5342 function manualDispatchChangeEvent(nativeEvent) { 5343 var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); 5344 5345 // If change and propertychange bubbled, we'd just bind to it like all the 5346 // other events and have it go through ReactBrowserEventEmitter. Since it 5347 // doesn't, we manually listen for the events and so we have to enqueue and 5348 // process the abstract event manually. 5349 // 5350 // Batching is necessary here in order to ensure that all event handlers run 5351 // before the next rerender (including event handlers attached to ancestor 5352 // elements instead of directly on the input). Without this, controlled 5353 // components don't work properly in conjunction with event bubbling because 5354 // the component is rerendered and the value reverted before all the event 5355 // handlers can run. See https://github.com/facebook/react/issues/708. 5356 batchedUpdates(runEventInBatch, event); 5357 } 5358 5359 function runEventInBatch(event) { 5360 enqueueEvents(event); 5361 processEventQueue(false); 5362 } 5363 5364 function getInstIfValueChanged(targetInst) { 5365 var targetNode = getNodeFromInstance$1(targetInst); 5366 if (updateValueIfChanged(targetNode)) { 5367 return targetInst; 5368 } 5369 } 5370 5371 function getTargetInstForChangeEvent(topLevelType, targetInst) { 5372 if (topLevelType === 'topChange') { 5373 return targetInst; 5374 } 5375 } 5376 5377 /** 5378 * SECTION: handle `input` event 5379 */ 5380 var isInputEventSupported = false; 5381 if (ExecutionEnvironment.canUseDOM) { 5382 // IE9 claims to support the input event but fails to trigger it when 5383 // deleting text, so we ignore its input events. 5384 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 5385 } 5386 5387 /** 5388 * (For IE <=9) Starts tracking propertychange events on the passed-in element 5389 * and override the value property so that we can distinguish user events from 5390 * value changes in JS. 5391 */ 5392 function startWatchingForValueChange(target, targetInst) { 5393 activeElement = target; 5394 activeElementInst = targetInst; 5395 activeElement.attachEvent('onpropertychange', handlePropertyChange); 5396 } 5397 5398 /** 5399 * (For IE <=9) Removes the event listeners from the currently-tracked element, 5400 * if any exists. 5401 */ 5402 function stopWatchingForValueChange() { 5403 if (!activeElement) { 5404 return; 5405 } 5406 activeElement.detachEvent('onpropertychange', handlePropertyChange); 5407 activeElement = null; 5408 activeElementInst = null; 5409 } 5410 5411 /** 5412 * (For IE <=9) Handles a propertychange event, sending a `change` event if 5413 * the value of the active element has changed. 5414 */ 5415 function handlePropertyChange(nativeEvent) { 5416 if (nativeEvent.propertyName !== 'value') { 5417 return; 5418 } 5419 if (getInstIfValueChanged(activeElementInst)) { 5420 manualDispatchChangeEvent(nativeEvent); 5421 } 5422 } 5423 5424 function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { 5425 if (topLevelType === 'topFocus') { 5426 // In IE9, propertychange fires for most input events but is buggy and 5427 // doesn't fire when text is deleted, but conveniently, selectionchange 5428 // appears to fire in all of the remaining cases so we catch those and 5429 // forward the event if the value has changed 5430 // In either case, we don't want to call the event handler if the value 5431 // is changed from JS so we redefine a setter for `.value` that updates 5432 // our activeElementValue variable, allowing us to ignore those changes 5433 // 5434 // stopWatching() should be a noop here but we call it just in case we 5435 // missed a blur event somehow. 5436 stopWatchingForValueChange(); 5437 startWatchingForValueChange(target, targetInst); 5438 } else if (topLevelType === 'topBlur') { 5439 stopWatchingForValueChange(); 5440 } 5441 } 5442 5443 // For IE8 and IE9. 5444 function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { 5445 if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') { 5446 // On the selectionchange event, the target is just document which isn't 5447 // helpful for us so just check activeElement instead. 5448 // 5449 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 5450 // propertychange on the first input event after setting `value` from a 5451 // script and fires only keydown, keypress, keyup. Catching keyup usually 5452 // gets it and catching keydown lets us fire an event for the first 5453 // keystroke if user does a key repeat (it'll be a little delayed: right 5454 // before the second keystroke). Other input methods (e.g., paste) seem to 5455 // fire selectionchange normally. 5456 return getInstIfValueChanged(activeElementInst); 5457 } 5458 } 5459 5460 /** 5461 * SECTION: handle `click` event 5462 */ 5463 function shouldUseClickEvent(elem) { 5464 // Use the `click` event to detect changes to checkbox and radio inputs. 5465 // This approach works across all browsers, whereas `change` does not fire 5466 // until `blur` in IE8. 5467 var nodeName = elem.nodeName; 5468 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 5469 } 5470 5471 function getTargetInstForClickEvent(topLevelType, targetInst) { 5472 if (topLevelType === 'topClick') { 5473 return getInstIfValueChanged(targetInst); 5474 } 5475 } 5476 5477 function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { 5478 if (topLevelType === 'topInput' || topLevelType === 'topChange') { 5479 return getInstIfValueChanged(targetInst); 5480 } 5481 } 5482 5483 function handleControlledInputBlur(inst, node) { 5484 // TODO: In IE, inst is occasionally null. Why? 5485 if (inst == null) { 5486 return; 5487 } 5488 5489 // Fiber and ReactDOM keep wrapper state in separate places 5490 var state = inst._wrapperState || node._wrapperState; 5491 5492 if (!state || !state.controlled || node.type !== 'number') { 5493 return; 5494 } 5495 5496 // If controlled, assign the value attribute to the current value on blur 5497 var value = '' + node.value; 5498 if (node.getAttribute('value') !== value) { 5499 node.setAttribute('value', value); 5500 } 5501 } 5502 5503 /** 5504 * This plugin creates an `onChange` event that normalizes change events 5505 * across form elements. This event fires at a time when it's possible to 5506 * change the element's value without seeing a flicker. 5507 * 5508 * Supported elements are: 5509 * - input (see `isTextInputElement`) 5510 * - textarea 5511 * - select 5512 */ 5513 var ChangeEventPlugin = { 5514 eventTypes: eventTypes$1, 5515 5516 _isInputEventSupported: isInputEventSupported, 5517 5518 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 5519 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 5520 5521 var getTargetInstFunc, handleEventFunc; 5522 if (shouldUseChangeEvent(targetNode)) { 5523 getTargetInstFunc = getTargetInstForChangeEvent; 5524 } else if (isTextInputElement(targetNode)) { 5525 if (isInputEventSupported) { 5526 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 5527 } else { 5528 getTargetInstFunc = getTargetInstForInputEventPolyfill; 5529 handleEventFunc = handleEventsForInputEventPolyfill; 5530 } 5531 } else if (shouldUseClickEvent(targetNode)) { 5532 getTargetInstFunc = getTargetInstForClickEvent; 5533 } 5534 5535 if (getTargetInstFunc) { 5536 var inst = getTargetInstFunc(topLevelType, targetInst); 5537 if (inst) { 5538 var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); 5539 return event; 5540 } 5541 } 5542 5543 if (handleEventFunc) { 5544 handleEventFunc(topLevelType, targetNode, targetInst); 5545 } 5546 5547 // When blurring, set the value attribute for number inputs 5548 if (topLevelType === 'topBlur') { 5549 handleControlledInputBlur(targetInst, targetNode); 5550 } 5551 } 5552 }; 5553 5554 /** 5555 * Module that is injectable into `EventPluginHub`, that specifies a 5556 * deterministic ordering of `EventPlugin`s. A convenient way to reason about 5557 * plugins, without having to package every one of them. This is better than 5558 * having plugins be ordered in the same order that they are injected because 5559 * that ordering would be influenced by the packaging order. 5560 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that 5561 * preventing default on events is convenient in `SimpleEventPlugin` handlers. 5562 */ 5563 var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; 5564 5565 /** 5566 * @interface UIEvent 5567 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 5568 */ 5569 var UIEventInterface = { 5570 view: null, 5571 detail: null 5572 }; 5573 5574 /** 5575 * @param {object} dispatchConfig Configuration used to dispatch this event. 5576 * @param {string} dispatchMarker Marker identifying the event target. 5577 * @param {object} nativeEvent Native browser event. 5578 * @extends {SyntheticEvent} 5579 */ 5580 function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 5581 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 5582 } 5583 5584 SyntheticEvent$1.augmentClass(SyntheticUIEvent, UIEventInterface); 5585 5586 /** 5587 * Translation from modifier key to the associated property in the event. 5588 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 5589 */ 5590 5591 var modifierKeyToProp = { 5592 Alt: 'altKey', 5593 Control: 'ctrlKey', 5594 Meta: 'metaKey', 5595 Shift: 'shiftKey' 5596 }; 5597 5598 // IE8 does not implement getModifierState so we simply map it to the only 5599 // modifier keys exposed by the event itself, does not support Lock-keys. 5600 // Currently, all major browsers except Chrome seems to support Lock-keys. 5601 function modifierStateGetter(keyArg) { 5602 var syntheticEvent = this; 5603 var nativeEvent = syntheticEvent.nativeEvent; 5604 if (nativeEvent.getModifierState) { 5605 return nativeEvent.getModifierState(keyArg); 5606 } 5607 var keyProp = modifierKeyToProp[keyArg]; 5608 return keyProp ? !!nativeEvent[keyProp] : false; 5609 } 5610 5611 function getEventModifierState(nativeEvent) { 5612 return modifierStateGetter; 5613 } 5614 5615 /** 5616 * @interface MouseEvent 5617 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 5618 */ 5619 var MouseEventInterface = { 5620 screenX: null, 5621 screenY: null, 5622 clientX: null, 5623 clientY: null, 5624 pageX: null, 5625 pageY: null, 5626 ctrlKey: null, 5627 shiftKey: null, 5628 altKey: null, 5629 metaKey: null, 5630 getModifierState: getEventModifierState, 5631 button: null, 5632 buttons: null, 5633 relatedTarget: function (event) { 5634 return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); 5635 } 5636 }; 5637 5638 /** 5639 * @param {object} dispatchConfig Configuration used to dispatch this event. 5640 * @param {string} dispatchMarker Marker identifying the event target. 5641 * @param {object} nativeEvent Native browser event. 5642 * @extends {SyntheticUIEvent} 5643 */ 5644 function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 5645 return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 5646 } 5647 5648 SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface); 5649 5650 var eventTypes$2 = { 5651 mouseEnter: { 5652 registrationName: 'onMouseEnter', 5653 dependencies: ['topMouseOut', 'topMouseOver'] 5654 }, 5655 mouseLeave: { 5656 registrationName: 'onMouseLeave', 5657 dependencies: ['topMouseOut', 'topMouseOver'] 5658 } 5659 }; 5660 5661 var EnterLeaveEventPlugin = { 5662 eventTypes: eventTypes$2, 5663 5664 /** 5665 * For almost every interaction we care about, there will be both a top-level 5666 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 5667 * we do not extract duplicate events. However, moving the mouse into the 5668 * browser from outside will not fire a `mouseout` event. In this case, we use 5669 * the `mouseover` top-level event. 5670 */ 5671 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 5672 if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { 5673 return null; 5674 } 5675 if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') { 5676 // Must not be a mouse in or mouse out - ignoring. 5677 return null; 5678 } 5679 5680 var win; 5681 if (nativeEventTarget.window === nativeEventTarget) { 5682 // `nativeEventTarget` is probably a window object. 5683 win = nativeEventTarget; 5684 } else { 5685 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 5686 var doc = nativeEventTarget.ownerDocument; 5687 if (doc) { 5688 win = doc.defaultView || doc.parentWindow; 5689 } else { 5690 win = window; 5691 } 5692 } 5693 5694 var from; 5695 var to; 5696 if (topLevelType === 'topMouseOut') { 5697 from = targetInst; 5698 var related = nativeEvent.relatedTarget || nativeEvent.toElement; 5699 to = related ? getClosestInstanceFromNode(related) : null; 5700 } else { 5701 // Moving to a node from outside the window. 5702 from = null; 5703 to = targetInst; 5704 } 5705 5706 if (from === to) { 5707 // Nothing pertains to our managed components. 5708 return null; 5709 } 5710 5711 var fromNode = from == null ? win : getNodeFromInstance$1(from); 5712 var toNode = to == null ? win : getNodeFromInstance$1(to); 5713 5714 var leave = SyntheticMouseEvent.getPooled(eventTypes$2.mouseLeave, from, nativeEvent, nativeEventTarget); 5715 leave.type = 'mouseleave'; 5716 leave.target = fromNode; 5717 leave.relatedTarget = toNode; 5718 5719 var enter = SyntheticMouseEvent.getPooled(eventTypes$2.mouseEnter, to, nativeEvent, nativeEventTarget); 5720 enter.type = 'mouseenter'; 5721 enter.target = toNode; 5722 enter.relatedTarget = fromNode; 5723 5724 accumulateEnterLeaveDispatches(leave, enter, from, to); 5725 5726 return [leave, enter]; 5727 } 5728 }; 5729 5730 /** 5731 * `ReactInstanceMap` maintains a mapping from a public facing stateful 5732 * instance (key) and the internal representation (value). This allows public 5733 * methods to accept the user facing instance as an argument and map them back 5734 * to internal methods. 5735 * 5736 * Note that this module is currently shared and assumed to be stateless. 5737 * If this becomes an actual Map, that will break. 5738 */ 5739 5740 /** 5741 * This API should be called `delete` but we'd have to make sure to always 5742 * transform these to strings for IE support. When this transform is fully 5743 * supported we can rename it. 5744 */ 5745 5746 5747 function get(key) { 5748 return key._reactInternalFiber; 5749 } 5750 5751 function has(key) { 5752 return key._reactInternalFiber !== undefined; 5753 } 5754 5755 function set(key, value) { 5756 key._reactInternalFiber = value; 5757 } 5758 5759 var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 5760 5761 var ReactCurrentOwner = ReactInternals.ReactCurrentOwner; 5762 var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame; 5763 5764 function getComponentName(fiber) { 5765 var type = fiber.type; 5766 5767 if (typeof type === 'string') { 5768 return type; 5769 } 5770 if (typeof type === 'function') { 5771 return type.displayName || type.name; 5772 } 5773 return null; 5774 } 5775 5776 // Don't change these two values: 5777 var NoEffect = 0; // 0b00000000 5778 var PerformedWork = 1; // 0b00000001 5779 5780 // You can change the rest (and add more). 5781 var Placement = 2; // 0b00000010 5782 var Update = 4; // 0b00000100 5783 var PlacementAndUpdate = 6; // 0b00000110 5784 var Deletion = 8; // 0b00001000 5785 var ContentReset = 16; // 0b00010000 5786 var Callback = 32; // 0b00100000 5787 var Err = 64; // 0b01000000 5788 var Ref = 128; // 0b10000000 5789 5790 var MOUNTING = 1; 5791 var MOUNTED = 2; 5792 var UNMOUNTED = 3; 5793 5794 function isFiberMountedImpl(fiber) { 5795 var node = fiber; 5796 if (!fiber.alternate) { 5797 // If there is no alternate, this might be a new tree that isn't inserted 5798 // yet. If it is, then it will have a pending insertion effect on it. 5799 if ((node.effectTag & Placement) !== NoEffect) { 5800 return MOUNTING; 5801 } 5802 while (node['return']) { 5803 node = node['return']; 5804 if ((node.effectTag & Placement) !== NoEffect) { 5805 return MOUNTING; 5806 } 5807 } 5808 } else { 5809 while (node['return']) { 5810 node = node['return']; 5811 } 5812 } 5813 if (node.tag === HostRoot) { 5814 // TODO: Check if this was a nested HostRoot when used with 5815 // renderContainerIntoSubtree. 5816 return MOUNTED; 5817 } 5818 // If we didn't hit the root, that means that we're in an disconnected tree 5819 // that has been unmounted. 5820 return UNMOUNTED; 5821 } 5822 5823 function isFiberMounted(fiber) { 5824 return isFiberMountedImpl(fiber) === MOUNTED; 5825 } 5826 5827 function isMounted(component) { 5828 { 5829 var owner = ReactCurrentOwner.current; 5830 if (owner !== null && owner.tag === ClassComponent) { 5831 var ownerFiber = owner; 5832 var instance = ownerFiber.stateNode; 5833 warning(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component'); 5834 instance._warnedAboutRefsInRender = true; 5835 } 5836 } 5837 5838 var fiber = get(component); 5839 if (!fiber) { 5840 return false; 5841 } 5842 return isFiberMountedImpl(fiber) === MOUNTED; 5843 } 5844 5845 function assertIsMounted(fiber) { 5846 !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 5847 } 5848 5849 function findCurrentFiberUsingSlowPath(fiber) { 5850 var alternate = fiber.alternate; 5851 if (!alternate) { 5852 // If there is no alternate, then we only need to check if it is mounted. 5853 var state = isFiberMountedImpl(fiber); 5854 !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 5855 if (state === MOUNTING) { 5856 return null; 5857 } 5858 return fiber; 5859 } 5860 // If we have two possible branches, we'll walk backwards up to the root 5861 // to see what path the root points to. On the way we may hit one of the 5862 // special cases and we'll deal with them. 5863 var a = fiber; 5864 var b = alternate; 5865 while (true) { 5866 var parentA = a['return']; 5867 var parentB = parentA ? parentA.alternate : null; 5868 if (!parentA || !parentB) { 5869 // We're at the root. 5870 break; 5871 } 5872 5873 // If both copies of the parent fiber point to the same child, we can 5874 // assume that the child is current. This happens when we bailout on low 5875 // priority: the bailed out fiber's child reuses the current child. 5876 if (parentA.child === parentB.child) { 5877 var child = parentA.child; 5878 while (child) { 5879 if (child === a) { 5880 // We've determined that A is the current branch. 5881 assertIsMounted(parentA); 5882 return fiber; 5883 } 5884 if (child === b) { 5885 // We've determined that B is the current branch. 5886 assertIsMounted(parentA); 5887 return alternate; 5888 } 5889 child = child.sibling; 5890 } 5891 // We should never have an alternate for any mounting node. So the only 5892 // way this could possibly happen is if this was unmounted, if at all. 5893 invariant(false, 'Unable to find node on an unmounted component.'); 5894 } 5895 5896 if (a['return'] !== b['return']) { 5897 // The return pointer of A and the return pointer of B point to different 5898 // fibers. We assume that return pointers never criss-cross, so A must 5899 // belong to the child set of A.return, and B must belong to the child 5900 // set of B.return. 5901 a = parentA; 5902 b = parentB; 5903 } else { 5904 // The return pointers point to the same fiber. We'll have to use the 5905 // default, slow path: scan the child sets of each parent alternate to see 5906 // which child belongs to which set. 5907 // 5908 // Search parent A's child set 5909 var didFindChild = false; 5910 var _child = parentA.child; 5911 while (_child) { 5912 if (_child === a) { 5913 didFindChild = true; 5914 a = parentA; 5915 b = parentB; 5916 break; 5917 } 5918 if (_child === b) { 5919 didFindChild = true; 5920 b = parentA; 5921 a = parentB; 5922 break; 5923 } 5924 _child = _child.sibling; 5925 } 5926 if (!didFindChild) { 5927 // Search parent B's child set 5928 _child = parentB.child; 5929 while (_child) { 5930 if (_child === a) { 5931 didFindChild = true; 5932 a = parentB; 5933 b = parentA; 5934 break; 5935 } 5936 if (_child === b) { 5937 didFindChild = true; 5938 b = parentB; 5939 a = parentA; 5940 break; 5941 } 5942 _child = _child.sibling; 5943 } 5944 !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0; 5945 } 5946 } 5947 5948 !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0; 5949 } 5950 // If the root is not a host container, we're in a disconnected tree. I.e. 5951 // unmounted. 5952 !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 5953 if (a.stateNode.current === a) { 5954 // We've determined that A is the current branch. 5955 return fiber; 5956 } 5957 // Otherwise B has to be current branch. 5958 return alternate; 5959 } 5960 5961 function findCurrentHostFiber(parent) { 5962 var currentParent = findCurrentFiberUsingSlowPath(parent); 5963 if (!currentParent) { 5964 return null; 5965 } 5966 5967 // Next we'll drill down this component to find the first HostComponent/Text. 5968 var node = currentParent; 5969 while (true) { 5970 if (node.tag === HostComponent || node.tag === HostText) { 5971 return node; 5972 } else if (node.child) { 5973 node.child['return'] = node; 5974 node = node.child; 5975 continue; 5976 } 5977 if (node === currentParent) { 5978 return null; 5979 } 5980 while (!node.sibling) { 5981 if (!node['return'] || node['return'] === currentParent) { 5982 return null; 5983 } 5984 node = node['return']; 5985 } 5986 node.sibling['return'] = node['return']; 5987 node = node.sibling; 5988 } 5989 // Flow needs the return null here, but ESLint complains about it. 5990 // eslint-disable-next-line no-unreachable 5991 return null; 5992 } 5993 5994 function findCurrentHostFiberWithNoPortals(parent) { 5995 var currentParent = findCurrentFiberUsingSlowPath(parent); 5996 if (!currentParent) { 5997 return null; 5998 } 5999 6000 // Next we'll drill down this component to find the first HostComponent/Text. 6001 var node = currentParent; 6002 while (true) { 6003 if (node.tag === HostComponent || node.tag === HostText) { 6004 return node; 6005 } else if (node.child && node.tag !== HostPortal) { 6006 node.child['return'] = node; 6007 node = node.child; 6008 continue; 6009 } 6010 if (node === currentParent) { 6011 return null; 6012 } 6013 while (!node.sibling) { 6014 if (!node['return'] || node['return'] === currentParent) { 6015 return null; 6016 } 6017 node = node['return']; 6018 } 6019 node.sibling['return'] = node['return']; 6020 node = node.sibling; 6021 } 6022 // Flow needs the return null here, but ESLint complains about it. 6023 // eslint-disable-next-line no-unreachable 6024 return null; 6025 } 6026 6027 var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; 6028 var callbackBookkeepingPool = []; 6029 6030 /** 6031 * Find the deepest React component completely containing the root of the 6032 * passed-in instance (for use when entire React trees are nested within each 6033 * other). If React trees are not nested, returns null. 6034 */ 6035 function findRootContainerNode(inst) { 6036 // TODO: It may be a good idea to cache this to prevent unnecessary DOM 6037 // traversal, but caching is difficult to do correctly without using a 6038 // mutation observer to listen for all DOM changes. 6039 while (inst['return']) { 6040 inst = inst['return']; 6041 } 6042 if (inst.tag !== HostRoot) { 6043 // This can happen if we're in a detached tree. 6044 return null; 6045 } 6046 return inst.stateNode.containerInfo; 6047 } 6048 6049 // Used to store ancestor hierarchy in top level callback 6050 function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { 6051 if (callbackBookkeepingPool.length) { 6052 var instance = callbackBookkeepingPool.pop(); 6053 instance.topLevelType = topLevelType; 6054 instance.nativeEvent = nativeEvent; 6055 instance.targetInst = targetInst; 6056 return instance; 6057 } 6058 return { 6059 topLevelType: topLevelType, 6060 nativeEvent: nativeEvent, 6061 targetInst: targetInst, 6062 ancestors: [] 6063 }; 6064 } 6065 6066 function releaseTopLevelCallbackBookKeeping(instance) { 6067 instance.topLevelType = null; 6068 instance.nativeEvent = null; 6069 instance.targetInst = null; 6070 instance.ancestors.length = 0; 6071 if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { 6072 callbackBookkeepingPool.push(instance); 6073 } 6074 } 6075 6076 function handleTopLevelImpl(bookKeeping) { 6077 var targetInst = bookKeeping.targetInst; 6078 6079 // Loop through the hierarchy, in case there's any nested components. 6080 // It's important that we build the array of ancestors before calling any 6081 // event handlers, because event handlers can modify the DOM, leading to 6082 // inconsistencies with ReactMount's node cache. See #1105. 6083 var ancestor = targetInst; 6084 do { 6085 if (!ancestor) { 6086 bookKeeping.ancestors.push(ancestor); 6087 break; 6088 } 6089 var root = findRootContainerNode(ancestor); 6090 if (!root) { 6091 break; 6092 } 6093 bookKeeping.ancestors.push(ancestor); 6094 ancestor = getClosestInstanceFromNode(root); 6095 } while (ancestor); 6096 6097 for (var i = 0; i < bookKeeping.ancestors.length; i++) { 6098 targetInst = bookKeeping.ancestors[i]; 6099 _handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent)); 6100 } 6101 } 6102 6103 // TODO: can we stop exporting these? 6104 var _enabled = true; 6105 var _handleTopLevel = void 0; 6106 6107 function setHandleTopLevel(handleTopLevel) { 6108 _handleTopLevel = handleTopLevel; 6109 } 6110 6111 function setEnabled(enabled) { 6112 _enabled = !!enabled; 6113 } 6114 6115 function isEnabled() { 6116 return _enabled; 6117 } 6118 6119 /** 6120 * Traps top-level events by using event bubbling. 6121 * 6122 * @param {string} topLevelType Record from `BrowserEventConstants`. 6123 * @param {string} handlerBaseName Event name (e.g. "click"). 6124 * @param {object} element Element on which to attach listener. 6125 * @return {?object} An object with a remove function which will forcefully 6126 * remove the listener. 6127 * @internal 6128 */ 6129 function trapBubbledEvent(topLevelType, handlerBaseName, element) { 6130 if (!element) { 6131 return null; 6132 } 6133 return EventListener.listen(element, handlerBaseName, dispatchEvent.bind(null, topLevelType)); 6134 } 6135 6136 /** 6137 * Traps a top-level event by using event capturing. 6138 * 6139 * @param {string} topLevelType Record from `BrowserEventConstants`. 6140 * @param {string} handlerBaseName Event name (e.g. "click"). 6141 * @param {object} element Element on which to attach listener. 6142 * @return {?object} An object with a remove function which will forcefully 6143 * remove the listener. 6144 * @internal 6145 */ 6146 function trapCapturedEvent(topLevelType, handlerBaseName, element) { 6147 if (!element) { 6148 return null; 6149 } 6150 return EventListener.capture(element, handlerBaseName, dispatchEvent.bind(null, topLevelType)); 6151 } 6152 6153 function dispatchEvent(topLevelType, nativeEvent) { 6154 if (!_enabled) { 6155 return; 6156 } 6157 6158 var nativeEventTarget = getEventTarget(nativeEvent); 6159 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 6160 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) { 6161 // If we get an event (ex: img onload) before committing that 6162 // component's mount, ignore it for now (that is, treat it as if it was an 6163 // event on a non-React tree). We might also consider queueing events and 6164 // dispatching them after the mount. 6165 targetInst = null; 6166 } 6167 6168 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst); 6169 6170 try { 6171 // Event queue being processed in the same cycle allows 6172 // `preventDefault`. 6173 batchedUpdates(handleTopLevelImpl, bookKeeping); 6174 } finally { 6175 releaseTopLevelCallbackBookKeeping(bookKeeping); 6176 } 6177 } 6178 6179 var ReactDOMEventListener = Object.freeze({ 6180 get _enabled () { return _enabled; }, 6181 get _handleTopLevel () { return _handleTopLevel; }, 6182 setHandleTopLevel: setHandleTopLevel, 6183 setEnabled: setEnabled, 6184 isEnabled: isEnabled, 6185 trapBubbledEvent: trapBubbledEvent, 6186 trapCapturedEvent: trapCapturedEvent, 6187 dispatchEvent: dispatchEvent 6188 }); 6189 6190 /** 6191 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 6192 * 6193 * @param {string} styleProp 6194 * @param {string} eventName 6195 * @returns {object} 6196 */ 6197 function makePrefixMap(styleProp, eventName) { 6198 var prefixes = {}; 6199 6200 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 6201 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 6202 prefixes['Moz' + styleProp] = 'moz' + eventName; 6203 prefixes['ms' + styleProp] = 'MS' + eventName; 6204 prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); 6205 6206 return prefixes; 6207 } 6208 6209 /** 6210 * A list of event names to a configurable list of vendor prefixes. 6211 */ 6212 var vendorPrefixes = { 6213 animationend: makePrefixMap('Animation', 'AnimationEnd'), 6214 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 6215 animationstart: makePrefixMap('Animation', 'AnimationStart'), 6216 transitionend: makePrefixMap('Transition', 'TransitionEnd') 6217 }; 6218 6219 /** 6220 * Event names that have already been detected and prefixed (if applicable). 6221 */ 6222 var prefixedEventNames = {}; 6223 6224 /** 6225 * Element to check for prefixes on. 6226 */ 6227 var style = {}; 6228 6229 /** 6230 * Bootstrap if a DOM exists. 6231 */ 6232 if (ExecutionEnvironment.canUseDOM) { 6233 style = document.createElement('div').style; 6234 6235 // On some platforms, in particular some releases of Android 4.x, 6236 // the un-prefixed "animation" and "transition" properties are defined on the 6237 // style object but the events that fire will still be prefixed, so we need 6238 // to check if the un-prefixed events are usable, and if not remove them from the map. 6239 if (!('AnimationEvent' in window)) { 6240 delete vendorPrefixes.animationend.animation; 6241 delete vendorPrefixes.animationiteration.animation; 6242 delete vendorPrefixes.animationstart.animation; 6243 } 6244 6245 // Same as above 6246 if (!('TransitionEvent' in window)) { 6247 delete vendorPrefixes.transitionend.transition; 6248 } 6249 } 6250 6251 /** 6252 * Attempts to determine the correct vendor prefixed event name. 6253 * 6254 * @param {string} eventName 6255 * @returns {string} 6256 */ 6257 function getVendorPrefixedEventName(eventName) { 6258 if (prefixedEventNames[eventName]) { 6259 return prefixedEventNames[eventName]; 6260 } else if (!vendorPrefixes[eventName]) { 6261 return eventName; 6262 } 6263 6264 var prefixMap = vendorPrefixes[eventName]; 6265 6266 for (var styleProp in prefixMap) { 6267 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 6268 return prefixedEventNames[eventName] = prefixMap[styleProp]; 6269 } 6270 } 6271 6272 return ''; 6273 } 6274 6275 /** 6276 * Types of raw signals from the browser caught at the top level. 6277 * 6278 * For events like 'submit' which don't consistently bubble (which we 6279 * trap at a lower node than `document`), binding at `document` would 6280 * cause duplicate events so we don't include them here. 6281 */ 6282 var topLevelTypes$1 = { 6283 topAbort: 'abort', 6284 topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend', 6285 topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration', 6286 topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart', 6287 topBlur: 'blur', 6288 topCancel: 'cancel', 6289 topCanPlay: 'canplay', 6290 topCanPlayThrough: 'canplaythrough', 6291 topChange: 'change', 6292 topClick: 'click', 6293 topClose: 'close', 6294 topCompositionEnd: 'compositionend', 6295 topCompositionStart: 'compositionstart', 6296 topCompositionUpdate: 'compositionupdate', 6297 topContextMenu: 'contextmenu', 6298 topCopy: 'copy', 6299 topCut: 'cut', 6300 topDoubleClick: 'dblclick', 6301 topDrag: 'drag', 6302 topDragEnd: 'dragend', 6303 topDragEnter: 'dragenter', 6304 topDragExit: 'dragexit', 6305 topDragLeave: 'dragleave', 6306 topDragOver: 'dragover', 6307 topDragStart: 'dragstart', 6308 topDrop: 'drop', 6309 topDurationChange: 'durationchange', 6310 topEmptied: 'emptied', 6311 topEncrypted: 'encrypted', 6312 topEnded: 'ended', 6313 topError: 'error', 6314 topFocus: 'focus', 6315 topInput: 'input', 6316 topKeyDown: 'keydown', 6317 topKeyPress: 'keypress', 6318 topKeyUp: 'keyup', 6319 topLoadedData: 'loadeddata', 6320 topLoad: 'load', 6321 topLoadedMetadata: 'loadedmetadata', 6322 topLoadStart: 'loadstart', 6323 topMouseDown: 'mousedown', 6324 topMouseMove: 'mousemove', 6325 topMouseOut: 'mouseout', 6326 topMouseOver: 'mouseover', 6327 topMouseUp: 'mouseup', 6328 topPaste: 'paste', 6329 topPause: 'pause', 6330 topPlay: 'play', 6331 topPlaying: 'playing', 6332 topProgress: 'progress', 6333 topRateChange: 'ratechange', 6334 topScroll: 'scroll', 6335 topSeeked: 'seeked', 6336 topSeeking: 'seeking', 6337 topSelectionChange: 'selectionchange', 6338 topStalled: 'stalled', 6339 topSuspend: 'suspend', 6340 topTextInput: 'textInput', 6341 topTimeUpdate: 'timeupdate', 6342 topToggle: 'toggle', 6343 topTouchCancel: 'touchcancel', 6344 topTouchEnd: 'touchend', 6345 topTouchMove: 'touchmove', 6346 topTouchStart: 'touchstart', 6347 topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend', 6348 topVolumeChange: 'volumechange', 6349 topWaiting: 'waiting', 6350 topWheel: 'wheel' 6351 }; 6352 6353 var BrowserEventConstants = { 6354 topLevelTypes: topLevelTypes$1 6355 }; 6356 6357 function runEventQueueInBatch(events) { 6358 enqueueEvents(events); 6359 processEventQueue(false); 6360 } 6361 6362 /** 6363 * Streams a fired top-level event to `EventPluginHub` where plugins have the 6364 * opportunity to create `ReactEvent`s to be dispatched. 6365 */ 6366 function handleTopLevel(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 6367 var events = extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); 6368 runEventQueueInBatch(events); 6369 } 6370 6371 var topLevelTypes = BrowserEventConstants.topLevelTypes; 6372 6373 /** 6374 * Summary of `ReactBrowserEventEmitter` event handling: 6375 * 6376 * - Top-level delegation is used to trap most native browser events. This 6377 * may only occur in the main thread and is the responsibility of 6378 * ReactDOMEventListener, which is injected and can therefore support 6379 * pluggable event sources. This is the only work that occurs in the main 6380 * thread. 6381 * 6382 * - We normalize and de-duplicate events to account for browser quirks. This 6383 * may be done in the worker thread. 6384 * 6385 * - Forward these native events (with the associated top-level type used to 6386 * trap it) to `EventPluginHub`, which in turn will ask plugins if they want 6387 * to extract any synthetic events. 6388 * 6389 * - The `EventPluginHub` will then process each event by annotating them with 6390 * "dispatches", a sequence of listeners and IDs that care about that event. 6391 * 6392 * - The `EventPluginHub` then dispatches the events. 6393 * 6394 * Overview of React and the event system: 6395 * 6396 * +------------+ . 6397 * | DOM | . 6398 * +------------+ . 6399 * | . 6400 * v . 6401 * +------------+ . 6402 * | ReactEvent | . 6403 * | Listener | . 6404 * +------------+ . +-----------+ 6405 * | . +--------+|SimpleEvent| 6406 * | . | |Plugin | 6407 * +-----|------+ . v +-----------+ 6408 * | | | . +--------------+ +------------+ 6409 * | +-----------.--->|EventPluginHub| | Event | 6410 * | | . | | +-----------+ | Propagators| 6411 * | ReactEvent | . | | |TapEvent | |------------| 6412 * | Emitter | . | |<---+|Plugin | |other plugin| 6413 * | | . | | +-----------+ | utilities | 6414 * | +-----------.--->| | +------------+ 6415 * | | | . +--------------+ 6416 * +-----|------+ . ^ +-----------+ 6417 * | . | |Enter/Leave| 6418 * + . +-------+|Plugin | 6419 * +-------------+ . +-----------+ 6420 * | application | . 6421 * |-------------| . 6422 * | | . 6423 * | | . 6424 * +-------------+ . 6425 * . 6426 * React Core . General Purpose Event Plugin System 6427 */ 6428 6429 var alreadyListeningTo = {}; 6430 var reactTopListenersCounter = 0; 6431 6432 /** 6433 * To ensure no conflicts with other potential React instances on the page 6434 */ 6435 var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); 6436 6437 function getListeningForDocument(mountAt) { 6438 // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` 6439 // directly. 6440 if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { 6441 mountAt[topListenersIDKey] = reactTopListenersCounter++; 6442 alreadyListeningTo[mountAt[topListenersIDKey]] = {}; 6443 } 6444 return alreadyListeningTo[mountAt[topListenersIDKey]]; 6445 } 6446 6447 /** 6448 * We listen for bubbled touch events on the document object. 6449 * 6450 * Firefox v8.01 (and possibly others) exhibited strange behavior when 6451 * mounting `onmousemove` events at some node that was not the document 6452 * element. The symptoms were that if your mouse is not moving over something 6453 * contained within that mount point (for example on the background) the 6454 * top-level listeners for `onmousemove` won't be called. However, if you 6455 * register the `mousemove` on the document object, then it will of course 6456 * catch all `mousemove`s. This along with iOS quirks, justifies restricting 6457 * top-level listeners to the document object only, at least for these 6458 * movement types of events and possibly all events. 6459 * 6460 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 6461 * 6462 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but 6463 * they bubble to document. 6464 * 6465 * @param {string} registrationName Name of listener (e.g. `onClick`). 6466 * @param {object} contentDocumentHandle Document which owns the container 6467 */ 6468 function listenTo(registrationName, contentDocumentHandle) { 6469 var mountAt = contentDocumentHandle; 6470 var isListening = getListeningForDocument(mountAt); 6471 var dependencies = registrationNameDependencies[registrationName]; 6472 6473 for (var i = 0; i < dependencies.length; i++) { 6474 var dependency = dependencies[i]; 6475 if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { 6476 if (dependency === 'topScroll') { 6477 trapCapturedEvent('topScroll', 'scroll', mountAt); 6478 } else if (dependency === 'topFocus' || dependency === 'topBlur') { 6479 trapCapturedEvent('topFocus', 'focus', mountAt); 6480 trapCapturedEvent('topBlur', 'blur', mountAt); 6481 6482 // to make sure blur and focus event listeners are only attached once 6483 isListening.topBlur = true; 6484 isListening.topFocus = true; 6485 } else if (dependency === 'topCancel') { 6486 if (isEventSupported('cancel', true)) { 6487 trapCapturedEvent('topCancel', 'cancel', mountAt); 6488 } 6489 isListening.topCancel = true; 6490 } else if (dependency === 'topClose') { 6491 if (isEventSupported('close', true)) { 6492 trapCapturedEvent('topClose', 'close', mountAt); 6493 } 6494 isListening.topClose = true; 6495 } else if (topLevelTypes.hasOwnProperty(dependency)) { 6496 trapBubbledEvent(dependency, topLevelTypes[dependency], mountAt); 6497 } 6498 6499 isListening[dependency] = true; 6500 } 6501 } 6502 } 6503 6504 function isListeningToAllDependencies(registrationName, mountAt) { 6505 var isListening = getListeningForDocument(mountAt); 6506 var dependencies = registrationNameDependencies[registrationName]; 6507 for (var i = 0; i < dependencies.length; i++) { 6508 var dependency = dependencies[i]; 6509 if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { 6510 return false; 6511 } 6512 } 6513 return true; 6514 } 6515 6516 /** 6517 * Given any node return the first leaf node without children. 6518 * 6519 * @param {DOMElement|DOMTextNode} node 6520 * @return {DOMElement|DOMTextNode} 6521 */ 6522 function getLeafNode(node) { 6523 while (node && node.firstChild) { 6524 node = node.firstChild; 6525 } 6526 return node; 6527 } 6528 6529 /** 6530 * Get the next sibling within a container. This will walk up the 6531 * DOM if a node's siblings have been exhausted. 6532 * 6533 * @param {DOMElement|DOMTextNode} node 6534 * @return {?DOMElement|DOMTextNode} 6535 */ 6536 function getSiblingNode(node) { 6537 while (node) { 6538 if (node.nextSibling) { 6539 return node.nextSibling; 6540 } 6541 node = node.parentNode; 6542 } 6543 } 6544 6545 /** 6546 * Get object describing the nodes which contain characters at offset. 6547 * 6548 * @param {DOMElement|DOMTextNode} root 6549 * @param {number} offset 6550 * @return {?object} 6551 */ 6552 function getNodeForCharacterOffset(root, offset) { 6553 var node = getLeafNode(root); 6554 var nodeStart = 0; 6555 var nodeEnd = 0; 6556 6557 while (node) { 6558 if (node.nodeType === TEXT_NODE) { 6559 nodeEnd = nodeStart + node.textContent.length; 6560 6561 if (nodeStart <= offset && nodeEnd >= offset) { 6562 return { 6563 node: node, 6564 offset: offset - nodeStart 6565 }; 6566 } 6567 6568 nodeStart = nodeEnd; 6569 } 6570 6571 node = getLeafNode(getSiblingNode(node)); 6572 } 6573 } 6574 6575 /** 6576 * @param {DOMElement} outerNode 6577 * @return {?object} 6578 */ 6579 function getOffsets(outerNode) { 6580 var selection = window.getSelection && window.getSelection(); 6581 6582 if (!selection || selection.rangeCount === 0) { 6583 return null; 6584 } 6585 6586 var anchorNode = selection.anchorNode, 6587 anchorOffset = selection.anchorOffset, 6588 focusNode$$1 = selection.focusNode, 6589 focusOffset = selection.focusOffset; 6590 6591 // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 6592 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 6593 // expose properties, triggering a "Permission denied error" if any of its 6594 // properties are accessed. The only seemingly possible way to avoid erroring 6595 // is to access a property that typically works for non-anonymous divs and 6596 // catch any error that may otherwise arise. See 6597 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 6598 6599 try { 6600 /* eslint-disable no-unused-expressions */ 6601 anchorNode.nodeType; 6602 focusNode$$1.nodeType; 6603 /* eslint-enable no-unused-expressions */ 6604 } catch (e) { 6605 return null; 6606 } 6607 6608 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode$$1, focusOffset); 6609 } 6610 6611 /** 6612 * Returns {start, end} where `start` is the character/codepoint index of 6613 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 6614 * `end` is the index of (focusNode, focusOffset). 6615 * 6616 * Returns null if you pass in garbage input but we should probably just crash. 6617 * 6618 * Exported only for testing. 6619 */ 6620 function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode$$1, focusOffset) { 6621 var length = 0; 6622 var start = -1; 6623 var end = -1; 6624 var indexWithinAnchor = 0; 6625 var indexWithinFocus = 0; 6626 var node = outerNode; 6627 var parentNode = null; 6628 6629 outer: while (true) { 6630 var next = null; 6631 6632 while (true) { 6633 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 6634 start = length + anchorOffset; 6635 } 6636 if (node === focusNode$$1 && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 6637 end = length + focusOffset; 6638 } 6639 6640 if (node.nodeType === TEXT_NODE) { 6641 length += node.nodeValue.length; 6642 } 6643 6644 if ((next = node.firstChild) === null) { 6645 break; 6646 } 6647 // Moving from `node` to its first child `next`. 6648 parentNode = node; 6649 node = next; 6650 } 6651 6652 while (true) { 6653 if (node === outerNode) { 6654 // If `outerNode` has children, this is always the second time visiting 6655 // it. If it has no children, this is still the first loop, and the only 6656 // valid selection is anchorNode and focusNode both equal to this node 6657 // and both offsets 0, in which case we will have handled above. 6658 break outer; 6659 } 6660 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 6661 start = length; 6662 } 6663 if (parentNode === focusNode$$1 && ++indexWithinFocus === focusOffset) { 6664 end = length; 6665 } 6666 if ((next = node.nextSibling) !== null) { 6667 break; 6668 } 6669 node = parentNode; 6670 parentNode = node.parentNode; 6671 } 6672 6673 // Moving from `node` to its next sibling `next`. 6674 node = next; 6675 } 6676 6677 if (start === -1 || end === -1) { 6678 // This should never happen. (Would happen if the anchor/focus nodes aren't 6679 // actually inside the passed-in node.) 6680 return null; 6681 } 6682 6683 return { 6684 start: start, 6685 end: end 6686 }; 6687 } 6688 6689 /** 6690 * In modern non-IE browsers, we can support both forward and backward 6691 * selections. 6692 * 6693 * Note: IE10+ supports the Selection object, but it does not support 6694 * the `extend` method, which means that even in modern IE, it's not possible 6695 * to programmatically create a backward selection. Thus, for all IE 6696 * versions, we use the old IE API to create our selections. 6697 * 6698 * @param {DOMElement|DOMTextNode} node 6699 * @param {object} offsets 6700 */ 6701 function setOffsets(node, offsets) { 6702 if (!window.getSelection) { 6703 return; 6704 } 6705 6706 var selection = window.getSelection(); 6707 var length = node[getTextContentAccessor()].length; 6708 var start = Math.min(offsets.start, length); 6709 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); 6710 6711 // IE 11 uses modern selection, but doesn't support the extend method. 6712 // Flip backward selections, so we can set with a single range. 6713 if (!selection.extend && start > end) { 6714 var temp = end; 6715 end = start; 6716 start = temp; 6717 } 6718 6719 var startMarker = getNodeForCharacterOffset(node, start); 6720 var endMarker = getNodeForCharacterOffset(node, end); 6721 6722 if (startMarker && endMarker) { 6723 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 6724 return; 6725 } 6726 var range = document.createRange(); 6727 range.setStart(startMarker.node, startMarker.offset); 6728 selection.removeAllRanges(); 6729 6730 if (start > end) { 6731 selection.addRange(range); 6732 selection.extend(endMarker.node, endMarker.offset); 6733 } else { 6734 range.setEnd(endMarker.node, endMarker.offset); 6735 selection.addRange(range); 6736 } 6737 } 6738 } 6739 6740 function isInDocument(node) { 6741 return containsNode(document.documentElement, node); 6742 } 6743 6744 /** 6745 * @ReactInputSelection: React input selection module. Based on Selection.js, 6746 * but modified to be suitable for react and has a couple of bug fixes (doesn't 6747 * assume buttons have range selections allowed). 6748 * Input selection module for React. 6749 */ 6750 6751 function hasSelectionCapabilities(elem) { 6752 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 6753 return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true'); 6754 } 6755 6756 function getSelectionInformation() { 6757 var focusedElem = getActiveElement(); 6758 return { 6759 focusedElem: focusedElem, 6760 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection$1(focusedElem) : null 6761 }; 6762 } 6763 6764 /** 6765 * @restoreSelection: If any selection information was potentially lost, 6766 * restore it. This is useful when performing operations that could remove dom 6767 * nodes and place them back in, resulting in focus being lost. 6768 */ 6769 function restoreSelection(priorSelectionInformation) { 6770 var curFocusedElem = getActiveElement(); 6771 var priorFocusedElem = priorSelectionInformation.focusedElem; 6772 var priorSelectionRange = priorSelectionInformation.selectionRange; 6773 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 6774 if (hasSelectionCapabilities(priorFocusedElem)) { 6775 setSelection(priorFocusedElem, priorSelectionRange); 6776 } 6777 6778 // Focusing a node can change the scroll position, which is undesirable 6779 var ancestors = []; 6780 var ancestor = priorFocusedElem; 6781 while (ancestor = ancestor.parentNode) { 6782 if (ancestor.nodeType === ELEMENT_NODE) { 6783 ancestors.push({ 6784 element: ancestor, 6785 left: ancestor.scrollLeft, 6786 top: ancestor.scrollTop 6787 }); 6788 } 6789 } 6790 6791 focusNode(priorFocusedElem); 6792 6793 for (var i = 0; i < ancestors.length; i++) { 6794 var info = ancestors[i]; 6795 info.element.scrollLeft = info.left; 6796 info.element.scrollTop = info.top; 6797 } 6798 } 6799 } 6800 6801 /** 6802 * @getSelection: Gets the selection bounds of a focused textarea, input or 6803 * contentEditable node. 6804 * -@input: Look up selection bounds of this input 6805 * -@return {start: selectionStart, end: selectionEnd} 6806 */ 6807 function getSelection$1(input) { 6808 var selection = void 0; 6809 6810 if ('selectionStart' in input) { 6811 // Modern browser with input or textarea. 6812 selection = { 6813 start: input.selectionStart, 6814 end: input.selectionEnd 6815 }; 6816 } else { 6817 // Content editable or old IE textarea. 6818 selection = getOffsets(input); 6819 } 6820 6821 return selection || { start: 0, end: 0 }; 6822 } 6823 6824 /** 6825 * @setSelection: Sets the selection bounds of a textarea or input and focuses 6826 * the input. 6827 * -@input Set selection bounds of this input or textarea 6828 * -@offsets Object of same form that is returned from get* 6829 */ 6830 function setSelection(input, offsets) { 6831 var start = offsets.start, 6832 end = offsets.end; 6833 6834 if (end === undefined) { 6835 end = start; 6836 } 6837 6838 if ('selectionStart' in input) { 6839 input.selectionStart = start; 6840 input.selectionEnd = Math.min(end, input.value.length); 6841 } else { 6842 setOffsets(input, offsets); 6843 } 6844 } 6845 6846 var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11; 6847 6848 var eventTypes$3 = { 6849 select: { 6850 phasedRegistrationNames: { 6851 bubbled: 'onSelect', 6852 captured: 'onSelectCapture' 6853 }, 6854 dependencies: ['topBlur', 'topContextMenu', 'topFocus', 'topKeyDown', 'topKeyUp', 'topMouseDown', 'topMouseUp', 'topSelectionChange'] 6855 } 6856 }; 6857 6858 var activeElement$1 = null; 6859 var activeElementInst$1 = null; 6860 var lastSelection = null; 6861 var mouseDown = false; 6862 6863 /** 6864 * Get an object which is a unique representation of the current selection. 6865 * 6866 * The return value will not be consistent across nodes or browsers, but 6867 * two identical selections on the same node will return identical objects. 6868 * 6869 * @param {DOMElement} node 6870 * @return {object} 6871 */ 6872 function getSelection(node) { 6873 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 6874 return { 6875 start: node.selectionStart, 6876 end: node.selectionEnd 6877 }; 6878 } else if (window.getSelection) { 6879 var selection = window.getSelection(); 6880 return { 6881 anchorNode: selection.anchorNode, 6882 anchorOffset: selection.anchorOffset, 6883 focusNode: selection.focusNode, 6884 focusOffset: selection.focusOffset 6885 }; 6886 } 6887 } 6888 6889 /** 6890 * Poll selection to see whether it's changed. 6891 * 6892 * @param {object} nativeEvent 6893 * @return {?SyntheticEvent} 6894 */ 6895 function constructSelectEvent(nativeEvent, nativeEventTarget) { 6896 // Ensure we have the right element, and that the user is not dragging a 6897 // selection (this matches native `select` event behavior). In HTML5, select 6898 // fires only on input and textarea thus if there's no focused element we 6899 // won't dispatch. 6900 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) { 6901 return null; 6902 } 6903 6904 // Only fire when selection has actually changed. 6905 var currentSelection = getSelection(activeElement$1); 6906 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 6907 lastSelection = currentSelection; 6908 6909 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); 6910 6911 syntheticEvent.type = 'select'; 6912 syntheticEvent.target = activeElement$1; 6913 6914 accumulateTwoPhaseDispatches(syntheticEvent); 6915 6916 return syntheticEvent; 6917 } 6918 6919 return null; 6920 } 6921 6922 /** 6923 * This plugin creates an `onSelect` event that normalizes select events 6924 * across form elements. 6925 * 6926 * Supported elements are: 6927 * - input (see `isTextInputElement`) 6928 * - textarea 6929 * - contentEditable 6930 * 6931 * This differs from native browser implementations in the following ways: 6932 * - Fires on contentEditable fields as well as inputs. 6933 * - Fires for collapsed selection. 6934 * - Fires after user input. 6935 */ 6936 var SelectEventPlugin = { 6937 eventTypes: eventTypes$3, 6938 6939 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 6940 var doc = nativeEventTarget.window === nativeEventTarget ? nativeEventTarget.document : nativeEventTarget.nodeType === DOCUMENT_NODE ? nativeEventTarget : nativeEventTarget.ownerDocument; 6941 // Track whether all listeners exists for this plugin. If none exist, we do 6942 // not extract events. See #3639. 6943 if (!doc || !isListeningToAllDependencies('onSelect', doc)) { 6944 return null; 6945 } 6946 6947 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 6948 6949 switch (topLevelType) { 6950 // Track the input node that has focus. 6951 case 'topFocus': 6952 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 6953 activeElement$1 = targetNode; 6954 activeElementInst$1 = targetInst; 6955 lastSelection = null; 6956 } 6957 break; 6958 case 'topBlur': 6959 activeElement$1 = null; 6960 activeElementInst$1 = null; 6961 lastSelection = null; 6962 break; 6963 // Don't fire the event while the user is dragging. This matches the 6964 // semantics of the native select event. 6965 case 'topMouseDown': 6966 mouseDown = true; 6967 break; 6968 case 'topContextMenu': 6969 case 'topMouseUp': 6970 mouseDown = false; 6971 return constructSelectEvent(nativeEvent, nativeEventTarget); 6972 // Chrome and IE fire non-standard event when selection is changed (and 6973 // sometimes when it hasn't). IE's event fires out of order with respect 6974 // to key and input events on deletion, so we discard it. 6975 // 6976 // Firefox doesn't support selectionchange, so check selection status 6977 // after each key entry. The selection changes after keydown and before 6978 // keyup, but we check on keydown as well in the case of holding down a 6979 // key, when multiple keydown events are fired but only one keyup is. 6980 // This is also our approach for IE handling, for the reason above. 6981 case 'topSelectionChange': 6982 if (skipSelectionChangeEvent) { 6983 break; 6984 } 6985 // falls through 6986 case 'topKeyDown': 6987 case 'topKeyUp': 6988 return constructSelectEvent(nativeEvent, nativeEventTarget); 6989 } 6990 6991 return null; 6992 } 6993 }; 6994 6995 /** 6996 * @interface Event 6997 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 6998 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 6999 */ 7000 var AnimationEventInterface = { 7001 animationName: null, 7002 elapsedTime: null, 7003 pseudoElement: null 7004 }; 7005 7006 /** 7007 * @param {object} dispatchConfig Configuration used to dispatch this event. 7008 * @param {string} dispatchMarker Marker identifying the event target. 7009 * @param {object} nativeEvent Native browser event. 7010 * @extends {SyntheticEvent} 7011 */ 7012 function SyntheticAnimationEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7013 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7014 } 7015 7016 SyntheticEvent$1.augmentClass(SyntheticAnimationEvent, AnimationEventInterface); 7017 7018 /** 7019 * @interface Event 7020 * @see http://www.w3.org/TR/clipboard-apis/ 7021 */ 7022 var ClipboardEventInterface = { 7023 clipboardData: function (event) { 7024 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 7025 } 7026 }; 7027 7028 /** 7029 * @param {object} dispatchConfig Configuration used to dispatch this event. 7030 * @param {string} dispatchMarker Marker identifying the event target. 7031 * @param {object} nativeEvent Native browser event. 7032 * @extends {SyntheticEvent} 7033 */ 7034 function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7035 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7036 } 7037 7038 SyntheticEvent$1.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface); 7039 7040 /** 7041 * @interface FocusEvent 7042 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 7043 */ 7044 var FocusEventInterface = { 7045 relatedTarget: null 7046 }; 7047 7048 /** 7049 * @param {object} dispatchConfig Configuration used to dispatch this event. 7050 * @param {string} dispatchMarker Marker identifying the event target. 7051 * @param {object} nativeEvent Native browser event. 7052 * @extends {SyntheticUIEvent} 7053 */ 7054 function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7055 return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7056 } 7057 7058 SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface); 7059 7060 /** 7061 * `charCode` represents the actual "character code" and is safe to use with 7062 * `String.fromCharCode`. As such, only keys that correspond to printable 7063 * characters produce a valid `charCode`, the only exception to this is Enter. 7064 * The Tab-key is considered non-printable and does not have a `charCode`, 7065 * presumably because it does not produce a tab-character in browsers. 7066 * 7067 * @param {object} nativeEvent Native browser event. 7068 * @return {number} Normalized `charCode` property. 7069 */ 7070 function getEventCharCode(nativeEvent) { 7071 var charCode; 7072 var keyCode = nativeEvent.keyCode; 7073 7074 if ('charCode' in nativeEvent) { 7075 charCode = nativeEvent.charCode; 7076 7077 // FF does not set `charCode` for the Enter-key, check against `keyCode`. 7078 if (charCode === 0 && keyCode === 13) { 7079 charCode = 13; 7080 } 7081 } else { 7082 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 7083 charCode = keyCode; 7084 } 7085 7086 // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 7087 // Must not discard the (non-)printable Enter-key. 7088 if (charCode >= 32 || charCode === 13) { 7089 return charCode; 7090 } 7091 7092 return 0; 7093 } 7094 7095 /** 7096 * Normalization of deprecated HTML5 `key` values 7097 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 7098 */ 7099 var normalizeKey = { 7100 Esc: 'Escape', 7101 Spacebar: ' ', 7102 Left: 'ArrowLeft', 7103 Up: 'ArrowUp', 7104 Right: 'ArrowRight', 7105 Down: 'ArrowDown', 7106 Del: 'Delete', 7107 Win: 'OS', 7108 Menu: 'ContextMenu', 7109 Apps: 'ContextMenu', 7110 Scroll: 'ScrollLock', 7111 MozPrintableKey: 'Unidentified' 7112 }; 7113 7114 /** 7115 * Translation from legacy `keyCode` to HTML5 `key` 7116 * Only special keys supported, all others depend on keyboard layout or browser 7117 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 7118 */ 7119 var translateToKey = { 7120 '8': 'Backspace', 7121 '9': 'Tab', 7122 '12': 'Clear', 7123 '13': 'Enter', 7124 '16': 'Shift', 7125 '17': 'Control', 7126 '18': 'Alt', 7127 '19': 'Pause', 7128 '20': 'CapsLock', 7129 '27': 'Escape', 7130 '32': ' ', 7131 '33': 'PageUp', 7132 '34': 'PageDown', 7133 '35': 'End', 7134 '36': 'Home', 7135 '37': 'ArrowLeft', 7136 '38': 'ArrowUp', 7137 '39': 'ArrowRight', 7138 '40': 'ArrowDown', 7139 '45': 'Insert', 7140 '46': 'Delete', 7141 '112': 'F1', 7142 '113': 'F2', 7143 '114': 'F3', 7144 '115': 'F4', 7145 '116': 'F5', 7146 '117': 'F6', 7147 '118': 'F7', 7148 '119': 'F8', 7149 '120': 'F9', 7150 '121': 'F10', 7151 '122': 'F11', 7152 '123': 'F12', 7153 '144': 'NumLock', 7154 '145': 'ScrollLock', 7155 '224': 'Meta' 7156 }; 7157 7158 /** 7159 * @param {object} nativeEvent Native browser event. 7160 * @return {string} Normalized `key` property. 7161 */ 7162 function getEventKey(nativeEvent) { 7163 if (nativeEvent.key) { 7164 // Normalize inconsistent values reported by browsers due to 7165 // implementations of a working draft specification. 7166 7167 // FireFox implements `key` but returns `MozPrintableKey` for all 7168 // printable characters (normalized to `Unidentified`), ignore it. 7169 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 7170 if (key !== 'Unidentified') { 7171 return key; 7172 } 7173 } 7174 7175 // Browser does not implement `key`, polyfill as much of it as we can. 7176 if (nativeEvent.type === 'keypress') { 7177 var charCode = getEventCharCode(nativeEvent); 7178 7179 // The enter-key is technically both printable and non-printable and can 7180 // thus be captured by `keypress`, no other non-printable key should. 7181 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 7182 } 7183 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 7184 // While user keyboard layout determines the actual meaning of each 7185 // `keyCode` value, almost all function keys have a universal value. 7186 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 7187 } 7188 return ''; 7189 } 7190 7191 /** 7192 * @interface KeyboardEvent 7193 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 7194 */ 7195 var KeyboardEventInterface = { 7196 key: getEventKey, 7197 location: null, 7198 ctrlKey: null, 7199 shiftKey: null, 7200 altKey: null, 7201 metaKey: null, 7202 repeat: null, 7203 locale: null, 7204 getModifierState: getEventModifierState, 7205 // Legacy Interface 7206 charCode: function (event) { 7207 // `charCode` is the result of a KeyPress event and represents the value of 7208 // the actual printable character. 7209 7210 // KeyPress is deprecated, but its replacement is not yet final and not 7211 // implemented in any major browser. Only KeyPress has charCode. 7212 if (event.type === 'keypress') { 7213 return getEventCharCode(event); 7214 } 7215 return 0; 7216 }, 7217 keyCode: function (event) { 7218 // `keyCode` is the result of a KeyDown/Up event and represents the value of 7219 // physical keyboard key. 7220 7221 // The actual meaning of the value depends on the users' keyboard layout 7222 // which cannot be detected. Assuming that it is a US keyboard layout 7223 // provides a surprisingly accurate mapping for US and European users. 7224 // Due to this, it is left to the user to implement at this time. 7225 if (event.type === 'keydown' || event.type === 'keyup') { 7226 return event.keyCode; 7227 } 7228 return 0; 7229 }, 7230 which: function (event) { 7231 // `which` is an alias for either `keyCode` or `charCode` depending on the 7232 // type of the event. 7233 if (event.type === 'keypress') { 7234 return getEventCharCode(event); 7235 } 7236 if (event.type === 'keydown' || event.type === 'keyup') { 7237 return event.keyCode; 7238 } 7239 return 0; 7240 } 7241 }; 7242 7243 /** 7244 * @param {object} dispatchConfig Configuration used to dispatch this event. 7245 * @param {string} dispatchMarker Marker identifying the event target. 7246 * @param {object} nativeEvent Native browser event. 7247 * @extends {SyntheticUIEvent} 7248 */ 7249 function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7250 return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7251 } 7252 7253 SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface); 7254 7255 /** 7256 * @interface DragEvent 7257 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 7258 */ 7259 var DragEventInterface = { 7260 dataTransfer: null 7261 }; 7262 7263 /** 7264 * @param {object} dispatchConfig Configuration used to dispatch this event. 7265 * @param {string} dispatchMarker Marker identifying the event target. 7266 * @param {object} nativeEvent Native browser event. 7267 * @extends {SyntheticMouseEvent} 7268 */ 7269 function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7270 return SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7271 } 7272 7273 SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface); 7274 7275 /** 7276 * @interface TouchEvent 7277 * @see http://www.w3.org/TR/touch-events/ 7278 */ 7279 var TouchEventInterface = { 7280 touches: null, 7281 targetTouches: null, 7282 changedTouches: null, 7283 altKey: null, 7284 metaKey: null, 7285 ctrlKey: null, 7286 shiftKey: null, 7287 getModifierState: getEventModifierState 7288 }; 7289 7290 /** 7291 * @param {object} dispatchConfig Configuration used to dispatch this event. 7292 * @param {string} dispatchMarker Marker identifying the event target. 7293 * @param {object} nativeEvent Native browser event. 7294 * @extends {SyntheticUIEvent} 7295 */ 7296 function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7297 return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7298 } 7299 7300 SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface); 7301 7302 /** 7303 * @interface Event 7304 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 7305 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 7306 */ 7307 var TransitionEventInterface = { 7308 propertyName: null, 7309 elapsedTime: null, 7310 pseudoElement: null 7311 }; 7312 7313 /** 7314 * @param {object} dispatchConfig Configuration used to dispatch this event. 7315 * @param {string} dispatchMarker Marker identifying the event target. 7316 * @param {object} nativeEvent Native browser event. 7317 * @extends {SyntheticEvent} 7318 */ 7319 function SyntheticTransitionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7320 return SyntheticEvent$1.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7321 } 7322 7323 SyntheticEvent$1.augmentClass(SyntheticTransitionEvent, TransitionEventInterface); 7324 7325 /** 7326 * @interface WheelEvent 7327 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 7328 */ 7329 var WheelEventInterface = { 7330 deltaX: function (event) { 7331 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 7332 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 7333 }, 7334 deltaY: function (event) { 7335 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 7336 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 7337 'wheelDelta' in event ? -event.wheelDelta : 0; 7338 }, 7339 deltaZ: null, 7340 7341 // Browsers without "deltaMode" is reporting in raw wheel delta where one 7342 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 7343 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 7344 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 7345 deltaMode: null 7346 }; 7347 7348 /** 7349 * @param {object} dispatchConfig Configuration used to dispatch this event. 7350 * @param {string} dispatchMarker Marker identifying the event target. 7351 * @param {object} nativeEvent Native browser event. 7352 * @extends {SyntheticMouseEvent} 7353 */ 7354 function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { 7355 return SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); 7356 } 7357 7358 SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface); 7359 7360 /** 7361 * Turns 7362 * ['abort', ...] 7363 * into 7364 * eventTypes = { 7365 * 'abort': { 7366 * phasedRegistrationNames: { 7367 * bubbled: 'onAbort', 7368 * captured: 'onAbortCapture', 7369 * }, 7370 * dependencies: ['topAbort'], 7371 * }, 7372 * ... 7373 * }; 7374 * topLevelEventsToDispatchConfig = { 7375 * 'topAbort': { sameConfig } 7376 * }; 7377 */ 7378 var eventTypes$4 = {}; 7379 var topLevelEventsToDispatchConfig = {}; 7380 ['abort', 'animationEnd', 'animationIteration', 'animationStart', 'blur', 'cancel', 'canPlay', 'canPlayThrough', 'click', 'close', 'contextMenu', 'copy', 'cut', 'doubleClick', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'progress', 'rateChange', 'reset', 'scroll', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'toggle', 'touchCancel', 'touchEnd', 'touchMove', 'touchStart', 'transitionEnd', 'volumeChange', 'waiting', 'wheel'].forEach(function (event) { 7381 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 7382 var onEvent = 'on' + capitalizedEvent; 7383 var topEvent = 'top' + capitalizedEvent; 7384 7385 var type = { 7386 phasedRegistrationNames: { 7387 bubbled: onEvent, 7388 captured: onEvent + 'Capture' 7389 }, 7390 dependencies: [topEvent] 7391 }; 7392 eventTypes$4[event] = type; 7393 topLevelEventsToDispatchConfig[topEvent] = type; 7394 }); 7395 7396 // Only used in DEV for exhaustiveness validation. 7397 var knownHTMLTopLevelTypes = ['topAbort', 'topCancel', 'topCanPlay', 'topCanPlayThrough', 'topClose', 'topDurationChange', 'topEmptied', 'topEncrypted', 'topEnded', 'topError', 'topInput', 'topInvalid', 'topLoad', 'topLoadedData', 'topLoadedMetadata', 'topLoadStart', 'topPause', 'topPlay', 'topPlaying', 'topProgress', 'topRateChange', 'topReset', 'topSeeked', 'topSeeking', 'topStalled', 'topSubmit', 'topSuspend', 'topTimeUpdate', 'topToggle', 'topVolumeChange', 'topWaiting']; 7398 7399 var SimpleEventPlugin = { 7400 eventTypes: eventTypes$4, 7401 7402 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 7403 var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; 7404 if (!dispatchConfig) { 7405 return null; 7406 } 7407 var EventConstructor; 7408 switch (topLevelType) { 7409 case 'topKeyPress': 7410 // Firefox creates a keypress event for function keys too. This removes 7411 // the unwanted keypress events. Enter is however both printable and 7412 // non-printable. One would expect Tab to be as well (but it isn't). 7413 if (getEventCharCode(nativeEvent) === 0) { 7414 return null; 7415 } 7416 /* falls through */ 7417 case 'topKeyDown': 7418 case 'topKeyUp': 7419 EventConstructor = SyntheticKeyboardEvent; 7420 break; 7421 case 'topBlur': 7422 case 'topFocus': 7423 EventConstructor = SyntheticFocusEvent; 7424 break; 7425 case 'topClick': 7426 // Firefox creates a click event on right mouse clicks. This removes the 7427 // unwanted click events. 7428 if (nativeEvent.button === 2) { 7429 return null; 7430 } 7431 /* falls through */ 7432 case 'topDoubleClick': 7433 case 'topMouseDown': 7434 case 'topMouseMove': 7435 case 'topMouseUp': 7436 // TODO: Disabled elements should not respond to mouse events 7437 /* falls through */ 7438 case 'topMouseOut': 7439 case 'topMouseOver': 7440 case 'topContextMenu': 7441 EventConstructor = SyntheticMouseEvent; 7442 break; 7443 case 'topDrag': 7444 case 'topDragEnd': 7445 case 'topDragEnter': 7446 case 'topDragExit': 7447 case 'topDragLeave': 7448 case 'topDragOver': 7449 case 'topDragStart': 7450 case 'topDrop': 7451 EventConstructor = SyntheticDragEvent; 7452 break; 7453 case 'topTouchCancel': 7454 case 'topTouchEnd': 7455 case 'topTouchMove': 7456 case 'topTouchStart': 7457 EventConstructor = SyntheticTouchEvent; 7458 break; 7459 case 'topAnimationEnd': 7460 case 'topAnimationIteration': 7461 case 'topAnimationStart': 7462 EventConstructor = SyntheticAnimationEvent; 7463 break; 7464 case 'topTransitionEnd': 7465 EventConstructor = SyntheticTransitionEvent; 7466 break; 7467 case 'topScroll': 7468 EventConstructor = SyntheticUIEvent; 7469 break; 7470 case 'topWheel': 7471 EventConstructor = SyntheticWheelEvent; 7472 break; 7473 case 'topCopy': 7474 case 'topCut': 7475 case 'topPaste': 7476 EventConstructor = SyntheticClipboardEvent; 7477 break; 7478 default: 7479 { 7480 if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) { 7481 warning(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType); 7482 } 7483 } 7484 // HTML Events 7485 // @see http://www.w3.org/TR/html5/index.html#events-0 7486 EventConstructor = SyntheticEvent$1; 7487 break; 7488 } 7489 var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); 7490 accumulateTwoPhaseDispatches(event); 7491 return event; 7492 } 7493 }; 7494 7495 setHandleTopLevel(handleTopLevel); 7496 7497 /** 7498 * Inject modules for resolving DOM hierarchy and plugin ordering. 7499 */ 7500 injection$1.injectEventPluginOrder(DOMEventPluginOrder); 7501 injection$2.injectComponentTree(ReactDOMComponentTree); 7502 7503 /** 7504 * Some important event plugins included by default (without having to require 7505 * them). 7506 */ 7507 injection$1.injectEventPluginsByName({ 7508 SimpleEventPlugin: SimpleEventPlugin, 7509 EnterLeaveEventPlugin: EnterLeaveEventPlugin, 7510 ChangeEventPlugin: ChangeEventPlugin, 7511 SelectEventPlugin: SelectEventPlugin, 7512 BeforeInputEventPlugin: BeforeInputEventPlugin 7513 }); 7514 7515 var enableAsyncSubtreeAPI = true; 7516 var enableAsyncSchedulingByDefaultInReactDOM = false; 7517 // Exports ReactDOM.createRoot 7518 var enableCreateRoot = false; 7519 var enableUserTimingAPI = true; 7520 7521 // Mutating mode (React DOM, React ART, React Native): 7522 var enableMutatingReconciler = true; 7523 // Experimental noop mode (currently unused): 7524 var enableNoopReconciler = false; 7525 // Experimental persistent mode (CS): 7526 var enablePersistentReconciler = false; 7527 7528 // Helps identify side effects in begin-phase lifecycle hooks and setState reducers: 7529 var debugRenderPhaseSideEffects = false; 7530 7531 // Only used in www builds. 7532 7533 var valueStack = []; 7534 7535 { 7536 var fiberStack = []; 7537 } 7538 7539 var index = -1; 7540 7541 function createCursor(defaultValue) { 7542 return { 7543 current: defaultValue 7544 }; 7545 } 7546 7547 7548 7549 function pop(cursor, fiber) { 7550 if (index < 0) { 7551 { 7552 warning(false, 'Unexpected pop.'); 7553 } 7554 return; 7555 } 7556 7557 { 7558 if (fiber !== fiberStack[index]) { 7559 warning(false, 'Unexpected Fiber popped.'); 7560 } 7561 } 7562 7563 cursor.current = valueStack[index]; 7564 7565 valueStack[index] = null; 7566 7567 { 7568 fiberStack[index] = null; 7569 } 7570 7571 index--; 7572 } 7573 7574 function push(cursor, value, fiber) { 7575 index++; 7576 7577 valueStack[index] = cursor.current; 7578 7579 { 7580 fiberStack[index] = fiber; 7581 } 7582 7583 cursor.current = value; 7584 } 7585 7586 function reset$1() { 7587 while (index > -1) { 7588 valueStack[index] = null; 7589 7590 { 7591 fiberStack[index] = null; 7592 } 7593 7594 index--; 7595 } 7596 } 7597 7598 var describeComponentFrame = function (name, source, ownerName) { 7599 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); 7600 }; 7601 7602 function describeFiber(fiber) { 7603 switch (fiber.tag) { 7604 case IndeterminateComponent: 7605 case FunctionalComponent: 7606 case ClassComponent: 7607 case HostComponent: 7608 var owner = fiber._debugOwner; 7609 var source = fiber._debugSource; 7610 var name = getComponentName(fiber); 7611 var ownerName = null; 7612 if (owner) { 7613 ownerName = getComponentName(owner); 7614 } 7615 return describeComponentFrame(name, source, ownerName); 7616 default: 7617 return ''; 7618 } 7619 } 7620 7621 // This function can only be called with a work-in-progress fiber and 7622 // only during begin or complete phase. Do not call it under any other 7623 // circumstances. 7624 function getStackAddendumByWorkInProgressFiber(workInProgress) { 7625 var info = ''; 7626 var node = workInProgress; 7627 do { 7628 info += describeFiber(node); 7629 // Otherwise this return pointer might point to the wrong tree: 7630 node = node['return']; 7631 } while (node); 7632 return info; 7633 } 7634 7635 function getCurrentFiberOwnerName() { 7636 { 7637 var fiber = ReactDebugCurrentFiber.current; 7638 if (fiber === null) { 7639 return null; 7640 } 7641 var owner = fiber._debugOwner; 7642 if (owner !== null && typeof owner !== 'undefined') { 7643 return getComponentName(owner); 7644 } 7645 } 7646 return null; 7647 } 7648 7649 function getCurrentFiberStackAddendum() { 7650 { 7651 var fiber = ReactDebugCurrentFiber.current; 7652 if (fiber === null) { 7653 return null; 7654 } 7655 // Safe because if current fiber exists, we are reconciling, 7656 // and it is guaranteed to be the work-in-progress version. 7657 return getStackAddendumByWorkInProgressFiber(fiber); 7658 } 7659 return null; 7660 } 7661 7662 function resetCurrentFiber() { 7663 ReactDebugCurrentFrame.getCurrentStack = null; 7664 ReactDebugCurrentFiber.current = null; 7665 ReactDebugCurrentFiber.phase = null; 7666 } 7667 7668 function setCurrentFiber(fiber) { 7669 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackAddendum; 7670 ReactDebugCurrentFiber.current = fiber; 7671 ReactDebugCurrentFiber.phase = null; 7672 } 7673 7674 function setCurrentPhase(phase) { 7675 ReactDebugCurrentFiber.phase = phase; 7676 } 7677 7678 var ReactDebugCurrentFiber = { 7679 current: null, 7680 phase: null, 7681 resetCurrentFiber: resetCurrentFiber, 7682 setCurrentFiber: setCurrentFiber, 7683 setCurrentPhase: setCurrentPhase, 7684 getCurrentFiberOwnerName: getCurrentFiberOwnerName, 7685 getCurrentFiberStackAddendum: getCurrentFiberStackAddendum 7686 }; 7687 7688 // Prefix measurements so that it's possible to filter them. 7689 // Longer prefixes are hard to read in DevTools. 7690 var reactEmoji = '\u269B'; 7691 var warningEmoji = '\u26D4'; 7692 var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; 7693 7694 // Keep track of current fiber so that we know the path to unwind on pause. 7695 // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? 7696 var currentFiber = null; 7697 // If we're in the middle of user code, which fiber and method is it? 7698 // Reusing `currentFiber` would be confusing for this because user code fiber 7699 // can change during commit phase too, but we don't need to unwind it (since 7700 // lifecycles in the commit phase don't resemble a tree). 7701 var currentPhase = null; 7702 var currentPhaseFiber = null; 7703 // Did lifecycle hook schedule an update? This is often a performance problem, 7704 // so we will keep track of it, and include it in the report. 7705 // Track commits caused by cascading updates. 7706 var isCommitting = false; 7707 var hasScheduledUpdateInCurrentCommit = false; 7708 var hasScheduledUpdateInCurrentPhase = false; 7709 var commitCountInCurrentWorkLoop = 0; 7710 var effectCountInCurrentCommit = 0; 7711 var isWaitingForCallback = false; 7712 // During commits, we only show a measurement once per method name 7713 // to avoid stretch the commit phase with measurement overhead. 7714 var labelsInCurrentCommit = new Set(); 7715 7716 var formatMarkName = function (markName) { 7717 return reactEmoji + ' ' + markName; 7718 }; 7719 7720 var formatLabel = function (label, warning$$1) { 7721 var prefix = warning$$1 ? warningEmoji + ' ' : reactEmoji + ' '; 7722 var suffix = warning$$1 ? ' Warning: ' + warning$$1 : ''; 7723 return '' + prefix + label + suffix; 7724 }; 7725 7726 var beginMark = function (markName) { 7727 performance.mark(formatMarkName(markName)); 7728 }; 7729 7730 var clearMark = function (markName) { 7731 performance.clearMarks(formatMarkName(markName)); 7732 }; 7733 7734 var endMark = function (label, markName, warning$$1) { 7735 var formattedMarkName = formatMarkName(markName); 7736 var formattedLabel = formatLabel(label, warning$$1); 7737 try { 7738 performance.measure(formattedLabel, formattedMarkName); 7739 } catch (err) {} 7740 // If previous mark was missing for some reason, this will throw. 7741 // This could only happen if React crashed in an unexpected place earlier. 7742 // Don't pile on with more errors. 7743 7744 // Clear marks immediately to avoid growing buffer. 7745 performance.clearMarks(formattedMarkName); 7746 performance.clearMeasures(formattedLabel); 7747 }; 7748 7749 var getFiberMarkName = function (label, debugID) { 7750 return label + ' (#' + debugID + ')'; 7751 }; 7752 7753 var getFiberLabel = function (componentName, isMounted, phase) { 7754 if (phase === null) { 7755 // These are composite component total time measurements. 7756 return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']'; 7757 } else { 7758 // Composite component methods. 7759 return componentName + '.' + phase; 7760 } 7761 }; 7762 7763 var beginFiberMark = function (fiber, phase) { 7764 var componentName = getComponentName(fiber) || 'Unknown'; 7765 var debugID = fiber._debugID; 7766 var isMounted = fiber.alternate !== null; 7767 var label = getFiberLabel(componentName, isMounted, phase); 7768 7769 if (isCommitting && labelsInCurrentCommit.has(label)) { 7770 // During the commit phase, we don't show duplicate labels because 7771 // there is a fixed overhead for every measurement, and we don't 7772 // want to stretch the commit phase beyond necessary. 7773 return false; 7774 } 7775 labelsInCurrentCommit.add(label); 7776 7777 var markName = getFiberMarkName(label, debugID); 7778 beginMark(markName); 7779 return true; 7780 }; 7781 7782 var clearFiberMark = function (fiber, phase) { 7783 var componentName = getComponentName(fiber) || 'Unknown'; 7784 var debugID = fiber._debugID; 7785 var isMounted = fiber.alternate !== null; 7786 var label = getFiberLabel(componentName, isMounted, phase); 7787 var markName = getFiberMarkName(label, debugID); 7788 clearMark(markName); 7789 }; 7790 7791 var endFiberMark = function (fiber, phase, warning$$1) { 7792 var componentName = getComponentName(fiber) || 'Unknown'; 7793 var debugID = fiber._debugID; 7794 var isMounted = fiber.alternate !== null; 7795 var label = getFiberLabel(componentName, isMounted, phase); 7796 var markName = getFiberMarkName(label, debugID); 7797 endMark(label, markName, warning$$1); 7798 }; 7799 7800 var shouldIgnoreFiber = function (fiber) { 7801 // Host components should be skipped in the timeline. 7802 // We could check typeof fiber.type, but does this work with RN? 7803 switch (fiber.tag) { 7804 case HostRoot: 7805 case HostComponent: 7806 case HostText: 7807 case HostPortal: 7808 case ReturnComponent: 7809 case Fragment: 7810 return true; 7811 default: 7812 return false; 7813 } 7814 }; 7815 7816 var clearPendingPhaseMeasurement = function () { 7817 if (currentPhase !== null && currentPhaseFiber !== null) { 7818 clearFiberMark(currentPhaseFiber, currentPhase); 7819 } 7820 currentPhaseFiber = null; 7821 currentPhase = null; 7822 hasScheduledUpdateInCurrentPhase = false; 7823 }; 7824 7825 var pauseTimers = function () { 7826 // Stops all currently active measurements so that they can be resumed 7827 // if we continue in a later deferred loop from the same unit of work. 7828 var fiber = currentFiber; 7829 while (fiber) { 7830 if (fiber._debugIsCurrentlyTiming) { 7831 endFiberMark(fiber, null, null); 7832 } 7833 fiber = fiber['return']; 7834 } 7835 }; 7836 7837 var resumeTimersRecursively = function (fiber) { 7838 if (fiber['return'] !== null) { 7839 resumeTimersRecursively(fiber['return']); 7840 } 7841 if (fiber._debugIsCurrentlyTiming) { 7842 beginFiberMark(fiber, null); 7843 } 7844 }; 7845 7846 var resumeTimers = function () { 7847 // Resumes all measurements that were active during the last deferred loop. 7848 if (currentFiber !== null) { 7849 resumeTimersRecursively(currentFiber); 7850 } 7851 }; 7852 7853 function recordEffect() { 7854 if (enableUserTimingAPI) { 7855 effectCountInCurrentCommit++; 7856 } 7857 } 7858 7859 function recordScheduleUpdate() { 7860 if (enableUserTimingAPI) { 7861 if (isCommitting) { 7862 hasScheduledUpdateInCurrentCommit = true; 7863 } 7864 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { 7865 hasScheduledUpdateInCurrentPhase = true; 7866 } 7867 } 7868 } 7869 7870 function startRequestCallbackTimer() { 7871 if (enableUserTimingAPI) { 7872 if (supportsUserTiming && !isWaitingForCallback) { 7873 isWaitingForCallback = true; 7874 beginMark('(Waiting for async callback...)'); 7875 } 7876 } 7877 } 7878 7879 function stopRequestCallbackTimer(didExpire) { 7880 if (enableUserTimingAPI) { 7881 if (supportsUserTiming) { 7882 isWaitingForCallback = false; 7883 var warning$$1 = didExpire ? 'React was blocked by main thread' : null; 7884 endMark('(Waiting for async callback...)', '(Waiting for async callback...)', warning$$1); 7885 } 7886 } 7887 } 7888 7889 function startWorkTimer(fiber) { 7890 if (enableUserTimingAPI) { 7891 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 7892 return; 7893 } 7894 // If we pause, this is the fiber to unwind from. 7895 currentFiber = fiber; 7896 if (!beginFiberMark(fiber, null)) { 7897 return; 7898 } 7899 fiber._debugIsCurrentlyTiming = true; 7900 } 7901 } 7902 7903 function cancelWorkTimer(fiber) { 7904 if (enableUserTimingAPI) { 7905 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 7906 return; 7907 } 7908 // Remember we shouldn't complete measurement for this fiber. 7909 // Otherwise flamechart will be deep even for small updates. 7910 fiber._debugIsCurrentlyTiming = false; 7911 clearFiberMark(fiber, null); 7912 } 7913 } 7914 7915 function stopWorkTimer(fiber) { 7916 if (enableUserTimingAPI) { 7917 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 7918 return; 7919 } 7920 // If we pause, its parent is the fiber to unwind from. 7921 currentFiber = fiber['return']; 7922 if (!fiber._debugIsCurrentlyTiming) { 7923 return; 7924 } 7925 fiber._debugIsCurrentlyTiming = false; 7926 endFiberMark(fiber, null, null); 7927 } 7928 } 7929 7930 function stopFailedWorkTimer(fiber) { 7931 if (enableUserTimingAPI) { 7932 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 7933 return; 7934 } 7935 // If we pause, its parent is the fiber to unwind from. 7936 currentFiber = fiber['return']; 7937 if (!fiber._debugIsCurrentlyTiming) { 7938 return; 7939 } 7940 fiber._debugIsCurrentlyTiming = false; 7941 var warning$$1 = 'An error was thrown inside this error boundary'; 7942 endFiberMark(fiber, null, warning$$1); 7943 } 7944 } 7945 7946 function startPhaseTimer(fiber, phase) { 7947 if (enableUserTimingAPI) { 7948 if (!supportsUserTiming) { 7949 return; 7950 } 7951 clearPendingPhaseMeasurement(); 7952 if (!beginFiberMark(fiber, phase)) { 7953 return; 7954 } 7955 currentPhaseFiber = fiber; 7956 currentPhase = phase; 7957 } 7958 } 7959 7960 function stopPhaseTimer() { 7961 if (enableUserTimingAPI) { 7962 if (!supportsUserTiming) { 7963 return; 7964 } 7965 if (currentPhase !== null && currentPhaseFiber !== null) { 7966 var warning$$1 = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; 7967 endFiberMark(currentPhaseFiber, currentPhase, warning$$1); 7968 } 7969 currentPhase = null; 7970 currentPhaseFiber = null; 7971 } 7972 } 7973 7974 function startWorkLoopTimer(nextUnitOfWork) { 7975 if (enableUserTimingAPI) { 7976 currentFiber = nextUnitOfWork; 7977 if (!supportsUserTiming) { 7978 return; 7979 } 7980 commitCountInCurrentWorkLoop = 0; 7981 // This is top level call. 7982 // Any other measurements are performed within. 7983 beginMark('(React Tree Reconciliation)'); 7984 // Resume any measurements that were in progress during the last loop. 7985 resumeTimers(); 7986 } 7987 } 7988 7989 function stopWorkLoopTimer(interruptedBy) { 7990 if (enableUserTimingAPI) { 7991 if (!supportsUserTiming) { 7992 return; 7993 } 7994 var warning$$1 = null; 7995 if (interruptedBy !== null) { 7996 if (interruptedBy.tag === HostRoot) { 7997 warning$$1 = 'A top-level update interrupted the previous render'; 7998 } else { 7999 var componentName = getComponentName(interruptedBy) || 'Unknown'; 8000 warning$$1 = 'An update to ' + componentName + ' interrupted the previous render'; 8001 } 8002 } else if (commitCountInCurrentWorkLoop > 1) { 8003 warning$$1 = 'There were cascading updates'; 8004 } 8005 commitCountInCurrentWorkLoop = 0; 8006 // Pause any measurements until the next loop. 8007 pauseTimers(); 8008 endMark('(React Tree Reconciliation)', '(React Tree Reconciliation)', warning$$1); 8009 } 8010 } 8011 8012 function startCommitTimer() { 8013 if (enableUserTimingAPI) { 8014 if (!supportsUserTiming) { 8015 return; 8016 } 8017 isCommitting = true; 8018 hasScheduledUpdateInCurrentCommit = false; 8019 labelsInCurrentCommit.clear(); 8020 beginMark('(Committing Changes)'); 8021 } 8022 } 8023 8024 function stopCommitTimer() { 8025 if (enableUserTimingAPI) { 8026 if (!supportsUserTiming) { 8027 return; 8028 } 8029 8030 var warning$$1 = null; 8031 if (hasScheduledUpdateInCurrentCommit) { 8032 warning$$1 = 'Lifecycle hook scheduled a cascading update'; 8033 } else if (commitCountInCurrentWorkLoop > 0) { 8034 warning$$1 = 'Caused by a cascading update in earlier commit'; 8035 } 8036 hasScheduledUpdateInCurrentCommit = false; 8037 commitCountInCurrentWorkLoop++; 8038 isCommitting = false; 8039 labelsInCurrentCommit.clear(); 8040 8041 endMark('(Committing Changes)', '(Committing Changes)', warning$$1); 8042 } 8043 } 8044 8045 function startCommitHostEffectsTimer() { 8046 if (enableUserTimingAPI) { 8047 if (!supportsUserTiming) { 8048 return; 8049 } 8050 effectCountInCurrentCommit = 0; 8051 beginMark('(Committing Host Effects)'); 8052 } 8053 } 8054 8055 function stopCommitHostEffectsTimer() { 8056 if (enableUserTimingAPI) { 8057 if (!supportsUserTiming) { 8058 return; 8059 } 8060 var count = effectCountInCurrentCommit; 8061 effectCountInCurrentCommit = 0; 8062 endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null); 8063 } 8064 } 8065 8066 function startCommitLifeCyclesTimer() { 8067 if (enableUserTimingAPI) { 8068 if (!supportsUserTiming) { 8069 return; 8070 } 8071 effectCountInCurrentCommit = 0; 8072 beginMark('(Calling Lifecycle Methods)'); 8073 } 8074 } 8075 8076 function stopCommitLifeCyclesTimer() { 8077 if (enableUserTimingAPI) { 8078 if (!supportsUserTiming) { 8079 return; 8080 } 8081 var count = effectCountInCurrentCommit; 8082 effectCountInCurrentCommit = 0; 8083 endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null); 8084 } 8085 } 8086 8087 { 8088 var warnedAboutMissingGetChildContext = {}; 8089 } 8090 8091 // A cursor to the current merged context object on the stack. 8092 var contextStackCursor = createCursor(emptyObject); 8093 // A cursor to a boolean indicating whether the context has changed. 8094 var didPerformWorkStackCursor = createCursor(false); 8095 // Keep track of the previous context object that was on the stack. 8096 // We use this to get access to the parent context after we have already 8097 // pushed the next context provider, and now need to merge their contexts. 8098 var previousContext = emptyObject; 8099 8100 function getUnmaskedContext(workInProgress) { 8101 var hasOwnContext = isContextProvider(workInProgress); 8102 if (hasOwnContext) { 8103 // If the fiber is a context provider itself, when we read its context 8104 // we have already pushed its own child context on the stack. A context 8105 // provider should not "see" its own child context. Therefore we read the 8106 // previous (parent) context instead for a context provider. 8107 return previousContext; 8108 } 8109 return contextStackCursor.current; 8110 } 8111 8112 function cacheContext(workInProgress, unmaskedContext, maskedContext) { 8113 var instance = workInProgress.stateNode; 8114 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 8115 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 8116 } 8117 8118 function getMaskedContext(workInProgress, unmaskedContext) { 8119 var type = workInProgress.type; 8120 var contextTypes = type.contextTypes; 8121 if (!contextTypes) { 8122 return emptyObject; 8123 } 8124 8125 // Avoid recreating masked context unless unmasked context has changed. 8126 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 8127 // This may trigger infinite loops if componentWillReceiveProps calls setState. 8128 var instance = workInProgress.stateNode; 8129 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 8130 return instance.__reactInternalMemoizedMaskedChildContext; 8131 } 8132 8133 var context = {}; 8134 for (var key in contextTypes) { 8135 context[key] = unmaskedContext[key]; 8136 } 8137 8138 { 8139 var name = getComponentName(workInProgress) || 'Unknown'; 8140 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); 8141 } 8142 8143 // Cache unmasked context so we can avoid recreating masked context unless necessary. 8144 // Context is created before the class component is instantiated so check for instance. 8145 if (instance) { 8146 cacheContext(workInProgress, unmaskedContext, context); 8147 } 8148 8149 return context; 8150 } 8151 8152 function hasContextChanged() { 8153 return didPerformWorkStackCursor.current; 8154 } 8155 8156 function isContextConsumer(fiber) { 8157 return fiber.tag === ClassComponent && fiber.type.contextTypes != null; 8158 } 8159 8160 function isContextProvider(fiber) { 8161 return fiber.tag === ClassComponent && fiber.type.childContextTypes != null; 8162 } 8163 8164 function popContextProvider(fiber) { 8165 if (!isContextProvider(fiber)) { 8166 return; 8167 } 8168 8169 pop(didPerformWorkStackCursor, fiber); 8170 pop(contextStackCursor, fiber); 8171 } 8172 8173 function popTopLevelContextObject(fiber) { 8174 pop(didPerformWorkStackCursor, fiber); 8175 pop(contextStackCursor, fiber); 8176 } 8177 8178 function pushTopLevelContextObject(fiber, context, didChange) { 8179 !(contextStackCursor.cursor == null) ? invariant(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0; 8180 8181 push(contextStackCursor, context, fiber); 8182 push(didPerformWorkStackCursor, didChange, fiber); 8183 } 8184 8185 function processChildContext(fiber, parentContext) { 8186 var instance = fiber.stateNode; 8187 var childContextTypes = fiber.type.childContextTypes; 8188 8189 // TODO (bvaughn) Replace this behavior with an invariant() in the future. 8190 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 8191 if (typeof instance.getChildContext !== 'function') { 8192 { 8193 var componentName = getComponentName(fiber) || 'Unknown'; 8194 8195 if (!warnedAboutMissingGetChildContext[componentName]) { 8196 warnedAboutMissingGetChildContext[componentName] = true; 8197 warning(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); 8198 } 8199 } 8200 return parentContext; 8201 } 8202 8203 var childContext = void 0; 8204 { 8205 ReactDebugCurrentFiber.setCurrentPhase('getChildContext'); 8206 } 8207 startPhaseTimer(fiber, 'getChildContext'); 8208 childContext = instance.getChildContext(); 8209 stopPhaseTimer(); 8210 { 8211 ReactDebugCurrentFiber.setCurrentPhase(null); 8212 } 8213 for (var contextKey in childContext) { 8214 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0; 8215 } 8216 { 8217 var name = getComponentName(fiber) || 'Unknown'; 8218 checkPropTypes(childContextTypes, childContext, 'child context', name, 8219 // In practice, there is one case in which we won't get a stack. It's when 8220 // somebody calls unstable_renderSubtreeIntoContainer() and we process 8221 // context from the parent component instance. The stack will be missing 8222 // because it's outside of the reconciliation, and so the pointer has not 8223 // been set. This is rare and doesn't matter. We'll also remove that API. 8224 ReactDebugCurrentFiber.getCurrentFiberStackAddendum); 8225 } 8226 8227 return _assign({}, parentContext, childContext); 8228 } 8229 8230 function pushContextProvider(workInProgress) { 8231 if (!isContextProvider(workInProgress)) { 8232 return false; 8233 } 8234 8235 var instance = workInProgress.stateNode; 8236 // We push the context as early as possible to ensure stack integrity. 8237 // If the instance does not exist yet, we will push null at first, 8238 // and replace it on the stack later when invalidating the context. 8239 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyObject; 8240 8241 // Remember the parent context so we can merge with it later. 8242 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 8243 previousContext = contextStackCursor.current; 8244 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 8245 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 8246 8247 return true; 8248 } 8249 8250 function invalidateContextProvider(workInProgress, didChange) { 8251 var instance = workInProgress.stateNode; 8252 !instance ? invariant(false, 'Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.') : void 0; 8253 8254 if (didChange) { 8255 // Merge parent and own context. 8256 // Skip this if we're not updating due to sCU. 8257 // This avoids unnecessarily recomputing memoized values. 8258 var mergedContext = processChildContext(workInProgress, previousContext); 8259 instance.__reactInternalMemoizedMergedChildContext = mergedContext; 8260 8261 // Replace the old (or empty) context with the new one. 8262 // It is important to unwind the context in the reverse order. 8263 pop(didPerformWorkStackCursor, workInProgress); 8264 pop(contextStackCursor, workInProgress); 8265 // Now push the new context and mark that it has changed. 8266 push(contextStackCursor, mergedContext, workInProgress); 8267 push(didPerformWorkStackCursor, didChange, workInProgress); 8268 } else { 8269 pop(didPerformWorkStackCursor, workInProgress); 8270 push(didPerformWorkStackCursor, didChange, workInProgress); 8271 } 8272 } 8273 8274 function resetContext() { 8275 previousContext = emptyObject; 8276 contextStackCursor.current = emptyObject; 8277 didPerformWorkStackCursor.current = false; 8278 } 8279 8280 function findCurrentUnmaskedContext(fiber) { 8281 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 8282 // makes sense elsewhere 8283 !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0; 8284 8285 var node = fiber; 8286 while (node.tag !== HostRoot) { 8287 if (isContextProvider(node)) { 8288 return node.stateNode.__reactInternalMemoizedMergedChildContext; 8289 } 8290 var parent = node['return']; 8291 !parent ? invariant(false, 'Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.') : void 0; 8292 node = parent; 8293 } 8294 return node.stateNode.context; 8295 } 8296 8297 var NoWork = 0; // TODO: Use an opaque type once ESLint et al support the syntax 8298 8299 var Sync = 1; 8300 var Never = 2147483647; // Max int32: Math.pow(2, 31) - 1 8301 8302 var UNIT_SIZE = 10; 8303 var MAGIC_NUMBER_OFFSET = 2; 8304 8305 // 1 unit of expiration time represents 10ms. 8306 function msToExpirationTime(ms) { 8307 // Always add an offset so that we don't clash with the magic number for NoWork. 8308 return (ms / UNIT_SIZE | 0) + MAGIC_NUMBER_OFFSET; 8309 } 8310 8311 function expirationTimeToMs(expirationTime) { 8312 return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; 8313 } 8314 8315 function ceiling(num, precision) { 8316 return ((num / precision | 0) + 1) * precision; 8317 } 8318 8319 function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { 8320 return ceiling(currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE); 8321 } 8322 8323 var NoContext = 0; 8324 var AsyncUpdates = 1; 8325 8326 { 8327 var hasBadMapPolyfill = false; 8328 try { 8329 var nonExtensibleObject = Object.preventExtensions({}); 8330 /* eslint-disable no-new */ 8331 8332 /* eslint-enable no-new */ 8333 } catch (e) { 8334 // TODO: Consider warning about bad polyfills 8335 hasBadMapPolyfill = true; 8336 } 8337 } 8338 8339 // A Fiber is work on a Component that needs to be done or was done. There can 8340 // be more than one per component. 8341 8342 8343 { 8344 var debugCounter = 1; 8345 } 8346 8347 function FiberNode(tag, key, internalContextTag) { 8348 // Instance 8349 this.tag = tag; 8350 this.key = key; 8351 this.type = null; 8352 this.stateNode = null; 8353 8354 // Fiber 8355 this['return'] = null; 8356 this.child = null; 8357 this.sibling = null; 8358 this.index = 0; 8359 8360 this.ref = null; 8361 8362 this.pendingProps = null; 8363 this.memoizedProps = null; 8364 this.updateQueue = null; 8365 this.memoizedState = null; 8366 8367 this.internalContextTag = internalContextTag; 8368 8369 // Effects 8370 this.effectTag = NoEffect; 8371 this.nextEffect = null; 8372 8373 this.firstEffect = null; 8374 this.lastEffect = null; 8375 8376 this.expirationTime = NoWork; 8377 8378 this.alternate = null; 8379 8380 { 8381 this._debugID = debugCounter++; 8382 this._debugSource = null; 8383 this._debugOwner = null; 8384 this._debugIsCurrentlyTiming = false; 8385 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 8386 Object.preventExtensions(this); 8387 } 8388 } 8389 } 8390 8391 // This is a constructor function, rather than a POJO constructor, still 8392 // please ensure we do the following: 8393 // 1) Nobody should add any instance methods on this. Instance methods can be 8394 // more difficult to predict when they get optimized and they are almost 8395 // never inlined properly in static compilers. 8396 // 2) Nobody should rely on `instanceof Fiber` for type testing. We should 8397 // always know when it is a fiber. 8398 // 3) We might want to experiment with using numeric keys since they are easier 8399 // to optimize in a non-JIT environment. 8400 // 4) We can easily go from a constructor to a createFiber object literal if that 8401 // is faster. 8402 // 5) It should be easy to port this to a C struct and keep a C implementation 8403 // compatible. 8404 var createFiber = function (tag, key, internalContextTag) { 8405 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 8406 return new FiberNode(tag, key, internalContextTag); 8407 }; 8408 8409 function shouldConstruct(Component) { 8410 return !!(Component.prototype && Component.prototype.isReactComponent); 8411 } 8412 8413 // This is used to create an alternate fiber to do work on. 8414 function createWorkInProgress(current, pendingProps, expirationTime) { 8415 var workInProgress = current.alternate; 8416 if (workInProgress === null) { 8417 // We use a double buffering pooling technique because we know that we'll 8418 // only ever need at most two versions of a tree. We pool the "other" unused 8419 // node that we're free to reuse. This is lazily created to avoid allocating 8420 // extra objects for things that are never updated. It also allow us to 8421 // reclaim the extra memory if needed. 8422 workInProgress = createFiber(current.tag, current.key, current.internalContextTag); 8423 workInProgress.type = current.type; 8424 workInProgress.stateNode = current.stateNode; 8425 8426 { 8427 // DEV-only fields 8428 workInProgress._debugID = current._debugID; 8429 workInProgress._debugSource = current._debugSource; 8430 workInProgress._debugOwner = current._debugOwner; 8431 } 8432 8433 workInProgress.alternate = current; 8434 current.alternate = workInProgress; 8435 } else { 8436 // We already have an alternate. 8437 // Reset the effect tag. 8438 workInProgress.effectTag = NoEffect; 8439 8440 // The effect list is no longer valid. 8441 workInProgress.nextEffect = null; 8442 workInProgress.firstEffect = null; 8443 workInProgress.lastEffect = null; 8444 } 8445 8446 workInProgress.expirationTime = expirationTime; 8447 workInProgress.pendingProps = pendingProps; 8448 8449 workInProgress.child = current.child; 8450 workInProgress.memoizedProps = current.memoizedProps; 8451 workInProgress.memoizedState = current.memoizedState; 8452 workInProgress.updateQueue = current.updateQueue; 8453 8454 // These will be overridden during the parent's reconciliation 8455 workInProgress.sibling = current.sibling; 8456 workInProgress.index = current.index; 8457 workInProgress.ref = current.ref; 8458 8459 return workInProgress; 8460 } 8461 8462 function createHostRootFiber() { 8463 var fiber = createFiber(HostRoot, null, NoContext); 8464 return fiber; 8465 } 8466 8467 function createFiberFromElement(element, internalContextTag, expirationTime) { 8468 var owner = null; 8469 { 8470 owner = element._owner; 8471 } 8472 8473 var fiber = void 0; 8474 var type = element.type, 8475 key = element.key; 8476 8477 if (typeof type === 'function') { 8478 fiber = shouldConstruct(type) ? createFiber(ClassComponent, key, internalContextTag) : createFiber(IndeterminateComponent, key, internalContextTag); 8479 fiber.type = type; 8480 fiber.pendingProps = element.props; 8481 } else if (typeof type === 'string') { 8482 fiber = createFiber(HostComponent, key, internalContextTag); 8483 fiber.type = type; 8484 fiber.pendingProps = element.props; 8485 } else if (typeof type === 'object' && type !== null && typeof type.tag === 'number') { 8486 // Currently assumed to be a continuation and therefore is a fiber already. 8487 // TODO: The yield system is currently broken for updates in some cases. 8488 // The reified yield stores a fiber, but we don't know which fiber that is; 8489 // the current or a workInProgress? When the continuation gets rendered here 8490 // we don't know if we can reuse that fiber or if we need to clone it. 8491 // There is probably a clever way to restructure this. 8492 fiber = type; 8493 fiber.pendingProps = element.props; 8494 } else { 8495 var info = ''; 8496 { 8497 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 8498 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; 8499 } 8500 var ownerName = owner ? getComponentName(owner) : null; 8501 if (ownerName) { 8502 info += '\n\nCheck the render method of `' + ownerName + '`.'; 8503 } 8504 } 8505 invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info); 8506 } 8507 8508 { 8509 fiber._debugSource = element._source; 8510 fiber._debugOwner = element._owner; 8511 } 8512 8513 fiber.expirationTime = expirationTime; 8514 8515 return fiber; 8516 } 8517 8518 function createFiberFromFragment(elements, internalContextTag, expirationTime, key) { 8519 var fiber = createFiber(Fragment, key, internalContextTag); 8520 fiber.pendingProps = elements; 8521 fiber.expirationTime = expirationTime; 8522 return fiber; 8523 } 8524 8525 function createFiberFromText(content, internalContextTag, expirationTime) { 8526 var fiber = createFiber(HostText, null, internalContextTag); 8527 fiber.pendingProps = content; 8528 fiber.expirationTime = expirationTime; 8529 return fiber; 8530 } 8531 8532 function createFiberFromHostInstanceForDeletion() { 8533 var fiber = createFiber(HostComponent, null, NoContext); 8534 fiber.type = 'DELETED'; 8535 return fiber; 8536 } 8537 8538 function createFiberFromCall(call, internalContextTag, expirationTime) { 8539 var fiber = createFiber(CallComponent, call.key, internalContextTag); 8540 fiber.type = call.handler; 8541 fiber.pendingProps = call; 8542 fiber.expirationTime = expirationTime; 8543 return fiber; 8544 } 8545 8546 function createFiberFromReturn(returnNode, internalContextTag, expirationTime) { 8547 var fiber = createFiber(ReturnComponent, null, internalContextTag); 8548 fiber.expirationTime = expirationTime; 8549 return fiber; 8550 } 8551 8552 function createFiberFromPortal(portal, internalContextTag, expirationTime) { 8553 var fiber = createFiber(HostPortal, portal.key, internalContextTag); 8554 fiber.pendingProps = portal.children || []; 8555 fiber.expirationTime = expirationTime; 8556 fiber.stateNode = { 8557 containerInfo: portal.containerInfo, 8558 pendingChildren: null, // Used by persistent updates 8559 implementation: portal.implementation 8560 }; 8561 return fiber; 8562 } 8563 8564 function createFiberRoot(containerInfo, hydrate) { 8565 // Cyclic construction. This cheats the type system right now because 8566 // stateNode is any. 8567 var uninitializedFiber = createHostRootFiber(); 8568 var root = { 8569 current: uninitializedFiber, 8570 containerInfo: containerInfo, 8571 pendingChildren: null, 8572 remainingExpirationTime: NoWork, 8573 isReadyForCommit: false, 8574 finishedWork: null, 8575 context: null, 8576 pendingContext: null, 8577 hydrate: hydrate, 8578 nextScheduledRoot: null 8579 }; 8580 uninitializedFiber.stateNode = root; 8581 return root; 8582 } 8583 8584 var onCommitFiberRoot = null; 8585 var onCommitFiberUnmount = null; 8586 var hasLoggedError = false; 8587 8588 function catchErrors(fn) { 8589 return function (arg) { 8590 try { 8591 return fn(arg); 8592 } catch (err) { 8593 if (true && !hasLoggedError) { 8594 hasLoggedError = true; 8595 warning(false, 'React DevTools encountered an error: %s', err); 8596 } 8597 } 8598 }; 8599 } 8600 8601 function injectInternals(internals) { 8602 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 8603 // No DevTools 8604 return false; 8605 } 8606 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 8607 if (hook.isDisabled) { 8608 // This isn't a real property on the hook, but it can be set to opt out 8609 // of DevTools integration and associated warnings and logs. 8610 // https://github.com/facebook/react/issues/3877 8611 return true; 8612 } 8613 if (!hook.supportsFiber) { 8614 { 8615 warning(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools'); 8616 } 8617 // DevTools exists, even though it doesn't support Fiber. 8618 return true; 8619 } 8620 try { 8621 var rendererID = hook.inject(internals); 8622 // We have successfully injected, so now it is safe to set up hooks. 8623 onCommitFiberRoot = catchErrors(function (root) { 8624 return hook.onCommitFiberRoot(rendererID, root); 8625 }); 8626 onCommitFiberUnmount = catchErrors(function (fiber) { 8627 return hook.onCommitFiberUnmount(rendererID, fiber); 8628 }); 8629 } catch (err) { 8630 // Catch all errors because it is unsafe to throw during initialization. 8631 { 8632 warning(false, 'React DevTools encountered an error: %s.', err); 8633 } 8634 } 8635 // DevTools exists 8636 return true; 8637 } 8638 8639 function onCommitRoot(root) { 8640 if (typeof onCommitFiberRoot === 'function') { 8641 onCommitFiberRoot(root); 8642 } 8643 } 8644 8645 function onCommitUnmount(fiber) { 8646 if (typeof onCommitFiberUnmount === 'function') { 8647 onCommitFiberUnmount(fiber); 8648 } 8649 } 8650 8651 { 8652 var didWarnUpdateInsideUpdate = false; 8653 } 8654 8655 // Callbacks are not validated until invocation 8656 8657 8658 // Singly linked-list of updates. When an update is scheduled, it is added to 8659 // the queue of the current fiber and the work-in-progress fiber. The two queues 8660 // are separate but they share a persistent structure. 8661 // 8662 // During reconciliation, updates are removed from the work-in-progress fiber, 8663 // but they remain on the current fiber. That ensures that if a work-in-progress 8664 // is aborted, the aborted updates are recovered by cloning from current. 8665 // 8666 // The work-in-progress queue is always a subset of the current queue. 8667 // 8668 // When the tree is committed, the work-in-progress becomes the current. 8669 8670 8671 function createUpdateQueue(baseState) { 8672 var queue = { 8673 baseState: baseState, 8674 expirationTime: NoWork, 8675 first: null, 8676 last: null, 8677 callbackList: null, 8678 hasForceUpdate: false, 8679 isInitialized: false 8680 }; 8681 { 8682 queue.isProcessing = false; 8683 } 8684 return queue; 8685 } 8686 8687 function insertUpdateIntoQueue(queue, update) { 8688 // Append the update to the end of the list. 8689 if (queue.last === null) { 8690 // Queue is empty 8691 queue.first = queue.last = update; 8692 } else { 8693 queue.last.next = update; 8694 queue.last = update; 8695 } 8696 if (queue.expirationTime === NoWork || queue.expirationTime > update.expirationTime) { 8697 queue.expirationTime = update.expirationTime; 8698 } 8699 } 8700 8701 function insertUpdateIntoFiber(fiber, update) { 8702 // We'll have at least one and at most two distinct update queues. 8703 var alternateFiber = fiber.alternate; 8704 var queue1 = fiber.updateQueue; 8705 if (queue1 === null) { 8706 // TODO: We don't know what the base state will be until we begin work. 8707 // It depends on which fiber is the next current. Initialize with an empty 8708 // base state, then set to the memoizedState when rendering. Not super 8709 // happy with this approach. 8710 queue1 = fiber.updateQueue = createUpdateQueue(null); 8711 } 8712 8713 var queue2 = void 0; 8714 if (alternateFiber !== null) { 8715 queue2 = alternateFiber.updateQueue; 8716 if (queue2 === null) { 8717 queue2 = alternateFiber.updateQueue = createUpdateQueue(null); 8718 } 8719 } else { 8720 queue2 = null; 8721 } 8722 queue2 = queue2 !== queue1 ? queue2 : null; 8723 8724 // Warn if an update is scheduled from inside an updater function. 8725 { 8726 if ((queue1.isProcessing || queue2 !== null && queue2.isProcessing) && !didWarnUpdateInsideUpdate) { 8727 warning(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); 8728 didWarnUpdateInsideUpdate = true; 8729 } 8730 } 8731 8732 // If there's only one queue, add the update to that queue and exit. 8733 if (queue2 === null) { 8734 insertUpdateIntoQueue(queue1, update); 8735 return; 8736 } 8737 8738 // If either queue is empty, we need to add to both queues. 8739 if (queue1.last === null || queue2.last === null) { 8740 insertUpdateIntoQueue(queue1, update); 8741 insertUpdateIntoQueue(queue2, update); 8742 return; 8743 } 8744 8745 // If both lists are not empty, the last update is the same for both lists 8746 // because of structural sharing. So, we should only append to one of 8747 // the lists. 8748 insertUpdateIntoQueue(queue1, update); 8749 // But we still need to update the `last` pointer of queue2. 8750 queue2.last = update; 8751 } 8752 8753 function getUpdateExpirationTime(fiber) { 8754 if (fiber.tag !== ClassComponent && fiber.tag !== HostRoot) { 8755 return NoWork; 8756 } 8757 var updateQueue = fiber.updateQueue; 8758 if (updateQueue === null) { 8759 return NoWork; 8760 } 8761 return updateQueue.expirationTime; 8762 } 8763 8764 function getStateFromUpdate(update, instance, prevState, props) { 8765 var partialState = update.partialState; 8766 if (typeof partialState === 'function') { 8767 var updateFn = partialState; 8768 8769 // Invoke setState callback an extra time to help detect side-effects. 8770 if (debugRenderPhaseSideEffects) { 8771 updateFn.call(instance, prevState, props); 8772 } 8773 8774 return updateFn.call(instance, prevState, props); 8775 } else { 8776 return partialState; 8777 } 8778 } 8779 8780 function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { 8781 if (current !== null && current.updateQueue === queue) { 8782 // We need to create a work-in-progress queue, by cloning the current queue. 8783 var currentQueue = queue; 8784 queue = workInProgress.updateQueue = { 8785 baseState: currentQueue.baseState, 8786 expirationTime: currentQueue.expirationTime, 8787 first: currentQueue.first, 8788 last: currentQueue.last, 8789 isInitialized: currentQueue.isInitialized, 8790 // These fields are no longer valid because they were already committed. 8791 // Reset them. 8792 callbackList: null, 8793 hasForceUpdate: false 8794 }; 8795 } 8796 8797 { 8798 // Set this flag so we can warn if setState is called inside the update 8799 // function of another setState. 8800 queue.isProcessing = true; 8801 } 8802 8803 // Reset the remaining expiration time. If we skip over any updates, we'll 8804 // increase this accordingly. 8805 queue.expirationTime = NoWork; 8806 8807 // TODO: We don't know what the base state will be until we begin work. 8808 // It depends on which fiber is the next current. Initialize with an empty 8809 // base state, then set to the memoizedState when rendering. Not super 8810 // happy with this approach. 8811 var state = void 0; 8812 if (queue.isInitialized) { 8813 state = queue.baseState; 8814 } else { 8815 state = queue.baseState = workInProgress.memoizedState; 8816 queue.isInitialized = true; 8817 } 8818 var dontMutatePrevState = true; 8819 var update = queue.first; 8820 var didSkip = false; 8821 while (update !== null) { 8822 var updateExpirationTime = update.expirationTime; 8823 if (updateExpirationTime > renderExpirationTime) { 8824 // This update does not have sufficient priority. Skip it. 8825 var remainingExpirationTime = queue.expirationTime; 8826 if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { 8827 // Update the remaining expiration time. 8828 queue.expirationTime = updateExpirationTime; 8829 } 8830 if (!didSkip) { 8831 didSkip = true; 8832 queue.baseState = state; 8833 } 8834 // Continue to the next update. 8835 update = update.next; 8836 continue; 8837 } 8838 8839 // This update does have sufficient priority. 8840 8841 // If no previous updates were skipped, drop this update from the queue by 8842 // advancing the head of the list. 8843 if (!didSkip) { 8844 queue.first = update.next; 8845 if (queue.first === null) { 8846 queue.last = null; 8847 } 8848 } 8849 8850 // Process the update 8851 var _partialState = void 0; 8852 if (update.isReplace) { 8853 state = getStateFromUpdate(update, instance, state, props); 8854 dontMutatePrevState = true; 8855 } else { 8856 _partialState = getStateFromUpdate(update, instance, state, props); 8857 if (_partialState) { 8858 if (dontMutatePrevState) { 8859 // $FlowFixMe: Idk how to type this properly. 8860 state = _assign({}, state, _partialState); 8861 } else { 8862 state = _assign(state, _partialState); 8863 } 8864 dontMutatePrevState = false; 8865 } 8866 } 8867 if (update.isForced) { 8868 queue.hasForceUpdate = true; 8869 } 8870 if (update.callback !== null) { 8871 // Append to list of callbacks. 8872 var _callbackList = queue.callbackList; 8873 if (_callbackList === null) { 8874 _callbackList = queue.callbackList = []; 8875 } 8876 _callbackList.push(update); 8877 } 8878 update = update.next; 8879 } 8880 8881 if (queue.callbackList !== null) { 8882 workInProgress.effectTag |= Callback; 8883 } else if (queue.first === null && !queue.hasForceUpdate) { 8884 // The queue is empty. We can reset it. 8885 workInProgress.updateQueue = null; 8886 } 8887 8888 if (!didSkip) { 8889 didSkip = true; 8890 queue.baseState = state; 8891 } 8892 8893 { 8894 // No longer processing. 8895 queue.isProcessing = false; 8896 } 8897 8898 return state; 8899 } 8900 8901 function commitCallbacks(queue, context) { 8902 var callbackList = queue.callbackList; 8903 if (callbackList === null) { 8904 return; 8905 } 8906 // Set the list to null to make sure they don't get called more than once. 8907 queue.callbackList = null; 8908 for (var i = 0; i < callbackList.length; i++) { 8909 var update = callbackList[i]; 8910 var _callback = update.callback; 8911 // This update might be processed again. Clear the callback so it's only 8912 // called once. 8913 update.callback = null; 8914 !(typeof _callback === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback) : void 0; 8915 _callback.call(context); 8916 } 8917 } 8918 8919 var fakeInternalInstance = {}; 8920 var isArray = Array.isArray; 8921 8922 { 8923 var didWarnAboutStateAssignmentForComponent = {}; 8924 8925 var warnOnInvalidCallback = function (callback, callerName) { 8926 warning(callback === null || typeof callback === 'function', '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 8927 }; 8928 8929 // This is so gross but it's at least non-critical and can be removed if 8930 // it causes problems. This is meant to give a nicer error message for 8931 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 8932 // ...)) which otherwise throws a "_processChildContext is not a function" 8933 // exception. 8934 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 8935 enumerable: false, 8936 value: function () { 8937 invariant(false, '_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn\'t supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).'); 8938 } 8939 }); 8940 Object.freeze(fakeInternalInstance); 8941 } 8942 8943 var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber, memoizeProps, memoizeState) { 8944 // Class component state updater 8945 var updater = { 8946 isMounted: isMounted, 8947 enqueueSetState: function (instance, partialState, callback) { 8948 var fiber = get(instance); 8949 callback = callback === undefined ? null : callback; 8950 { 8951 warnOnInvalidCallback(callback, 'setState'); 8952 } 8953 var expirationTime = computeExpirationForFiber(fiber); 8954 var update = { 8955 expirationTime: expirationTime, 8956 partialState: partialState, 8957 callback: callback, 8958 isReplace: false, 8959 isForced: false, 8960 nextCallback: null, 8961 next: null 8962 }; 8963 insertUpdateIntoFiber(fiber, update); 8964 scheduleWork(fiber, expirationTime); 8965 }, 8966 enqueueReplaceState: function (instance, state, callback) { 8967 var fiber = get(instance); 8968 callback = callback === undefined ? null : callback; 8969 { 8970 warnOnInvalidCallback(callback, 'replaceState'); 8971 } 8972 var expirationTime = computeExpirationForFiber(fiber); 8973 var update = { 8974 expirationTime: expirationTime, 8975 partialState: state, 8976 callback: callback, 8977 isReplace: true, 8978 isForced: false, 8979 nextCallback: null, 8980 next: null 8981 }; 8982 insertUpdateIntoFiber(fiber, update); 8983 scheduleWork(fiber, expirationTime); 8984 }, 8985 enqueueForceUpdate: function (instance, callback) { 8986 var fiber = get(instance); 8987 callback = callback === undefined ? null : callback; 8988 { 8989 warnOnInvalidCallback(callback, 'forceUpdate'); 8990 } 8991 var expirationTime = computeExpirationForFiber(fiber); 8992 var update = { 8993 expirationTime: expirationTime, 8994 partialState: null, 8995 callback: callback, 8996 isReplace: false, 8997 isForced: true, 8998 nextCallback: null, 8999 next: null 9000 }; 9001 insertUpdateIntoFiber(fiber, update); 9002 scheduleWork(fiber, expirationTime); 9003 } 9004 }; 9005 9006 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) { 9007 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) { 9008 // If the workInProgress already has an Update effect, return true 9009 return true; 9010 } 9011 9012 var instance = workInProgress.stateNode; 9013 var type = workInProgress.type; 9014 if (typeof instance.shouldComponentUpdate === 'function') { 9015 startPhaseTimer(workInProgress, 'shouldComponentUpdate'); 9016 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext); 9017 stopPhaseTimer(); 9018 9019 // Simulate an async bailout/interruption by invoking lifecycle twice. 9020 if (debugRenderPhaseSideEffects) { 9021 instance.shouldComponentUpdate(newProps, newState, newContext); 9022 } 9023 9024 { 9025 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown'); 9026 } 9027 9028 return shouldUpdate; 9029 } 9030 9031 if (type.prototype && type.prototype.isPureReactComponent) { 9032 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 9033 } 9034 9035 return true; 9036 } 9037 9038 function checkClassInstance(workInProgress) { 9039 var instance = workInProgress.stateNode; 9040 var type = workInProgress.type; 9041 { 9042 var name = getComponentName(workInProgress); 9043 var renderPresent = instance.render; 9044 9045 if (!renderPresent) { 9046 if (type.prototype && typeof type.prototype.render === 'function') { 9047 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 9048 } else { 9049 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 9050 } 9051 } 9052 9053 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state; 9054 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); 9055 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved; 9056 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); 9057 var noInstancePropTypes = !instance.propTypes; 9058 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); 9059 var noInstanceContextTypes = !instance.contextTypes; 9060 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); 9061 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function'; 9062 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); 9063 if (type.prototype && type.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 9064 warning(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(workInProgress) || 'A pure component'); 9065 } 9066 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function'; 9067 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); 9068 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function'; 9069 warning(noComponentDidReceiveProps, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); 9070 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function'; 9071 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); 9072 var hasMutatedProps = instance.props !== workInProgress.pendingProps; 9073 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); 9074 var noInstanceDefaultProps = !instance.defaultProps; 9075 warning(noInstanceDefaultProps, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); 9076 } 9077 9078 var state = instance.state; 9079 if (state && (typeof state !== 'object' || isArray(state))) { 9080 warning(false, '%s.state: must be set to an object or null', getComponentName(workInProgress)); 9081 } 9082 if (typeof instance.getChildContext === 'function') { 9083 warning(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress)); 9084 } 9085 } 9086 9087 function resetInputPointers(workInProgress, instance) { 9088 instance.props = workInProgress.memoizedProps; 9089 instance.state = workInProgress.memoizedState; 9090 } 9091 9092 function adoptClassInstance(workInProgress, instance) { 9093 instance.updater = updater; 9094 workInProgress.stateNode = instance; 9095 // The instance needs access to the fiber so that it can schedule updates 9096 set(instance, workInProgress); 9097 { 9098 instance._reactInternalInstance = fakeInternalInstance; 9099 } 9100 } 9101 9102 function constructClassInstance(workInProgress, props) { 9103 var ctor = workInProgress.type; 9104 var unmaskedContext = getUnmaskedContext(workInProgress); 9105 var needsContext = isContextConsumer(workInProgress); 9106 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject; 9107 var instance = new ctor(props, context); 9108 adoptClassInstance(workInProgress, instance); 9109 9110 // Cache unmasked context so we can avoid recreating masked context unless necessary. 9111 // ReactFiberContext usually updates this cache but can't for newly-created instances. 9112 if (needsContext) { 9113 cacheContext(workInProgress, unmaskedContext, context); 9114 } 9115 9116 return instance; 9117 } 9118 9119 function callComponentWillMount(workInProgress, instance) { 9120 startPhaseTimer(workInProgress, 'componentWillMount'); 9121 var oldState = instance.state; 9122 instance.componentWillMount(); 9123 stopPhaseTimer(); 9124 9125 // Simulate an async bailout/interruption by invoking lifecycle twice. 9126 if (debugRenderPhaseSideEffects) { 9127 instance.componentWillMount(); 9128 } 9129 9130 if (oldState !== instance.state) { 9131 { 9132 warning(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress)); 9133 } 9134 updater.enqueueReplaceState(instance, instance.state, null); 9135 } 9136 } 9137 9138 function callComponentWillReceiveProps(workInProgress, instance, newProps, newContext) { 9139 startPhaseTimer(workInProgress, 'componentWillReceiveProps'); 9140 var oldState = instance.state; 9141 instance.componentWillReceiveProps(newProps, newContext); 9142 stopPhaseTimer(); 9143 9144 // Simulate an async bailout/interruption by invoking lifecycle twice. 9145 if (debugRenderPhaseSideEffects) { 9146 instance.componentWillReceiveProps(newProps, newContext); 9147 } 9148 9149 if (instance.state !== oldState) { 9150 { 9151 var componentName = getComponentName(workInProgress) || 'Component'; 9152 if (!didWarnAboutStateAssignmentForComponent[componentName]) { 9153 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 9154 didWarnAboutStateAssignmentForComponent[componentName] = true; 9155 } 9156 } 9157 updater.enqueueReplaceState(instance, instance.state, null); 9158 } 9159 } 9160 9161 // Invokes the mount life-cycles on a previously never rendered instance. 9162 function mountClassInstance(workInProgress, renderExpirationTime) { 9163 var current = workInProgress.alternate; 9164 9165 { 9166 checkClassInstance(workInProgress); 9167 } 9168 9169 var instance = workInProgress.stateNode; 9170 var state = instance.state || null; 9171 9172 var props = workInProgress.pendingProps; 9173 !props ? invariant(false, 'There must be pending props for an initial mount. This error is likely caused by a bug in React. Please file an issue.') : void 0; 9174 9175 var unmaskedContext = getUnmaskedContext(workInProgress); 9176 9177 instance.props = props; 9178 instance.state = workInProgress.memoizedState = state; 9179 instance.refs = emptyObject; 9180 instance.context = getMaskedContext(workInProgress, unmaskedContext); 9181 9182 if (enableAsyncSubtreeAPI && workInProgress.type != null && workInProgress.type.prototype != null && workInProgress.type.prototype.unstable_isAsyncReactComponent === true) { 9183 workInProgress.internalContextTag |= AsyncUpdates; 9184 } 9185 9186 if (typeof instance.componentWillMount === 'function') { 9187 callComponentWillMount(workInProgress, instance); 9188 // If we had additional state updates during this life-cycle, let's 9189 // process them now. 9190 var updateQueue = workInProgress.updateQueue; 9191 if (updateQueue !== null) { 9192 instance.state = processUpdateQueue(current, workInProgress, updateQueue, instance, props, renderExpirationTime); 9193 } 9194 } 9195 if (typeof instance.componentDidMount === 'function') { 9196 workInProgress.effectTag |= Update; 9197 } 9198 } 9199 9200 // Called on a preexisting class instance. Returns false if a resumed render 9201 // could be reused. 9202 // function resumeMountClassInstance( 9203 // workInProgress: Fiber, 9204 // priorityLevel: PriorityLevel, 9205 // ): boolean { 9206 // const instance = workInProgress.stateNode; 9207 // resetInputPointers(workInProgress, instance); 9208 9209 // let newState = workInProgress.memoizedState; 9210 // let newProps = workInProgress.pendingProps; 9211 // if (!newProps) { 9212 // // If there isn't any new props, then we'll reuse the memoized props. 9213 // // This could be from already completed work. 9214 // newProps = workInProgress.memoizedProps; 9215 // invariant( 9216 // newProps != null, 9217 // 'There should always be pending or memoized props. This error is ' + 9218 // 'likely caused by a bug in React. Please file an issue.', 9219 // ); 9220 // } 9221 // const newUnmaskedContext = getUnmaskedContext(workInProgress); 9222 // const newContext = getMaskedContext(workInProgress, newUnmaskedContext); 9223 9224 // const oldContext = instance.context; 9225 // const oldProps = workInProgress.memoizedProps; 9226 9227 // if ( 9228 // typeof instance.componentWillReceiveProps === 'function' && 9229 // (oldProps !== newProps || oldContext !== newContext) 9230 // ) { 9231 // callComponentWillReceiveProps( 9232 // workInProgress, 9233 // instance, 9234 // newProps, 9235 // newContext, 9236 // ); 9237 // } 9238 9239 // // Process the update queue before calling shouldComponentUpdate 9240 // const updateQueue = workInProgress.updateQueue; 9241 // if (updateQueue !== null) { 9242 // newState = processUpdateQueue( 9243 // workInProgress, 9244 // updateQueue, 9245 // instance, 9246 // newState, 9247 // newProps, 9248 // priorityLevel, 9249 // ); 9250 // } 9251 9252 // // TODO: Should we deal with a setState that happened after the last 9253 // // componentWillMount and before this componentWillMount? Probably 9254 // // unsupported anyway. 9255 9256 // if ( 9257 // !checkShouldComponentUpdate( 9258 // workInProgress, 9259 // workInProgress.memoizedProps, 9260 // newProps, 9261 // workInProgress.memoizedState, 9262 // newState, 9263 // newContext, 9264 // ) 9265 // ) { 9266 // // Update the existing instance's state, props, and context pointers even 9267 // // though we're bailing out. 9268 // instance.props = newProps; 9269 // instance.state = newState; 9270 // instance.context = newContext; 9271 // return false; 9272 // } 9273 9274 // // Update the input pointers now so that they are correct when we call 9275 // // componentWillMount 9276 // instance.props = newProps; 9277 // instance.state = newState; 9278 // instance.context = newContext; 9279 9280 // if (typeof instance.componentWillMount === 'function') { 9281 // callComponentWillMount(workInProgress, instance); 9282 // // componentWillMount may have called setState. Process the update queue. 9283 // const newUpdateQueue = workInProgress.updateQueue; 9284 // if (newUpdateQueue !== null) { 9285 // newState = processUpdateQueue( 9286 // workInProgress, 9287 // newUpdateQueue, 9288 // instance, 9289 // newState, 9290 // newProps, 9291 // priorityLevel, 9292 // ); 9293 // } 9294 // } 9295 9296 // if (typeof instance.componentDidMount === 'function') { 9297 // workInProgress.effectTag |= Update; 9298 // } 9299 9300 // instance.state = newState; 9301 9302 // return true; 9303 // } 9304 9305 // Invokes the update life-cycles and returns false if it shouldn't rerender. 9306 function updateClassInstance(current, workInProgress, renderExpirationTime) { 9307 var instance = workInProgress.stateNode; 9308 resetInputPointers(workInProgress, instance); 9309 9310 var oldProps = workInProgress.memoizedProps; 9311 var newProps = workInProgress.pendingProps; 9312 if (!newProps) { 9313 // If there aren't any new props, then we'll reuse the memoized props. 9314 // This could be from already completed work. 9315 newProps = oldProps; 9316 !(newProps != null) ? invariant(false, 'There should always be pending or memoized props. This error is likely caused by a bug in React. Please file an issue.') : void 0; 9317 } 9318 var oldContext = instance.context; 9319 var newUnmaskedContext = getUnmaskedContext(workInProgress); 9320 var newContext = getMaskedContext(workInProgress, newUnmaskedContext); 9321 9322 // Note: During these life-cycles, instance.props/instance.state are what 9323 // ever the previously attempted to render - not the "current". However, 9324 // during componentDidUpdate we pass the "current" props. 9325 9326 if (typeof instance.componentWillReceiveProps === 'function' && (oldProps !== newProps || oldContext !== newContext)) { 9327 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); 9328 } 9329 9330 // Compute the next state using the memoized state and the update queue. 9331 var oldState = workInProgress.memoizedState; 9332 // TODO: Previous state can be null. 9333 var newState = void 0; 9334 if (workInProgress.updateQueue !== null) { 9335 newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime); 9336 } else { 9337 newState = oldState; 9338 } 9339 9340 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) { 9341 // If an update was already in progress, we should schedule an Update 9342 // effect even though we're bailing out, so that cWU/cDU are called. 9343 if (typeof instance.componentDidUpdate === 'function') { 9344 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 9345 workInProgress.effectTag |= Update; 9346 } 9347 } 9348 return false; 9349 } 9350 9351 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext); 9352 9353 if (shouldUpdate) { 9354 if (typeof instance.componentWillUpdate === 'function') { 9355 startPhaseTimer(workInProgress, 'componentWillUpdate'); 9356 instance.componentWillUpdate(newProps, newState, newContext); 9357 stopPhaseTimer(); 9358 9359 // Simulate an async bailout/interruption by invoking lifecycle twice. 9360 if (debugRenderPhaseSideEffects) { 9361 instance.componentWillUpdate(newProps, newState, newContext); 9362 } 9363 } 9364 if (typeof instance.componentDidUpdate === 'function') { 9365 workInProgress.effectTag |= Update; 9366 } 9367 } else { 9368 // If an update was already in progress, we should schedule an Update 9369 // effect even though we're bailing out, so that cWU/cDU are called. 9370 if (typeof instance.componentDidUpdate === 'function') { 9371 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 9372 workInProgress.effectTag |= Update; 9373 } 9374 } 9375 9376 // If shouldComponentUpdate returned false, we should still update the 9377 // memoized props/state to indicate that this work can be reused. 9378 memoizeProps(workInProgress, newProps); 9379 memoizeState(workInProgress, newState); 9380 } 9381 9382 // Update the existing instance's state, props, and context pointers even 9383 // if shouldComponentUpdate returns false. 9384 instance.props = newProps; 9385 instance.state = newState; 9386 instance.context = newContext; 9387 9388 return shouldUpdate; 9389 } 9390 9391 return { 9392 adoptClassInstance: adoptClassInstance, 9393 constructClassInstance: constructClassInstance, 9394 mountClassInstance: mountClassInstance, 9395 // resumeMountClassInstance, 9396 updateClassInstance: updateClassInstance 9397 }; 9398 }; 9399 9400 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol 9401 // nor polyfill, then a plain number is used for performance. 9402 var hasSymbol = typeof Symbol === 'function' && Symbol['for']; 9403 9404 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7; 9405 var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8; 9406 var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9; 9407 var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca; 9408 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb; 9409 9410 var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 9411 var FAUX_ITERATOR_SYMBOL = '@@iterator'; 9412 9413 function getIteratorFn(maybeIterable) { 9414 if (maybeIterable === null || typeof maybeIterable === 'undefined') { 9415 return null; 9416 } 9417 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 9418 if (typeof maybeIterator === 'function') { 9419 return maybeIterator; 9420 } 9421 return null; 9422 } 9423 9424 var getCurrentFiberStackAddendum$1 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 9425 9426 9427 { 9428 var didWarnAboutMaps = false; 9429 /** 9430 * Warn if there's no key explicitly set on dynamic arrays of children or 9431 * object keys are not valid. This allows us to keep track of children between 9432 * updates. 9433 */ 9434 var ownerHasKeyUseWarning = {}; 9435 var ownerHasFunctionTypeWarning = {}; 9436 9437 var warnForMissingKey = function (child) { 9438 if (child === null || typeof child !== 'object') { 9439 return; 9440 } 9441 if (!child._store || child._store.validated || child.key != null) { 9442 return; 9443 } 9444 !(typeof child._store === 'object') ? invariant(false, 'React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.') : void 0; 9445 child._store.validated = true; 9446 9447 var currentComponentErrorInfo = 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + (getCurrentFiberStackAddendum$1() || ''); 9448 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 9449 return; 9450 } 9451 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 9452 9453 warning(false, 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.%s', getCurrentFiberStackAddendum$1()); 9454 }; 9455 } 9456 9457 var isArray$1 = Array.isArray; 9458 9459 function coerceRef(current, element) { 9460 var mixedRef = element.ref; 9461 if (mixedRef !== null && typeof mixedRef !== 'function') { 9462 if (element._owner) { 9463 var owner = element._owner; 9464 var inst = void 0; 9465 if (owner) { 9466 var ownerFiber = owner; 9467 !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Stateless function components cannot have refs.') : void 0; 9468 inst = ownerFiber.stateNode; 9469 } 9470 !inst ? invariant(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0; 9471 var stringRef = '' + mixedRef; 9472 // Check if previous string ref matches new string ref 9473 if (current !== null && current.ref !== null && current.ref._stringRef === stringRef) { 9474 return current.ref; 9475 } 9476 var ref = function (value) { 9477 var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs; 9478 if (value === null) { 9479 delete refs[stringRef]; 9480 } else { 9481 refs[stringRef] = value; 9482 } 9483 }; 9484 ref._stringRef = stringRef; 9485 return ref; 9486 } else { 9487 !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function or a string.') : void 0; 9488 !element._owner ? invariant(false, 'Element ref was specified as a string (%s) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).', mixedRef) : void 0; 9489 } 9490 } 9491 return mixedRef; 9492 } 9493 9494 function throwOnInvalidObjectType(returnFiber, newChild) { 9495 if (returnFiber.type !== 'textarea') { 9496 var addendum = ''; 9497 { 9498 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + (getCurrentFiberStackAddendum$1() || ''); 9499 } 9500 invariant(false, 'Objects are not valid as a React child (found: %s).%s', Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild, addendum); 9501 } 9502 } 9503 9504 function warnOnFunctionType() { 9505 var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + (getCurrentFiberStackAddendum$1() || ''); 9506 9507 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { 9508 return; 9509 } 9510 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; 9511 9512 warning(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.%s', getCurrentFiberStackAddendum$1() || ''); 9513 } 9514 9515 // This wrapper function exists because I expect to clone the code in each path 9516 // to be able to optimize each path individually by branching early. This needs 9517 // a compiler or we can do it manually. Helpers that don't need this branching 9518 // live outside of this function. 9519 function ChildReconciler(shouldTrackSideEffects) { 9520 function deleteChild(returnFiber, childToDelete) { 9521 if (!shouldTrackSideEffects) { 9522 // Noop. 9523 return; 9524 } 9525 // Deletions are added in reversed order so we add it to the front. 9526 // At this point, the return fiber's effect list is empty except for 9527 // deletions, so we can just append the deletion to the list. The remaining 9528 // effects aren't added until the complete phase. Once we implement 9529 // resuming, this may not be true. 9530 var last = returnFiber.lastEffect; 9531 if (last !== null) { 9532 last.nextEffect = childToDelete; 9533 returnFiber.lastEffect = childToDelete; 9534 } else { 9535 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 9536 } 9537 childToDelete.nextEffect = null; 9538 childToDelete.effectTag = Deletion; 9539 } 9540 9541 function deleteRemainingChildren(returnFiber, currentFirstChild) { 9542 if (!shouldTrackSideEffects) { 9543 // Noop. 9544 return null; 9545 } 9546 9547 // TODO: For the shouldClone case, this could be micro-optimized a bit by 9548 // assuming that after the first child we've already added everything. 9549 var childToDelete = currentFirstChild; 9550 while (childToDelete !== null) { 9551 deleteChild(returnFiber, childToDelete); 9552 childToDelete = childToDelete.sibling; 9553 } 9554 return null; 9555 } 9556 9557 function mapRemainingChildren(returnFiber, currentFirstChild) { 9558 // Add the remaining children to a temporary map so that we can find them by 9559 // keys quickly. Implicit (null) keys get added to this set with their index 9560 var existingChildren = new Map(); 9561 9562 var existingChild = currentFirstChild; 9563 while (existingChild !== null) { 9564 if (existingChild.key !== null) { 9565 existingChildren.set(existingChild.key, existingChild); 9566 } else { 9567 existingChildren.set(existingChild.index, existingChild); 9568 } 9569 existingChild = existingChild.sibling; 9570 } 9571 return existingChildren; 9572 } 9573 9574 function useFiber(fiber, pendingProps, expirationTime) { 9575 // We currently set sibling to null and index to 0 here because it is easy 9576 // to forget to do before returning it. E.g. for the single child case. 9577 var clone = createWorkInProgress(fiber, pendingProps, expirationTime); 9578 clone.index = 0; 9579 clone.sibling = null; 9580 return clone; 9581 } 9582 9583 function placeChild(newFiber, lastPlacedIndex, newIndex) { 9584 newFiber.index = newIndex; 9585 if (!shouldTrackSideEffects) { 9586 // Noop. 9587 return lastPlacedIndex; 9588 } 9589 var current = newFiber.alternate; 9590 if (current !== null) { 9591 var oldIndex = current.index; 9592 if (oldIndex < lastPlacedIndex) { 9593 // This is a move. 9594 newFiber.effectTag = Placement; 9595 return lastPlacedIndex; 9596 } else { 9597 // This item can stay in place. 9598 return oldIndex; 9599 } 9600 } else { 9601 // This is an insertion. 9602 newFiber.effectTag = Placement; 9603 return lastPlacedIndex; 9604 } 9605 } 9606 9607 function placeSingleChild(newFiber) { 9608 // This is simpler for the single child case. We only need to do a 9609 // placement for inserting new children. 9610 if (shouldTrackSideEffects && newFiber.alternate === null) { 9611 newFiber.effectTag = Placement; 9612 } 9613 return newFiber; 9614 } 9615 9616 function updateTextNode(returnFiber, current, textContent, expirationTime) { 9617 if (current === null || current.tag !== HostText) { 9618 // Insert 9619 var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime); 9620 created['return'] = returnFiber; 9621 return created; 9622 } else { 9623 // Update 9624 var existing = useFiber(current, textContent, expirationTime); 9625 existing['return'] = returnFiber; 9626 return existing; 9627 } 9628 } 9629 9630 function updateElement(returnFiber, current, element, expirationTime) { 9631 if (current !== null && current.type === element.type) { 9632 // Move based on index 9633 var existing = useFiber(current, element.props, expirationTime); 9634 existing.ref = coerceRef(current, element); 9635 existing['return'] = returnFiber; 9636 { 9637 existing._debugSource = element._source; 9638 existing._debugOwner = element._owner; 9639 } 9640 return existing; 9641 } else { 9642 // Insert 9643 var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime); 9644 created.ref = coerceRef(current, element); 9645 created['return'] = returnFiber; 9646 return created; 9647 } 9648 } 9649 9650 function updateCall(returnFiber, current, call, expirationTime) { 9651 // TODO: Should this also compare handler to determine whether to reuse? 9652 if (current === null || current.tag !== CallComponent) { 9653 // Insert 9654 var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime); 9655 created['return'] = returnFiber; 9656 return created; 9657 } else { 9658 // Move based on index 9659 var existing = useFiber(current, call, expirationTime); 9660 existing['return'] = returnFiber; 9661 return existing; 9662 } 9663 } 9664 9665 function updateReturn(returnFiber, current, returnNode, expirationTime) { 9666 if (current === null || current.tag !== ReturnComponent) { 9667 // Insert 9668 var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime); 9669 created.type = returnNode.value; 9670 created['return'] = returnFiber; 9671 return created; 9672 } else { 9673 // Move based on index 9674 var existing = useFiber(current, null, expirationTime); 9675 existing.type = returnNode.value; 9676 existing['return'] = returnFiber; 9677 return existing; 9678 } 9679 } 9680 9681 function updatePortal(returnFiber, current, portal, expirationTime) { 9682 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 9683 // Insert 9684 var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime); 9685 created['return'] = returnFiber; 9686 return created; 9687 } else { 9688 // Update 9689 var existing = useFiber(current, portal.children || [], expirationTime); 9690 existing['return'] = returnFiber; 9691 return existing; 9692 } 9693 } 9694 9695 function updateFragment(returnFiber, current, fragment, expirationTime, key) { 9696 if (current === null || current.tag !== Fragment) { 9697 // Insert 9698 var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key); 9699 created['return'] = returnFiber; 9700 return created; 9701 } else { 9702 // Update 9703 var existing = useFiber(current, fragment, expirationTime); 9704 existing['return'] = returnFiber; 9705 return existing; 9706 } 9707 } 9708 9709 function createChild(returnFiber, newChild, expirationTime) { 9710 if (typeof newChild === 'string' || typeof newChild === 'number') { 9711 // Text nodes don't have keys. If the previous node is implicitly keyed 9712 // we can continue to replace it without aborting even if it is not a text 9713 // node. 9714 var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime); 9715 created['return'] = returnFiber; 9716 return created; 9717 } 9718 9719 if (typeof newChild === 'object' && newChild !== null) { 9720 switch (newChild.$$typeof) { 9721 case REACT_ELEMENT_TYPE: 9722 { 9723 if (newChild.type === REACT_FRAGMENT_TYPE) { 9724 var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key); 9725 _created['return'] = returnFiber; 9726 return _created; 9727 } else { 9728 var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime); 9729 _created2.ref = coerceRef(null, newChild); 9730 _created2['return'] = returnFiber; 9731 return _created2; 9732 } 9733 } 9734 9735 case REACT_CALL_TYPE: 9736 { 9737 var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime); 9738 _created3['return'] = returnFiber; 9739 return _created3; 9740 } 9741 9742 case REACT_RETURN_TYPE: 9743 { 9744 var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime); 9745 _created4.type = newChild.value; 9746 _created4['return'] = returnFiber; 9747 return _created4; 9748 } 9749 9750 case REACT_PORTAL_TYPE: 9751 { 9752 var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime); 9753 _created5['return'] = returnFiber; 9754 return _created5; 9755 } 9756 } 9757 9758 if (isArray$1(newChild) || getIteratorFn(newChild)) { 9759 var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null); 9760 _created6['return'] = returnFiber; 9761 return _created6; 9762 } 9763 9764 throwOnInvalidObjectType(returnFiber, newChild); 9765 } 9766 9767 { 9768 if (typeof newChild === 'function') { 9769 warnOnFunctionType(); 9770 } 9771 } 9772 9773 return null; 9774 } 9775 9776 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { 9777 // Update the fiber if the keys match, otherwise return null. 9778 9779 var key = oldFiber !== null ? oldFiber.key : null; 9780 9781 if (typeof newChild === 'string' || typeof newChild === 'number') { 9782 // Text nodes don't have keys. If the previous node is implicitly keyed 9783 // we can continue to replace it without aborting even if it is not a text 9784 // node. 9785 if (key !== null) { 9786 return null; 9787 } 9788 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); 9789 } 9790 9791 if (typeof newChild === 'object' && newChild !== null) { 9792 switch (newChild.$$typeof) { 9793 case REACT_ELEMENT_TYPE: 9794 { 9795 if (newChild.key === key) { 9796 if (newChild.type === REACT_FRAGMENT_TYPE) { 9797 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); 9798 } 9799 return updateElement(returnFiber, oldFiber, newChild, expirationTime); 9800 } else { 9801 return null; 9802 } 9803 } 9804 9805 case REACT_CALL_TYPE: 9806 { 9807 if (newChild.key === key) { 9808 return updateCall(returnFiber, oldFiber, newChild, expirationTime); 9809 } else { 9810 return null; 9811 } 9812 } 9813 9814 case REACT_RETURN_TYPE: 9815 { 9816 // Returns don't have keys. If the previous node is implicitly keyed 9817 // we can continue to replace it without aborting even if it is not a 9818 // yield. 9819 if (key === null) { 9820 return updateReturn(returnFiber, oldFiber, newChild, expirationTime); 9821 } else { 9822 return null; 9823 } 9824 } 9825 9826 case REACT_PORTAL_TYPE: 9827 { 9828 if (newChild.key === key) { 9829 return updatePortal(returnFiber, oldFiber, newChild, expirationTime); 9830 } else { 9831 return null; 9832 } 9833 } 9834 } 9835 9836 if (isArray$1(newChild) || getIteratorFn(newChild)) { 9837 if (key !== null) { 9838 return null; 9839 } 9840 9841 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); 9842 } 9843 9844 throwOnInvalidObjectType(returnFiber, newChild); 9845 } 9846 9847 { 9848 if (typeof newChild === 'function') { 9849 warnOnFunctionType(); 9850 } 9851 } 9852 9853 return null; 9854 } 9855 9856 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { 9857 if (typeof newChild === 'string' || typeof newChild === 'number') { 9858 // Text nodes don't have keys, so we neither have to check the old nor 9859 // new node for the key. If both are text nodes, they match. 9860 var matchedFiber = existingChildren.get(newIdx) || null; 9861 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); 9862 } 9863 9864 if (typeof newChild === 'object' && newChild !== null) { 9865 switch (newChild.$$typeof) { 9866 case REACT_ELEMENT_TYPE: 9867 { 9868 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 9869 if (newChild.type === REACT_FRAGMENT_TYPE) { 9870 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); 9871 } 9872 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); 9873 } 9874 9875 case REACT_CALL_TYPE: 9876 { 9877 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 9878 return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime); 9879 } 9880 9881 case REACT_RETURN_TYPE: 9882 { 9883 // Returns don't have keys, so we neither have to check the old nor 9884 // new node for the key. If both are returns, they match. 9885 var _matchedFiber3 = existingChildren.get(newIdx) || null; 9886 return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime); 9887 } 9888 9889 case REACT_PORTAL_TYPE: 9890 { 9891 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 9892 return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime); 9893 } 9894 } 9895 9896 if (isArray$1(newChild) || getIteratorFn(newChild)) { 9897 var _matchedFiber5 = existingChildren.get(newIdx) || null; 9898 return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null); 9899 } 9900 9901 throwOnInvalidObjectType(returnFiber, newChild); 9902 } 9903 9904 { 9905 if (typeof newChild === 'function') { 9906 warnOnFunctionType(); 9907 } 9908 } 9909 9910 return null; 9911 } 9912 9913 /** 9914 * Warns if there is a duplicate or missing key 9915 */ 9916 function warnOnInvalidKey(child, knownKeys) { 9917 { 9918 if (typeof child !== 'object' || child === null) { 9919 return knownKeys; 9920 } 9921 switch (child.$$typeof) { 9922 case REACT_ELEMENT_TYPE: 9923 case REACT_CALL_TYPE: 9924 case REACT_PORTAL_TYPE: 9925 warnForMissingKey(child); 9926 var key = child.key; 9927 if (typeof key !== 'string') { 9928 break; 9929 } 9930 if (knownKeys === null) { 9931 knownKeys = new Set(); 9932 knownKeys.add(key); 9933 break; 9934 } 9935 if (!knownKeys.has(key)) { 9936 knownKeys.add(key); 9937 break; 9938 } 9939 warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1()); 9940 break; 9941 default: 9942 break; 9943 } 9944 } 9945 return knownKeys; 9946 } 9947 9948 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { 9949 // This algorithm can't optimize by searching from boths ends since we 9950 // don't have backpointers on fibers. I'm trying to see how far we can get 9951 // with that model. If it ends up not being worth the tradeoffs, we can 9952 // add it later. 9953 9954 // Even with a two ended optimization, we'd want to optimize for the case 9955 // where there are few changes and brute force the comparison instead of 9956 // going for the Map. It'd like to explore hitting that path first in 9957 // forward-only mode and only go for the Map once we notice that we need 9958 // lots of look ahead. This doesn't handle reversal as well as two ended 9959 // search but that's unusual. Besides, for the two ended optimization to 9960 // work on Iterables, we'd need to copy the whole set. 9961 9962 // In this first iteration, we'll just live with hitting the bad case 9963 // (adding everything to a Map) in for every insert/move. 9964 9965 // If you change this code, also update reconcileChildrenIterator() which 9966 // uses the same algorithm. 9967 9968 { 9969 // First, validate keys. 9970 var knownKeys = null; 9971 for (var i = 0; i < newChildren.length; i++) { 9972 var child = newChildren[i]; 9973 knownKeys = warnOnInvalidKey(child, knownKeys); 9974 } 9975 } 9976 9977 var resultingFirstChild = null; 9978 var previousNewFiber = null; 9979 9980 var oldFiber = currentFirstChild; 9981 var lastPlacedIndex = 0; 9982 var newIdx = 0; 9983 var nextOldFiber = null; 9984 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 9985 if (oldFiber.index > newIdx) { 9986 nextOldFiber = oldFiber; 9987 oldFiber = null; 9988 } else { 9989 nextOldFiber = oldFiber.sibling; 9990 } 9991 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); 9992 if (newFiber === null) { 9993 // TODO: This breaks on empty slots like null children. That's 9994 // unfortunate because it triggers the slow path all the time. We need 9995 // a better way to communicate whether this was a miss or null, 9996 // boolean, undefined, etc. 9997 if (oldFiber === null) { 9998 oldFiber = nextOldFiber; 9999 } 10000 break; 10001 } 10002 if (shouldTrackSideEffects) { 10003 if (oldFiber && newFiber.alternate === null) { 10004 // We matched the slot, but we didn't reuse the existing fiber, so we 10005 // need to delete the existing child. 10006 deleteChild(returnFiber, oldFiber); 10007 } 10008 } 10009 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 10010 if (previousNewFiber === null) { 10011 // TODO: Move out of the loop. This only happens for the first run. 10012 resultingFirstChild = newFiber; 10013 } else { 10014 // TODO: Defer siblings if we're not at the right index for this slot. 10015 // I.e. if we had null values before, then we want to defer this 10016 // for each null value. However, we also don't want to call updateSlot 10017 // with the previous one. 10018 previousNewFiber.sibling = newFiber; 10019 } 10020 previousNewFiber = newFiber; 10021 oldFiber = nextOldFiber; 10022 } 10023 10024 if (newIdx === newChildren.length) { 10025 // We've reached the end of the new children. We can delete the rest. 10026 deleteRemainingChildren(returnFiber, oldFiber); 10027 return resultingFirstChild; 10028 } 10029 10030 if (oldFiber === null) { 10031 // If we don't have any more existing children we can choose a fast path 10032 // since the rest will all be insertions. 10033 for (; newIdx < newChildren.length; newIdx++) { 10034 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); 10035 if (!_newFiber) { 10036 continue; 10037 } 10038 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 10039 if (previousNewFiber === null) { 10040 // TODO: Move out of the loop. This only happens for the first run. 10041 resultingFirstChild = _newFiber; 10042 } else { 10043 previousNewFiber.sibling = _newFiber; 10044 } 10045 previousNewFiber = _newFiber; 10046 } 10047 return resultingFirstChild; 10048 } 10049 10050 // Add all children to a key map for quick lookups. 10051 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); 10052 10053 // Keep scanning and use the map to restore deleted items as moves. 10054 for (; newIdx < newChildren.length; newIdx++) { 10055 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); 10056 if (_newFiber2) { 10057 if (shouldTrackSideEffects) { 10058 if (_newFiber2.alternate !== null) { 10059 // The new fiber is a work in progress, but if there exists a 10060 // current, that means that we reused the fiber. We need to delete 10061 // it from the child list so that we don't add it to the deletion 10062 // list. 10063 existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key); 10064 } 10065 } 10066 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 10067 if (previousNewFiber === null) { 10068 resultingFirstChild = _newFiber2; 10069 } else { 10070 previousNewFiber.sibling = _newFiber2; 10071 } 10072 previousNewFiber = _newFiber2; 10073 } 10074 } 10075 10076 if (shouldTrackSideEffects) { 10077 // Any existing children that weren't consumed above were deleted. We need 10078 // to add them to the deletion list. 10079 existingChildren.forEach(function (child) { 10080 return deleteChild(returnFiber, child); 10081 }); 10082 } 10083 10084 return resultingFirstChild; 10085 } 10086 10087 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { 10088 // This is the same implementation as reconcileChildrenArray(), 10089 // but using the iterator instead. 10090 10091 var iteratorFn = getIteratorFn(newChildrenIterable); 10092 !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0; 10093 10094 { 10095 // Warn about using Maps as children 10096 if (typeof newChildrenIterable.entries === 'function') { 10097 var possibleMap = newChildrenIterable; 10098 if (possibleMap.entries === iteratorFn) { 10099 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1()); 10100 didWarnAboutMaps = true; 10101 } 10102 } 10103 10104 // First, validate keys. 10105 // We'll get a different iterator later for the main pass. 10106 var _newChildren = iteratorFn.call(newChildrenIterable); 10107 if (_newChildren) { 10108 var knownKeys = null; 10109 var _step = _newChildren.next(); 10110 for (; !_step.done; _step = _newChildren.next()) { 10111 var child = _step.value; 10112 knownKeys = warnOnInvalidKey(child, knownKeys); 10113 } 10114 } 10115 } 10116 10117 var newChildren = iteratorFn.call(newChildrenIterable); 10118 !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0; 10119 10120 var resultingFirstChild = null; 10121 var previousNewFiber = null; 10122 10123 var oldFiber = currentFirstChild; 10124 var lastPlacedIndex = 0; 10125 var newIdx = 0; 10126 var nextOldFiber = null; 10127 10128 var step = newChildren.next(); 10129 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 10130 if (oldFiber.index > newIdx) { 10131 nextOldFiber = oldFiber; 10132 oldFiber = null; 10133 } else { 10134 nextOldFiber = oldFiber.sibling; 10135 } 10136 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); 10137 if (newFiber === null) { 10138 // TODO: This breaks on empty slots like null children. That's 10139 // unfortunate because it triggers the slow path all the time. We need 10140 // a better way to communicate whether this was a miss or null, 10141 // boolean, undefined, etc. 10142 if (!oldFiber) { 10143 oldFiber = nextOldFiber; 10144 } 10145 break; 10146 } 10147 if (shouldTrackSideEffects) { 10148 if (oldFiber && newFiber.alternate === null) { 10149 // We matched the slot, but we didn't reuse the existing fiber, so we 10150 // need to delete the existing child. 10151 deleteChild(returnFiber, oldFiber); 10152 } 10153 } 10154 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 10155 if (previousNewFiber === null) { 10156 // TODO: Move out of the loop. This only happens for the first run. 10157 resultingFirstChild = newFiber; 10158 } else { 10159 // TODO: Defer siblings if we're not at the right index for this slot. 10160 // I.e. if we had null values before, then we want to defer this 10161 // for each null value. However, we also don't want to call updateSlot 10162 // with the previous one. 10163 previousNewFiber.sibling = newFiber; 10164 } 10165 previousNewFiber = newFiber; 10166 oldFiber = nextOldFiber; 10167 } 10168 10169 if (step.done) { 10170 // We've reached the end of the new children. We can delete the rest. 10171 deleteRemainingChildren(returnFiber, oldFiber); 10172 return resultingFirstChild; 10173 } 10174 10175 if (oldFiber === null) { 10176 // If we don't have any more existing children we can choose a fast path 10177 // since the rest will all be insertions. 10178 for (; !step.done; newIdx++, step = newChildren.next()) { 10179 var _newFiber3 = createChild(returnFiber, step.value, expirationTime); 10180 if (_newFiber3 === null) { 10181 continue; 10182 } 10183 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 10184 if (previousNewFiber === null) { 10185 // TODO: Move out of the loop. This only happens for the first run. 10186 resultingFirstChild = _newFiber3; 10187 } else { 10188 previousNewFiber.sibling = _newFiber3; 10189 } 10190 previousNewFiber = _newFiber3; 10191 } 10192 return resultingFirstChild; 10193 } 10194 10195 // Add all children to a key map for quick lookups. 10196 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); 10197 10198 // Keep scanning and use the map to restore deleted items as moves. 10199 for (; !step.done; newIdx++, step = newChildren.next()) { 10200 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); 10201 if (_newFiber4 !== null) { 10202 if (shouldTrackSideEffects) { 10203 if (_newFiber4.alternate !== null) { 10204 // The new fiber is a work in progress, but if there exists a 10205 // current, that means that we reused the fiber. We need to delete 10206 // it from the child list so that we don't add it to the deletion 10207 // list. 10208 existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key); 10209 } 10210 } 10211 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 10212 if (previousNewFiber === null) { 10213 resultingFirstChild = _newFiber4; 10214 } else { 10215 previousNewFiber.sibling = _newFiber4; 10216 } 10217 previousNewFiber = _newFiber4; 10218 } 10219 } 10220 10221 if (shouldTrackSideEffects) { 10222 // Any existing children that weren't consumed above were deleted. We need 10223 // to add them to the deletion list. 10224 existingChildren.forEach(function (child) { 10225 return deleteChild(returnFiber, child); 10226 }); 10227 } 10228 10229 return resultingFirstChild; 10230 } 10231 10232 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { 10233 // There's no need to check for keys on text nodes since we don't have a 10234 // way to define them. 10235 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 10236 // We already have an existing node so let's just update it and delete 10237 // the rest. 10238 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 10239 var existing = useFiber(currentFirstChild, textContent, expirationTime); 10240 existing['return'] = returnFiber; 10241 return existing; 10242 } 10243 // The existing first child is not a text node so we need to create one 10244 // and delete the existing ones. 10245 deleteRemainingChildren(returnFiber, currentFirstChild); 10246 var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime); 10247 created['return'] = returnFiber; 10248 return created; 10249 } 10250 10251 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { 10252 var key = element.key; 10253 var child = currentFirstChild; 10254 while (child !== null) { 10255 // TODO: If key === null and child.key === null, then this only applies to 10256 // the first item in the list. 10257 if (child.key === key) { 10258 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) { 10259 deleteRemainingChildren(returnFiber, child.sibling); 10260 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime); 10261 existing.ref = coerceRef(child, element); 10262 existing['return'] = returnFiber; 10263 { 10264 existing._debugSource = element._source; 10265 existing._debugOwner = element._owner; 10266 } 10267 return existing; 10268 } else { 10269 deleteRemainingChildren(returnFiber, child); 10270 break; 10271 } 10272 } else { 10273 deleteChild(returnFiber, child); 10274 } 10275 child = child.sibling; 10276 } 10277 10278 if (element.type === REACT_FRAGMENT_TYPE) { 10279 var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key); 10280 created['return'] = returnFiber; 10281 return created; 10282 } else { 10283 var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime); 10284 _created7.ref = coerceRef(currentFirstChild, element); 10285 _created7['return'] = returnFiber; 10286 return _created7; 10287 } 10288 } 10289 10290 function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) { 10291 var key = call.key; 10292 var child = currentFirstChild; 10293 while (child !== null) { 10294 // TODO: If key === null and child.key === null, then this only applies to 10295 // the first item in the list. 10296 if (child.key === key) { 10297 if (child.tag === CallComponent) { 10298 deleteRemainingChildren(returnFiber, child.sibling); 10299 var existing = useFiber(child, call, expirationTime); 10300 existing['return'] = returnFiber; 10301 return existing; 10302 } else { 10303 deleteRemainingChildren(returnFiber, child); 10304 break; 10305 } 10306 } else { 10307 deleteChild(returnFiber, child); 10308 } 10309 child = child.sibling; 10310 } 10311 10312 var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime); 10313 created['return'] = returnFiber; 10314 return created; 10315 } 10316 10317 function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) { 10318 // There's no need to check for keys on yields since they're stateless. 10319 var child = currentFirstChild; 10320 if (child !== null) { 10321 if (child.tag === ReturnComponent) { 10322 deleteRemainingChildren(returnFiber, child.sibling); 10323 var existing = useFiber(child, null, expirationTime); 10324 existing.type = returnNode.value; 10325 existing['return'] = returnFiber; 10326 return existing; 10327 } else { 10328 deleteRemainingChildren(returnFiber, child); 10329 } 10330 } 10331 10332 var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime); 10333 created.type = returnNode.value; 10334 created['return'] = returnFiber; 10335 return created; 10336 } 10337 10338 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { 10339 var key = portal.key; 10340 var child = currentFirstChild; 10341 while (child !== null) { 10342 // TODO: If key === null and child.key === null, then this only applies to 10343 // the first item in the list. 10344 if (child.key === key) { 10345 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 10346 deleteRemainingChildren(returnFiber, child.sibling); 10347 var existing = useFiber(child, portal.children || [], expirationTime); 10348 existing['return'] = returnFiber; 10349 return existing; 10350 } else { 10351 deleteRemainingChildren(returnFiber, child); 10352 break; 10353 } 10354 } else { 10355 deleteChild(returnFiber, child); 10356 } 10357 child = child.sibling; 10358 } 10359 10360 var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime); 10361 created['return'] = returnFiber; 10362 return created; 10363 } 10364 10365 // This API will tag the children with the side-effect of the reconciliation 10366 // itself. They will be added to the side-effect list as we pass through the 10367 // children and the parent. 10368 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { 10369 // This function is not recursive. 10370 // If the top level item is an array, we treat it as a set of children, 10371 // not as a fragment. Nested arrays on the other hand will be treated as 10372 // fragment nodes. Recursion happens at the normal flow. 10373 10374 // Handle top level unkeyed fragments as if they were arrays. 10375 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 10376 // We treat the ambiguous cases above the same. 10377 if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) { 10378 newChild = newChild.props.children; 10379 } 10380 10381 // Handle object types 10382 var isObject = typeof newChild === 'object' && newChild !== null; 10383 10384 if (isObject) { 10385 switch (newChild.$$typeof) { 10386 case REACT_ELEMENT_TYPE: 10387 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); 10388 10389 case REACT_CALL_TYPE: 10390 return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime)); 10391 case REACT_RETURN_TYPE: 10392 return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime)); 10393 case REACT_PORTAL_TYPE: 10394 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); 10395 } 10396 } 10397 10398 if (typeof newChild === 'string' || typeof newChild === 'number') { 10399 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); 10400 } 10401 10402 if (isArray$1(newChild)) { 10403 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); 10404 } 10405 10406 if (getIteratorFn(newChild)) { 10407 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); 10408 } 10409 10410 if (isObject) { 10411 throwOnInvalidObjectType(returnFiber, newChild); 10412 } 10413 10414 { 10415 if (typeof newChild === 'function') { 10416 warnOnFunctionType(); 10417 } 10418 } 10419 if (typeof newChild === 'undefined') { 10420 // If the new child is undefined, and the return fiber is a composite 10421 // component, throw an error. If Fiber return types are disabled, 10422 // we already threw above. 10423 switch (returnFiber.tag) { 10424 case ClassComponent: 10425 { 10426 { 10427 var instance = returnFiber.stateNode; 10428 if (instance.render._isMockFunction) { 10429 // We allow auto-mocks to proceed as if they're returning null. 10430 break; 10431 } 10432 } 10433 } 10434 // Intentionally fall through to the next case, which handles both 10435 // functions and classes 10436 // eslint-disable-next-lined no-fallthrough 10437 case FunctionalComponent: 10438 { 10439 var Component = returnFiber.type; 10440 invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component'); 10441 } 10442 } 10443 } 10444 10445 // Remaining cases are all treated as empty. 10446 return deleteRemainingChildren(returnFiber, currentFirstChild); 10447 } 10448 10449 return reconcileChildFibers; 10450 } 10451 10452 var reconcileChildFibers = ChildReconciler(true); 10453 var mountChildFibers = ChildReconciler(false); 10454 10455 function cloneChildFibers(current, workInProgress) { 10456 !(current === null || workInProgress.child === current.child) ? invariant(false, 'Resuming work not yet implemented.') : void 0; 10457 10458 if (workInProgress.child === null) { 10459 return; 10460 } 10461 10462 var currentChild = workInProgress.child; 10463 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime); 10464 workInProgress.child = newChild; 10465 10466 newChild['return'] = workInProgress; 10467 while (currentChild.sibling !== null) { 10468 currentChild = currentChild.sibling; 10469 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime); 10470 newChild['return'] = workInProgress; 10471 } 10472 newChild.sibling = null; 10473 } 10474 10475 { 10476 var warnedAboutStatelessRefs = {}; 10477 } 10478 10479 var ReactFiberBeginWork = function (config, hostContext, hydrationContext, scheduleWork, computeExpirationForFiber) { 10480 var shouldSetTextContent = config.shouldSetTextContent, 10481 useSyncScheduling = config.useSyncScheduling, 10482 shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree; 10483 var pushHostContext = hostContext.pushHostContext, 10484 pushHostContainer = hostContext.pushHostContainer; 10485 var enterHydrationState = hydrationContext.enterHydrationState, 10486 resetHydrationState = hydrationContext.resetHydrationState, 10487 tryToClaimNextHydratableInstance = hydrationContext.tryToClaimNextHydratableInstance; 10488 10489 var _ReactFiberClassCompo = ReactFiberClassComponent(scheduleWork, computeExpirationForFiber, memoizeProps, memoizeState), 10490 adoptClassInstance = _ReactFiberClassCompo.adoptClassInstance, 10491 constructClassInstance = _ReactFiberClassCompo.constructClassInstance, 10492 mountClassInstance = _ReactFiberClassCompo.mountClassInstance, 10493 updateClassInstance = _ReactFiberClassCompo.updateClassInstance; 10494 10495 // TODO: Remove this and use reconcileChildrenAtExpirationTime directly. 10496 10497 10498 function reconcileChildren(current, workInProgress, nextChildren) { 10499 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, workInProgress.expirationTime); 10500 } 10501 10502 function reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime) { 10503 if (current === null) { 10504 // If this is a fresh new component that hasn't been rendered yet, we 10505 // won't update its child set by applying minimal side-effects. Instead, 10506 // we will add them all to the child before it gets rendered. That means 10507 // we can optimize this reconciliation pass by not tracking side-effects. 10508 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 10509 } else { 10510 // If the current child is the same as the work in progress, it means that 10511 // we haven't yet started any work on these children. Therefore, we use 10512 // the clone algorithm to create a copy of all the current children. 10513 10514 // If we had any progressed work already, that is invalid at this point so 10515 // let's throw it out. 10516 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime); 10517 } 10518 } 10519 10520 function updateFragment(current, workInProgress) { 10521 var nextChildren = workInProgress.pendingProps; 10522 if (hasContextChanged()) { 10523 // Normally we can bail out on props equality but if context has changed 10524 // we don't do the bailout and we have to reuse existing props instead. 10525 if (nextChildren === null) { 10526 nextChildren = workInProgress.memoizedProps; 10527 } 10528 } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) { 10529 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10530 } 10531 reconcileChildren(current, workInProgress, nextChildren); 10532 memoizeProps(workInProgress, nextChildren); 10533 return workInProgress.child; 10534 } 10535 10536 function markRef(current, workInProgress) { 10537 var ref = workInProgress.ref; 10538 if (ref !== null && (!current || current.ref !== ref)) { 10539 // Schedule a Ref effect 10540 workInProgress.effectTag |= Ref; 10541 } 10542 } 10543 10544 function updateFunctionalComponent(current, workInProgress) { 10545 var fn = workInProgress.type; 10546 var nextProps = workInProgress.pendingProps; 10547 10548 var memoizedProps = workInProgress.memoizedProps; 10549 if (hasContextChanged()) { 10550 // Normally we can bail out on props equality but if context has changed 10551 // we don't do the bailout and we have to reuse existing props instead. 10552 if (nextProps === null) { 10553 nextProps = memoizedProps; 10554 } 10555 } else { 10556 if (nextProps === null || memoizedProps === nextProps) { 10557 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10558 } 10559 // TODO: consider bringing fn.shouldComponentUpdate() back. 10560 // It used to be here. 10561 } 10562 10563 var unmaskedContext = getUnmaskedContext(workInProgress); 10564 var context = getMaskedContext(workInProgress, unmaskedContext); 10565 10566 var nextChildren; 10567 10568 { 10569 ReactCurrentOwner.current = workInProgress; 10570 ReactDebugCurrentFiber.setCurrentPhase('render'); 10571 nextChildren = fn(nextProps, context); 10572 ReactDebugCurrentFiber.setCurrentPhase(null); 10573 } 10574 // React DevTools reads this flag. 10575 workInProgress.effectTag |= PerformedWork; 10576 reconcileChildren(current, workInProgress, nextChildren); 10577 memoizeProps(workInProgress, nextProps); 10578 return workInProgress.child; 10579 } 10580 10581 function updateClassComponent(current, workInProgress, renderExpirationTime) { 10582 // Push context providers early to prevent context stack mismatches. 10583 // During mounting we don't know the child context yet as the instance doesn't exist. 10584 // We will invalidate the child context in finishClassComponent() right after rendering. 10585 var hasContext = pushContextProvider(workInProgress); 10586 10587 var shouldUpdate = void 0; 10588 if (current === null) { 10589 if (!workInProgress.stateNode) { 10590 // In the initial pass we might need to construct the instance. 10591 constructClassInstance(workInProgress, workInProgress.pendingProps); 10592 mountClassInstance(workInProgress, renderExpirationTime); 10593 shouldUpdate = true; 10594 } else { 10595 invariant(false, 'Resuming work not yet implemented.'); 10596 // In a resume, we'll already have an instance we can reuse. 10597 // shouldUpdate = resumeMountClassInstance(workInProgress, renderExpirationTime); 10598 } 10599 } else { 10600 shouldUpdate = updateClassInstance(current, workInProgress, renderExpirationTime); 10601 } 10602 return finishClassComponent(current, workInProgress, shouldUpdate, hasContext); 10603 } 10604 10605 function finishClassComponent(current, workInProgress, shouldUpdate, hasContext) { 10606 // Refs should update even if shouldComponentUpdate returns false 10607 markRef(current, workInProgress); 10608 10609 if (!shouldUpdate) { 10610 // Context providers should defer to sCU for rendering 10611 if (hasContext) { 10612 invalidateContextProvider(workInProgress, false); 10613 } 10614 10615 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10616 } 10617 10618 var instance = workInProgress.stateNode; 10619 10620 // Rerender 10621 ReactCurrentOwner.current = workInProgress; 10622 var nextChildren = void 0; 10623 { 10624 ReactDebugCurrentFiber.setCurrentPhase('render'); 10625 nextChildren = instance.render(); 10626 if (debugRenderPhaseSideEffects) { 10627 instance.render(); 10628 } 10629 ReactDebugCurrentFiber.setCurrentPhase(null); 10630 } 10631 // React DevTools reads this flag. 10632 workInProgress.effectTag |= PerformedWork; 10633 reconcileChildren(current, workInProgress, nextChildren); 10634 // Memoize props and state using the values we just used to render. 10635 // TODO: Restructure so we never read values from the instance. 10636 memoizeState(workInProgress, instance.state); 10637 memoizeProps(workInProgress, instance.props); 10638 10639 // The context might have changed so we need to recalculate it. 10640 if (hasContext) { 10641 invalidateContextProvider(workInProgress, true); 10642 } 10643 10644 return workInProgress.child; 10645 } 10646 10647 function pushHostRootContext(workInProgress) { 10648 var root = workInProgress.stateNode; 10649 if (root.pendingContext) { 10650 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 10651 } else if (root.context) { 10652 // Should always be set 10653 pushTopLevelContextObject(workInProgress, root.context, false); 10654 } 10655 pushHostContainer(workInProgress, root.containerInfo); 10656 } 10657 10658 function updateHostRoot(current, workInProgress, renderExpirationTime) { 10659 pushHostRootContext(workInProgress); 10660 var updateQueue = workInProgress.updateQueue; 10661 if (updateQueue !== null) { 10662 var prevState = workInProgress.memoizedState; 10663 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime); 10664 if (prevState === state) { 10665 // If the state is the same as before, that's a bailout because we had 10666 // no work that expires at this time. 10667 resetHydrationState(); 10668 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10669 } 10670 var element = state.element; 10671 var root = workInProgress.stateNode; 10672 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) { 10673 // If we don't have any current children this might be the first pass. 10674 // We always try to hydrate. If this isn't a hydration pass there won't 10675 // be any children to hydrate which is effectively the same thing as 10676 // not hydrating. 10677 10678 // This is a bit of a hack. We track the host root as a placement to 10679 // know that we're currently in a mounting state. That way isMounted 10680 // works as expected. We must reset this before committing. 10681 // TODO: Delete this when we delete isMounted and findDOMNode. 10682 workInProgress.effectTag |= Placement; 10683 10684 // Ensure that children mount into this root without tracking 10685 // side-effects. This ensures that we don't store Placement effects on 10686 // nodes that will be hydrated. 10687 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime); 10688 } else { 10689 // Otherwise reset hydration state in case we aborted and resumed another 10690 // root. 10691 resetHydrationState(); 10692 reconcileChildren(current, workInProgress, element); 10693 } 10694 memoizeState(workInProgress, state); 10695 return workInProgress.child; 10696 } 10697 resetHydrationState(); 10698 // If there is no update queue, that's a bailout because the root has no props. 10699 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10700 } 10701 10702 function updateHostComponent(current, workInProgress, renderExpirationTime) { 10703 pushHostContext(workInProgress); 10704 10705 if (current === null) { 10706 tryToClaimNextHydratableInstance(workInProgress); 10707 } 10708 10709 var type = workInProgress.type; 10710 var memoizedProps = workInProgress.memoizedProps; 10711 var nextProps = workInProgress.pendingProps; 10712 if (nextProps === null) { 10713 nextProps = memoizedProps; 10714 !(nextProps !== null) ? invariant(false, 'We should always have pending or current props. This error is likely caused by a bug in React. Please file an issue.') : void 0; 10715 } 10716 var prevProps = current !== null ? current.memoizedProps : null; 10717 10718 if (hasContextChanged()) { 10719 // Normally we can bail out on props equality but if context has changed 10720 // we don't do the bailout and we have to reuse existing props instead. 10721 } else if (nextProps === null || memoizedProps === nextProps) { 10722 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10723 } 10724 10725 var nextChildren = nextProps.children; 10726 var isDirectTextChild = shouldSetTextContent(type, nextProps); 10727 10728 if (isDirectTextChild) { 10729 // We special case a direct text child of a host node. This is a common 10730 // case. We won't handle it as a reified child. We will instead handle 10731 // this in the host environment that also have access to this prop. That 10732 // avoids allocating another HostText fiber and traversing it. 10733 nextChildren = null; 10734 } else if (prevProps && shouldSetTextContent(type, prevProps)) { 10735 // If we're switching from a direct text child to a normal child, or to 10736 // empty, we need to schedule the text content to be reset. 10737 workInProgress.effectTag |= ContentReset; 10738 } 10739 10740 markRef(current, workInProgress); 10741 10742 // Check the host config to see if the children are offscreen/hidden. 10743 if (renderExpirationTime !== Never && !useSyncScheduling && shouldDeprioritizeSubtree(type, nextProps)) { 10744 // Down-prioritize the children. 10745 workInProgress.expirationTime = Never; 10746 // Bailout and come back to this fiber later. 10747 return null; 10748 } 10749 10750 reconcileChildren(current, workInProgress, nextChildren); 10751 memoizeProps(workInProgress, nextProps); 10752 return workInProgress.child; 10753 } 10754 10755 function updateHostText(current, workInProgress) { 10756 if (current === null) { 10757 tryToClaimNextHydratableInstance(workInProgress); 10758 } 10759 var nextProps = workInProgress.pendingProps; 10760 if (nextProps === null) { 10761 nextProps = workInProgress.memoizedProps; 10762 } 10763 memoizeProps(workInProgress, nextProps); 10764 // Nothing to do here. This is terminal. We'll do the completion step 10765 // immediately after. 10766 return null; 10767 } 10768 10769 function mountIndeterminateComponent(current, workInProgress, renderExpirationTime) { 10770 !(current === null) ? invariant(false, 'An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue.') : void 0; 10771 var fn = workInProgress.type; 10772 var props = workInProgress.pendingProps; 10773 var unmaskedContext = getUnmaskedContext(workInProgress); 10774 var context = getMaskedContext(workInProgress, unmaskedContext); 10775 10776 var value; 10777 10778 { 10779 if (fn.prototype && typeof fn.prototype.render === 'function') { 10780 var componentName = getComponentName(workInProgress); 10781 warning(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName); 10782 } 10783 ReactCurrentOwner.current = workInProgress; 10784 value = fn(props, context); 10785 } 10786 // React DevTools reads this flag. 10787 workInProgress.effectTag |= PerformedWork; 10788 10789 if (typeof value === 'object' && value !== null && typeof value.render === 'function') { 10790 // Proceed under the assumption that this is a class instance 10791 workInProgress.tag = ClassComponent; 10792 10793 // Push context providers early to prevent context stack mismatches. 10794 // During mounting we don't know the child context yet as the instance doesn't exist. 10795 // We will invalidate the child context in finishClassComponent() right after rendering. 10796 var hasContext = pushContextProvider(workInProgress); 10797 adoptClassInstance(workInProgress, value); 10798 mountClassInstance(workInProgress, renderExpirationTime); 10799 return finishClassComponent(current, workInProgress, true, hasContext); 10800 } else { 10801 // Proceed under the assumption that this is a functional component 10802 workInProgress.tag = FunctionalComponent; 10803 { 10804 var Component = workInProgress.type; 10805 10806 if (Component) { 10807 warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component'); 10808 } 10809 if (workInProgress.ref !== null) { 10810 var info = ''; 10811 var ownerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName(); 10812 if (ownerName) { 10813 info += '\n\nCheck the render method of `' + ownerName + '`.'; 10814 } 10815 10816 var warningKey = ownerName || workInProgress._debugID || ''; 10817 var debugSource = workInProgress._debugSource; 10818 if (debugSource) { 10819 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 10820 } 10821 if (!warnedAboutStatelessRefs[warningKey]) { 10822 warnedAboutStatelessRefs[warningKey] = true; 10823 warning(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s%s', info, ReactDebugCurrentFiber.getCurrentFiberStackAddendum()); 10824 } 10825 } 10826 } 10827 reconcileChildren(current, workInProgress, value); 10828 memoizeProps(workInProgress, props); 10829 return workInProgress.child; 10830 } 10831 } 10832 10833 function updateCallComponent(current, workInProgress, renderExpirationTime) { 10834 var nextCall = workInProgress.pendingProps; 10835 if (hasContextChanged()) { 10836 // Normally we can bail out on props equality but if context has changed 10837 // we don't do the bailout and we have to reuse existing props instead. 10838 if (nextCall === null) { 10839 nextCall = current && current.memoizedProps; 10840 !(nextCall !== null) ? invariant(false, 'We should always have pending or current props. This error is likely caused by a bug in React. Please file an issue.') : void 0; 10841 } 10842 } else if (nextCall === null || workInProgress.memoizedProps === nextCall) { 10843 nextCall = workInProgress.memoizedProps; 10844 // TODO: When bailing out, we might need to return the stateNode instead 10845 // of the child. To check it for work. 10846 // return bailoutOnAlreadyFinishedWork(current, workInProgress); 10847 } 10848 10849 var nextChildren = nextCall.children; 10850 10851 // The following is a fork of reconcileChildrenAtExpirationTime but using 10852 // stateNode to store the child. 10853 if (current === null) { 10854 workInProgress.stateNode = mountChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime); 10855 } else { 10856 workInProgress.stateNode = reconcileChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime); 10857 } 10858 10859 memoizeProps(workInProgress, nextCall); 10860 // This doesn't take arbitrary time so we could synchronously just begin 10861 // eagerly do the work of workInProgress.child as an optimization. 10862 return workInProgress.stateNode; 10863 } 10864 10865 function updatePortalComponent(current, workInProgress, renderExpirationTime) { 10866 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 10867 var nextChildren = workInProgress.pendingProps; 10868 if (hasContextChanged()) { 10869 // Normally we can bail out on props equality but if context has changed 10870 // we don't do the bailout and we have to reuse existing props instead. 10871 if (nextChildren === null) { 10872 nextChildren = current && current.memoizedProps; 10873 !(nextChildren != null) ? invariant(false, 'We should always have pending or current props. This error is likely caused by a bug in React. Please file an issue.') : void 0; 10874 } 10875 } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) { 10876 return bailoutOnAlreadyFinishedWork(current, workInProgress); 10877 } 10878 10879 if (current === null) { 10880 // Portals are special because we don't append the children during mount 10881 // but at commit. Therefore we need to track insertions which the normal 10882 // flow doesn't do during mount. This doesn't happen at the root because 10883 // the root always starts with a "current" with a null child. 10884 // TODO: Consider unifying this with how the root works. 10885 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 10886 memoizeProps(workInProgress, nextChildren); 10887 } else { 10888 reconcileChildren(current, workInProgress, nextChildren); 10889 memoizeProps(workInProgress, nextChildren); 10890 } 10891 return workInProgress.child; 10892 } 10893 10894 /* 10895 function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) { 10896 let child = firstChild; 10897 do { 10898 // Ensure that the first and last effect of the parent corresponds 10899 // to the children's first and last effect. 10900 if (!returnFiber.firstEffect) { 10901 returnFiber.firstEffect = child.firstEffect; 10902 } 10903 if (child.lastEffect) { 10904 if (returnFiber.lastEffect) { 10905 returnFiber.lastEffect.nextEffect = child.firstEffect; 10906 } 10907 returnFiber.lastEffect = child.lastEffect; 10908 } 10909 } while (child = child.sibling); 10910 } 10911 */ 10912 10913 function bailoutOnAlreadyFinishedWork(current, workInProgress) { 10914 cancelWorkTimer(workInProgress); 10915 10916 // TODO: We should ideally be able to bail out early if the children have no 10917 // more work to do. However, since we don't have a separation of this 10918 // Fiber's priority and its children yet - we don't know without doing lots 10919 // of the same work we do anyway. Once we have that separation we can just 10920 // bail out here if the children has no more work at this priority level. 10921 // if (workInProgress.priorityOfChildren <= priorityLevel) { 10922 // // If there are side-effects in these children that have not yet been 10923 // // committed we need to ensure that they get properly transferred up. 10924 // if (current && current.child !== workInProgress.child) { 10925 // reuseChildrenEffects(workInProgress, child); 10926 // } 10927 // return null; 10928 // } 10929 10930 cloneChildFibers(current, workInProgress); 10931 return workInProgress.child; 10932 } 10933 10934 function bailoutOnLowPriority(current, workInProgress) { 10935 cancelWorkTimer(workInProgress); 10936 10937 // TODO: Handle HostComponent tags here as well and call pushHostContext()? 10938 // See PR 8590 discussion for context 10939 switch (workInProgress.tag) { 10940 case HostRoot: 10941 pushHostRootContext(workInProgress); 10942 break; 10943 case ClassComponent: 10944 pushContextProvider(workInProgress); 10945 break; 10946 case HostPortal: 10947 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 10948 break; 10949 } 10950 // TODO: What if this is currently in progress? 10951 // How can that happen? How is this not being cloned? 10952 return null; 10953 } 10954 10955 // TODO: Delete memoizeProps/State and move to reconcile/bailout instead 10956 function memoizeProps(workInProgress, nextProps) { 10957 workInProgress.memoizedProps = nextProps; 10958 } 10959 10960 function memoizeState(workInProgress, nextState) { 10961 workInProgress.memoizedState = nextState; 10962 // Don't reset the updateQueue, in case there are pending updates. Resetting 10963 // is handled by processUpdateQueue. 10964 } 10965 10966 function beginWork(current, workInProgress, renderExpirationTime) { 10967 if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) { 10968 return bailoutOnLowPriority(current, workInProgress); 10969 } 10970 10971 switch (workInProgress.tag) { 10972 case IndeterminateComponent: 10973 return mountIndeterminateComponent(current, workInProgress, renderExpirationTime); 10974 case FunctionalComponent: 10975 return updateFunctionalComponent(current, workInProgress); 10976 case ClassComponent: 10977 return updateClassComponent(current, workInProgress, renderExpirationTime); 10978 case HostRoot: 10979 return updateHostRoot(current, workInProgress, renderExpirationTime); 10980 case HostComponent: 10981 return updateHostComponent(current, workInProgress, renderExpirationTime); 10982 case HostText: 10983 return updateHostText(current, workInProgress); 10984 case CallHandlerPhase: 10985 // This is a restart. Reset the tag to the initial phase. 10986 workInProgress.tag = CallComponent; 10987 // Intentionally fall through since this is now the same. 10988 case CallComponent: 10989 return updateCallComponent(current, workInProgress, renderExpirationTime); 10990 case ReturnComponent: 10991 // A return component is just a placeholder, we can just run through the 10992 // next one immediately. 10993 return null; 10994 case HostPortal: 10995 return updatePortalComponent(current, workInProgress, renderExpirationTime); 10996 case Fragment: 10997 return updateFragment(current, workInProgress); 10998 default: 10999 invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'); 11000 } 11001 } 11002 11003 function beginFailedWork(current, workInProgress, renderExpirationTime) { 11004 // Push context providers here to avoid a push/pop context mismatch. 11005 switch (workInProgress.tag) { 11006 case ClassComponent: 11007 pushContextProvider(workInProgress); 11008 break; 11009 case HostRoot: 11010 pushHostRootContext(workInProgress); 11011 break; 11012 default: 11013 invariant(false, 'Invalid type of work. This error is likely caused by a bug in React. Please file an issue.'); 11014 } 11015 11016 // Add an error effect so we can handle the error during the commit phase 11017 workInProgress.effectTag |= Err; 11018 11019 // This is a weird case where we do "resume" work — work that failed on 11020 // our first attempt. Because we no longer have a notion of "progressed 11021 // deletions," reset the child to the current child to make sure we delete 11022 // it again. TODO: Find a better way to handle this, perhaps during a more 11023 // general overhaul of error handling. 11024 if (current === null) { 11025 workInProgress.child = null; 11026 } else if (workInProgress.child !== current.child) { 11027 workInProgress.child = current.child; 11028 } 11029 11030 if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) { 11031 return bailoutOnLowPriority(current, workInProgress); 11032 } 11033 11034 // If we don't bail out, we're going be recomputing our children so we need 11035 // to drop our effect list. 11036 workInProgress.firstEffect = null; 11037 workInProgress.lastEffect = null; 11038 11039 // Unmount the current children as if the component rendered null 11040 var nextChildren = null; 11041 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime); 11042 11043 if (workInProgress.tag === ClassComponent) { 11044 var instance = workInProgress.stateNode; 11045 workInProgress.memoizedProps = instance.props; 11046 workInProgress.memoizedState = instance.state; 11047 } 11048 11049 return workInProgress.child; 11050 } 11051 11052 return { 11053 beginWork: beginWork, 11054 beginFailedWork: beginFailedWork 11055 }; 11056 }; 11057 11058 var ReactFiberCompleteWork = function (config, hostContext, hydrationContext) { 11059 var createInstance = config.createInstance, 11060 createTextInstance = config.createTextInstance, 11061 appendInitialChild = config.appendInitialChild, 11062 finalizeInitialChildren = config.finalizeInitialChildren, 11063 prepareUpdate = config.prepareUpdate, 11064 mutation = config.mutation, 11065 persistence = config.persistence; 11066 var getRootHostContainer = hostContext.getRootHostContainer, 11067 popHostContext = hostContext.popHostContext, 11068 getHostContext = hostContext.getHostContext, 11069 popHostContainer = hostContext.popHostContainer; 11070 var prepareToHydrateHostInstance = hydrationContext.prepareToHydrateHostInstance, 11071 prepareToHydrateHostTextInstance = hydrationContext.prepareToHydrateHostTextInstance, 11072 popHydrationState = hydrationContext.popHydrationState; 11073 11074 11075 function markUpdate(workInProgress) { 11076 // Tag the fiber with an update effect. This turns a Placement into 11077 // an UpdateAndPlacement. 11078 workInProgress.effectTag |= Update; 11079 } 11080 11081 function markRef(workInProgress) { 11082 workInProgress.effectTag |= Ref; 11083 } 11084 11085 function appendAllReturns(returns, workInProgress) { 11086 var node = workInProgress.stateNode; 11087 if (node) { 11088 node['return'] = workInProgress; 11089 } 11090 while (node !== null) { 11091 if (node.tag === HostComponent || node.tag === HostText || node.tag === HostPortal) { 11092 invariant(false, 'A call cannot have host component children.'); 11093 } else if (node.tag === ReturnComponent) { 11094 returns.push(node.type); 11095 } else if (node.child !== null) { 11096 node.child['return'] = node; 11097 node = node.child; 11098 continue; 11099 } 11100 while (node.sibling === null) { 11101 if (node['return'] === null || node['return'] === workInProgress) { 11102 return; 11103 } 11104 node = node['return']; 11105 } 11106 node.sibling['return'] = node['return']; 11107 node = node.sibling; 11108 } 11109 } 11110 11111 function moveCallToHandlerPhase(current, workInProgress, renderExpirationTime) { 11112 var call = workInProgress.memoizedProps; 11113 !call ? invariant(false, 'Should be resolved by now. This error is likely caused by a bug in React. Please file an issue.') : void 0; 11114 11115 // First step of the call has completed. Now we need to do the second. 11116 // TODO: It would be nice to have a multi stage call represented by a 11117 // single component, or at least tail call optimize nested ones. Currently 11118 // that requires additional fields that we don't want to add to the fiber. 11119 // So this requires nested handlers. 11120 // Note: This doesn't mutate the alternate node. I don't think it needs to 11121 // since this stage is reset for every pass. 11122 workInProgress.tag = CallHandlerPhase; 11123 11124 // Build up the returns. 11125 // TODO: Compare this to a generator or opaque helpers like Children. 11126 var returns = []; 11127 appendAllReturns(returns, workInProgress); 11128 var fn = call.handler; 11129 var props = call.props; 11130 var nextChildren = fn(props, returns); 11131 11132 var currentFirstChild = current !== null ? current.child : null; 11133 workInProgress.child = reconcileChildFibers(workInProgress, currentFirstChild, nextChildren, renderExpirationTime); 11134 return workInProgress.child; 11135 } 11136 11137 function appendAllChildren(parent, workInProgress) { 11138 // We only have the top Fiber that was created but we need recurse down its 11139 // children to find all the terminal nodes. 11140 var node = workInProgress.child; 11141 while (node !== null) { 11142 if (node.tag === HostComponent || node.tag === HostText) { 11143 appendInitialChild(parent, node.stateNode); 11144 } else if (node.tag === HostPortal) { 11145 // If we have a portal child, then we don't want to traverse 11146 // down its children. Instead, we'll get insertions from each child in 11147 // the portal directly. 11148 } else if (node.child !== null) { 11149 node.child['return'] = node; 11150 node = node.child; 11151 continue; 11152 } 11153 if (node === workInProgress) { 11154 return; 11155 } 11156 while (node.sibling === null) { 11157 if (node['return'] === null || node['return'] === workInProgress) { 11158 return; 11159 } 11160 node = node['return']; 11161 } 11162 node.sibling['return'] = node['return']; 11163 node = node.sibling; 11164 } 11165 } 11166 11167 var updateHostContainer = void 0; 11168 var updateHostComponent = void 0; 11169 var updateHostText = void 0; 11170 if (mutation) { 11171 if (enableMutatingReconciler) { 11172 // Mutation mode 11173 updateHostContainer = function (workInProgress) { 11174 // Noop 11175 }; 11176 updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance) { 11177 // TODO: Type this specific to this type of component. 11178 workInProgress.updateQueue = updatePayload; 11179 // If the update payload indicates that there is a change or if there 11180 // is a new ref we mark this as an update. All the work is done in commitWork. 11181 if (updatePayload) { 11182 markUpdate(workInProgress); 11183 } 11184 }; 11185 updateHostText = function (current, workInProgress, oldText, newText) { 11186 // If the text differs, mark it as an update. All the work in done in commitWork. 11187 if (oldText !== newText) { 11188 markUpdate(workInProgress); 11189 } 11190 }; 11191 } else { 11192 invariant(false, 'Mutating reconciler is disabled.'); 11193 } 11194 } else if (persistence) { 11195 if (enablePersistentReconciler) { 11196 // Persistent host tree mode 11197 var cloneInstance = persistence.cloneInstance, 11198 createContainerChildSet = persistence.createContainerChildSet, 11199 appendChildToContainerChildSet = persistence.appendChildToContainerChildSet, 11200 finalizeContainerChildren = persistence.finalizeContainerChildren; 11201 11202 // An unfortunate fork of appendAllChildren because we have two different parent types. 11203 11204 var appendAllChildrenToContainer = function (containerChildSet, workInProgress) { 11205 // We only have the top Fiber that was created but we need recurse down its 11206 // children to find all the terminal nodes. 11207 var node = workInProgress.child; 11208 while (node !== null) { 11209 if (node.tag === HostComponent || node.tag === HostText) { 11210 appendChildToContainerChildSet(containerChildSet, node.stateNode); 11211 } else if (node.tag === HostPortal) { 11212 // If we have a portal child, then we don't want to traverse 11213 // down its children. Instead, we'll get insertions from each child in 11214 // the portal directly. 11215 } else if (node.child !== null) { 11216 node.child['return'] = node; 11217 node = node.child; 11218 continue; 11219 } 11220 if (node === workInProgress) { 11221 return; 11222 } 11223 while (node.sibling === null) { 11224 if (node['return'] === null || node['return'] === workInProgress) { 11225 return; 11226 } 11227 node = node['return']; 11228 } 11229 node.sibling['return'] = node['return']; 11230 node = node.sibling; 11231 } 11232 }; 11233 updateHostContainer = function (workInProgress) { 11234 var portalOrRoot = workInProgress.stateNode; 11235 var childrenUnchanged = workInProgress.firstEffect === null; 11236 if (childrenUnchanged) { 11237 // No changes, just reuse the existing instance. 11238 } else { 11239 var container = portalOrRoot.containerInfo; 11240 var newChildSet = createContainerChildSet(container); 11241 if (finalizeContainerChildren(container, newChildSet)) { 11242 markUpdate(workInProgress); 11243 } 11244 portalOrRoot.pendingChildren = newChildSet; 11245 // If children might have changed, we have to add them all to the set. 11246 appendAllChildrenToContainer(newChildSet, workInProgress); 11247 // Schedule an update on the container to swap out the container. 11248 markUpdate(workInProgress); 11249 } 11250 }; 11251 updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance) { 11252 // If there are no effects associated with this node, then none of our children had any updates. 11253 // This guarantees that we can reuse all of them. 11254 var childrenUnchanged = workInProgress.firstEffect === null; 11255 var currentInstance = current.stateNode; 11256 if (childrenUnchanged && updatePayload === null) { 11257 // No changes, just reuse the existing instance. 11258 // Note that this might release a previous clone. 11259 workInProgress.stateNode = currentInstance; 11260 } else { 11261 var recyclableInstance = workInProgress.stateNode; 11262 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance); 11263 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance)) { 11264 markUpdate(workInProgress); 11265 } 11266 workInProgress.stateNode = newInstance; 11267 if (childrenUnchanged) { 11268 // If there are no other effects in this tree, we need to flag this node as having one. 11269 // Even though we're not going to use it for anything. 11270 // Otherwise parents won't know that there are new children to propagate upwards. 11271 markUpdate(workInProgress); 11272 } else { 11273 // If children might have changed, we have to add them all to the set. 11274 appendAllChildren(newInstance, workInProgress); 11275 } 11276 } 11277 }; 11278 updateHostText = function (current, workInProgress, oldText, newText) { 11279 if (oldText !== newText) { 11280 // If the text content differs, we'll create a new text instance for it. 11281 var rootContainerInstance = getRootHostContainer(); 11282 var currentHostContext = getHostContext(); 11283 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); 11284 // We'll have to mark it as having an effect, even though we won't use the effect for anything. 11285 // This lets the parents know that at least one of their children has changed. 11286 markUpdate(workInProgress); 11287 } 11288 }; 11289 } else { 11290 invariant(false, 'Persistent reconciler is disabled.'); 11291 } 11292 } else { 11293 if (enableNoopReconciler) { 11294 // No host operations 11295 updateHostContainer = function (workInProgress) { 11296 // Noop 11297 }; 11298 updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance) { 11299 // Noop 11300 }; 11301 updateHostText = function (current, workInProgress, oldText, newText) { 11302 // Noop 11303 }; 11304 } else { 11305 invariant(false, 'Noop reconciler is disabled.'); 11306 } 11307 } 11308 11309 function completeWork(current, workInProgress, renderExpirationTime) { 11310 // Get the latest props. 11311 var newProps = workInProgress.pendingProps; 11312 if (newProps === null) { 11313 newProps = workInProgress.memoizedProps; 11314 } else if (workInProgress.expirationTime !== Never || renderExpirationTime === Never) { 11315 // Reset the pending props, unless this was a down-prioritization. 11316 workInProgress.pendingProps = null; 11317 } 11318 11319 switch (workInProgress.tag) { 11320 case FunctionalComponent: 11321 return null; 11322 case ClassComponent: 11323 { 11324 // We are leaving this subtree, so pop context if any. 11325 popContextProvider(workInProgress); 11326 return null; 11327 } 11328 case HostRoot: 11329 { 11330 popHostContainer(workInProgress); 11331 popTopLevelContextObject(workInProgress); 11332 var fiberRoot = workInProgress.stateNode; 11333 if (fiberRoot.pendingContext) { 11334 fiberRoot.context = fiberRoot.pendingContext; 11335 fiberRoot.pendingContext = null; 11336 } 11337 11338 if (current === null || current.child === null) { 11339 // If we hydrated, pop so that we can delete any remaining children 11340 // that weren't hydrated. 11341 popHydrationState(workInProgress); 11342 // This resets the hacky state to fix isMounted before committing. 11343 // TODO: Delete this when we delete isMounted and findDOMNode. 11344 workInProgress.effectTag &= ~Placement; 11345 } 11346 updateHostContainer(workInProgress); 11347 return null; 11348 } 11349 case HostComponent: 11350 { 11351 popHostContext(workInProgress); 11352 var rootContainerInstance = getRootHostContainer(); 11353 var type = workInProgress.type; 11354 if (current !== null && workInProgress.stateNode != null) { 11355 // If we have an alternate, that means this is an update and we need to 11356 // schedule a side-effect to do the updates. 11357 var oldProps = current.memoizedProps; 11358 // If we get updated because one of our children updated, we don't 11359 // have newProps so we'll have to reuse them. 11360 // TODO: Split the update API as separate for the props vs. children. 11361 // Even better would be if children weren't special cased at all tho. 11362 var instance = workInProgress.stateNode; 11363 var currentHostContext = getHostContext(); 11364 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); 11365 11366 updateHostComponent(current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance); 11367 11368 if (current.ref !== workInProgress.ref) { 11369 markRef(workInProgress); 11370 } 11371 } else { 11372 if (!newProps) { 11373 !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0; 11374 // This can happen when we abort work. 11375 return null; 11376 } 11377 11378 var _currentHostContext = getHostContext(); 11379 // TODO: Move createInstance to beginWork and keep it on a context 11380 // "stack" as the parent. Then append children as we go in beginWork 11381 // or completeWork depending on we want to add then top->down or 11382 // bottom->up. Top->down is faster in IE11. 11383 var wasHydrated = popHydrationState(workInProgress); 11384 if (wasHydrated) { 11385 // TODO: Move this and createInstance step into the beginPhase 11386 // to consolidate. 11387 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, _currentHostContext)) { 11388 // If changes to the hydrated node needs to be applied at the 11389 // commit-phase we mark this as such. 11390 markUpdate(workInProgress); 11391 } 11392 } else { 11393 var _instance = createInstance(type, newProps, rootContainerInstance, _currentHostContext, workInProgress); 11394 11395 appendAllChildren(_instance, workInProgress); 11396 11397 // Certain renderers require commit-time effects for initial mount. 11398 // (eg DOM renderer supports auto-focus for certain elements). 11399 // Make sure such renderers get scheduled for later work. 11400 if (finalizeInitialChildren(_instance, type, newProps, rootContainerInstance)) { 11401 markUpdate(workInProgress); 11402 } 11403 workInProgress.stateNode = _instance; 11404 } 11405 11406 if (workInProgress.ref !== null) { 11407 // If there is a ref on a host node we need to schedule a callback 11408 markRef(workInProgress); 11409 } 11410 } 11411 return null; 11412 } 11413 case HostText: 11414 { 11415 var newText = newProps; 11416 if (current && workInProgress.stateNode != null) { 11417 var oldText = current.memoizedProps; 11418 // If we have an alternate, that means this is an update and we need 11419 // to schedule a side-effect to do the updates. 11420 updateHostText(current, workInProgress, oldText, newText); 11421 } else { 11422 if (typeof newText !== 'string') { 11423 !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0; 11424 // This can happen when we abort work. 11425 return null; 11426 } 11427 var _rootContainerInstance = getRootHostContainer(); 11428 var _currentHostContext2 = getHostContext(); 11429 var _wasHydrated = popHydrationState(workInProgress); 11430 if (_wasHydrated) { 11431 if (prepareToHydrateHostTextInstance(workInProgress)) { 11432 markUpdate(workInProgress); 11433 } 11434 } else { 11435 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext2, workInProgress); 11436 } 11437 } 11438 return null; 11439 } 11440 case CallComponent: 11441 return moveCallToHandlerPhase(current, workInProgress, renderExpirationTime); 11442 case CallHandlerPhase: 11443 // Reset the tag to now be a first phase call. 11444 workInProgress.tag = CallComponent; 11445 return null; 11446 case ReturnComponent: 11447 // Does nothing. 11448 return null; 11449 case Fragment: 11450 return null; 11451 case HostPortal: 11452 popHostContainer(workInProgress); 11453 updateHostContainer(workInProgress); 11454 return null; 11455 // Error cases 11456 case IndeterminateComponent: 11457 invariant(false, 'An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue.'); 11458 // eslint-disable-next-line no-fallthrough 11459 default: 11460 invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'); 11461 } 11462 } 11463 11464 return { 11465 completeWork: completeWork 11466 }; 11467 }; 11468 11469 var invokeGuardedCallback$2 = ReactErrorUtils.invokeGuardedCallback; 11470 var hasCaughtError$1 = ReactErrorUtils.hasCaughtError; 11471 var clearCaughtError$1 = ReactErrorUtils.clearCaughtError; 11472 11473 11474 var ReactFiberCommitWork = function (config, captureError) { 11475 var getPublicInstance = config.getPublicInstance, 11476 mutation = config.mutation, 11477 persistence = config.persistence; 11478 11479 11480 var callComponentWillUnmountWithTimer = function (current, instance) { 11481 startPhaseTimer(current, 'componentWillUnmount'); 11482 instance.props = current.memoizedProps; 11483 instance.state = current.memoizedState; 11484 instance.componentWillUnmount(); 11485 stopPhaseTimer(); 11486 }; 11487 11488 // Capture errors so they don't interrupt unmounting. 11489 function safelyCallComponentWillUnmount(current, instance) { 11490 { 11491 invokeGuardedCallback$2(null, callComponentWillUnmountWithTimer, null, current, instance); 11492 if (hasCaughtError$1()) { 11493 var unmountError = clearCaughtError$1(); 11494 captureError(current, unmountError); 11495 } 11496 } 11497 } 11498 11499 function safelyDetachRef(current) { 11500 var ref = current.ref; 11501 if (ref !== null) { 11502 { 11503 invokeGuardedCallback$2(null, ref, null, null); 11504 if (hasCaughtError$1()) { 11505 var refError = clearCaughtError$1(); 11506 captureError(current, refError); 11507 } 11508 } 11509 } 11510 } 11511 11512 function commitLifeCycles(current, finishedWork) { 11513 switch (finishedWork.tag) { 11514 case ClassComponent: 11515 { 11516 var instance = finishedWork.stateNode; 11517 if (finishedWork.effectTag & Update) { 11518 if (current === null) { 11519 startPhaseTimer(finishedWork, 'componentDidMount'); 11520 instance.props = finishedWork.memoizedProps; 11521 instance.state = finishedWork.memoizedState; 11522 instance.componentDidMount(); 11523 stopPhaseTimer(); 11524 } else { 11525 var prevProps = current.memoizedProps; 11526 var prevState = current.memoizedState; 11527 startPhaseTimer(finishedWork, 'componentDidUpdate'); 11528 instance.props = finishedWork.memoizedProps; 11529 instance.state = finishedWork.memoizedState; 11530 instance.componentDidUpdate(prevProps, prevState); 11531 stopPhaseTimer(); 11532 } 11533 } 11534 var updateQueue = finishedWork.updateQueue; 11535 if (updateQueue !== null) { 11536 commitCallbacks(updateQueue, instance); 11537 } 11538 return; 11539 } 11540 case HostRoot: 11541 { 11542 var _updateQueue = finishedWork.updateQueue; 11543 if (_updateQueue !== null) { 11544 var _instance = finishedWork.child !== null ? finishedWork.child.stateNode : null; 11545 commitCallbacks(_updateQueue, _instance); 11546 } 11547 return; 11548 } 11549 case HostComponent: 11550 { 11551 var _instance2 = finishedWork.stateNode; 11552 11553 // Renderers may schedule work to be done after host components are mounted 11554 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 11555 // These effects should only be committed when components are first mounted, 11556 // aka when there is no current/alternate. 11557 if (current === null && finishedWork.effectTag & Update) { 11558 var type = finishedWork.type; 11559 var props = finishedWork.memoizedProps; 11560 commitMount(_instance2, type, props, finishedWork); 11561 } 11562 11563 return; 11564 } 11565 case HostText: 11566 { 11567 // We have no life-cycles associated with text. 11568 return; 11569 } 11570 case HostPortal: 11571 { 11572 // We have no life-cycles associated with portals. 11573 return; 11574 } 11575 default: 11576 { 11577 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 11578 } 11579 } 11580 } 11581 11582 function commitAttachRef(finishedWork) { 11583 var ref = finishedWork.ref; 11584 if (ref !== null) { 11585 var instance = finishedWork.stateNode; 11586 switch (finishedWork.tag) { 11587 case HostComponent: 11588 ref(getPublicInstance(instance)); 11589 break; 11590 default: 11591 ref(instance); 11592 } 11593 } 11594 } 11595 11596 function commitDetachRef(current) { 11597 var currentRef = current.ref; 11598 if (currentRef !== null) { 11599 currentRef(null); 11600 } 11601 } 11602 11603 // User-originating errors (lifecycles and refs) should not interrupt 11604 // deletion, so don't let them throw. Host-originating errors should 11605 // interrupt deletion, so it's okay 11606 function commitUnmount(current) { 11607 if (typeof onCommitUnmount === 'function') { 11608 onCommitUnmount(current); 11609 } 11610 11611 switch (current.tag) { 11612 case ClassComponent: 11613 { 11614 safelyDetachRef(current); 11615 var instance = current.stateNode; 11616 if (typeof instance.componentWillUnmount === 'function') { 11617 safelyCallComponentWillUnmount(current, instance); 11618 } 11619 return; 11620 } 11621 case HostComponent: 11622 { 11623 safelyDetachRef(current); 11624 return; 11625 } 11626 case CallComponent: 11627 { 11628 commitNestedUnmounts(current.stateNode); 11629 return; 11630 } 11631 case HostPortal: 11632 { 11633 // TODO: this is recursive. 11634 // We are also not using this parent because 11635 // the portal will get pushed immediately. 11636 if (enableMutatingReconciler && mutation) { 11637 unmountHostComponents(current); 11638 } else if (enablePersistentReconciler && persistence) { 11639 emptyPortalContainer(current); 11640 } 11641 return; 11642 } 11643 } 11644 } 11645 11646 function commitNestedUnmounts(root) { 11647 // While we're inside a removed host node we don't want to call 11648 // removeChild on the inner nodes because they're removed by the top 11649 // call anyway. We also want to call componentWillUnmount on all 11650 // composites before this host node is removed from the tree. Therefore 11651 var node = root; 11652 while (true) { 11653 commitUnmount(node); 11654 // Visit children because they may contain more composite or host nodes. 11655 // Skip portals because commitUnmount() currently visits them recursively. 11656 if (node.child !== null && ( 11657 // If we use mutation we drill down into portals using commitUnmount above. 11658 // If we don't use mutation we drill down into portals here instead. 11659 !mutation || node.tag !== HostPortal)) { 11660 node.child['return'] = node; 11661 node = node.child; 11662 continue; 11663 } 11664 if (node === root) { 11665 return; 11666 } 11667 while (node.sibling === null) { 11668 if (node['return'] === null || node['return'] === root) { 11669 return; 11670 } 11671 node = node['return']; 11672 } 11673 node.sibling['return'] = node['return']; 11674 node = node.sibling; 11675 } 11676 } 11677 11678 function detachFiber(current) { 11679 // Cut off the return pointers to disconnect it from the tree. Ideally, we 11680 // should clear the child pointer of the parent alternate to let this 11681 // get GC:ed but we don't know which for sure which parent is the current 11682 // one so we'll settle for GC:ing the subtree of this child. This child 11683 // itself will be GC:ed when the parent updates the next time. 11684 current['return'] = null; 11685 current.child = null; 11686 if (current.alternate) { 11687 current.alternate.child = null; 11688 current.alternate['return'] = null; 11689 } 11690 } 11691 11692 if (!mutation) { 11693 var commitContainer = void 0; 11694 if (persistence) { 11695 var replaceContainerChildren = persistence.replaceContainerChildren, 11696 createContainerChildSet = persistence.createContainerChildSet; 11697 11698 var emptyPortalContainer = function (current) { 11699 var portal = current.stateNode; 11700 var containerInfo = portal.containerInfo; 11701 11702 var emptyChildSet = createContainerChildSet(containerInfo); 11703 replaceContainerChildren(containerInfo, emptyChildSet); 11704 }; 11705 commitContainer = function (finishedWork) { 11706 switch (finishedWork.tag) { 11707 case ClassComponent: 11708 { 11709 return; 11710 } 11711 case HostComponent: 11712 { 11713 return; 11714 } 11715 case HostText: 11716 { 11717 return; 11718 } 11719 case HostRoot: 11720 case HostPortal: 11721 { 11722 var portalOrRoot = finishedWork.stateNode; 11723 var containerInfo = portalOrRoot.containerInfo, 11724 _pendingChildren = portalOrRoot.pendingChildren; 11725 11726 replaceContainerChildren(containerInfo, _pendingChildren); 11727 return; 11728 } 11729 default: 11730 { 11731 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 11732 } 11733 } 11734 }; 11735 } else { 11736 commitContainer = function (finishedWork) { 11737 // Noop 11738 }; 11739 } 11740 if (enablePersistentReconciler || enableNoopReconciler) { 11741 return { 11742 commitResetTextContent: function (finishedWork) {}, 11743 commitPlacement: function (finishedWork) {}, 11744 commitDeletion: function (current) { 11745 // Detach refs and call componentWillUnmount() on the whole subtree. 11746 commitNestedUnmounts(current); 11747 detachFiber(current); 11748 }, 11749 commitWork: function (current, finishedWork) { 11750 commitContainer(finishedWork); 11751 }, 11752 11753 commitLifeCycles: commitLifeCycles, 11754 commitAttachRef: commitAttachRef, 11755 commitDetachRef: commitDetachRef 11756 }; 11757 } else if (persistence) { 11758 invariant(false, 'Persistent reconciler is disabled.'); 11759 } else { 11760 invariant(false, 'Noop reconciler is disabled.'); 11761 } 11762 } 11763 var commitMount = mutation.commitMount, 11764 commitUpdate = mutation.commitUpdate, 11765 resetTextContent = mutation.resetTextContent, 11766 commitTextUpdate = mutation.commitTextUpdate, 11767 appendChild = mutation.appendChild, 11768 appendChildToContainer = mutation.appendChildToContainer, 11769 insertBefore = mutation.insertBefore, 11770 insertInContainerBefore = mutation.insertInContainerBefore, 11771 removeChild = mutation.removeChild, 11772 removeChildFromContainer = mutation.removeChildFromContainer; 11773 11774 11775 function getHostParentFiber(fiber) { 11776 var parent = fiber['return']; 11777 while (parent !== null) { 11778 if (isHostParent(parent)) { 11779 return parent; 11780 } 11781 parent = parent['return']; 11782 } 11783 invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'); 11784 } 11785 11786 function isHostParent(fiber) { 11787 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 11788 } 11789 11790 function getHostSibling(fiber) { 11791 // We're going to search forward into the tree until we find a sibling host 11792 // node. Unfortunately, if multiple insertions are done in a row we have to 11793 // search past them. This leads to exponential search for the next sibling. 11794 var node = fiber; 11795 siblings: while (true) { 11796 // If we didn't find anything, let's try the next sibling. 11797 while (node.sibling === null) { 11798 if (node['return'] === null || isHostParent(node['return'])) { 11799 // If we pop out of the root or hit the parent the fiber we are the 11800 // last sibling. 11801 return null; 11802 } 11803 node = node['return']; 11804 } 11805 node.sibling['return'] = node['return']; 11806 node = node.sibling; 11807 while (node.tag !== HostComponent && node.tag !== HostText) { 11808 // If it is not host node and, we might have a host node inside it. 11809 // Try to search down until we find one. 11810 if (node.effectTag & Placement) { 11811 // If we don't have a child, try the siblings instead. 11812 continue siblings; 11813 } 11814 // If we don't have a child, try the siblings instead. 11815 // We also skip portals because they are not part of this host tree. 11816 if (node.child === null || node.tag === HostPortal) { 11817 continue siblings; 11818 } else { 11819 node.child['return'] = node; 11820 node = node.child; 11821 } 11822 } 11823 // Check if this host node is stable or about to be placed. 11824 if (!(node.effectTag & Placement)) { 11825 // Found it! 11826 return node.stateNode; 11827 } 11828 } 11829 } 11830 11831 function commitPlacement(finishedWork) { 11832 // Recursively insert all host nodes into the parent. 11833 var parentFiber = getHostParentFiber(finishedWork); 11834 var parent = void 0; 11835 var isContainer = void 0; 11836 switch (parentFiber.tag) { 11837 case HostComponent: 11838 parent = parentFiber.stateNode; 11839 isContainer = false; 11840 break; 11841 case HostRoot: 11842 parent = parentFiber.stateNode.containerInfo; 11843 isContainer = true; 11844 break; 11845 case HostPortal: 11846 parent = parentFiber.stateNode.containerInfo; 11847 isContainer = true; 11848 break; 11849 default: 11850 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.'); 11851 } 11852 if (parentFiber.effectTag & ContentReset) { 11853 // Reset the text content of the parent before doing any insertions 11854 resetTextContent(parent); 11855 // Clear ContentReset from the effect tag 11856 parentFiber.effectTag &= ~ContentReset; 11857 } 11858 11859 var before = getHostSibling(finishedWork); 11860 // We only have the top Fiber that was inserted but we need recurse down its 11861 // children to find all the terminal nodes. 11862 var node = finishedWork; 11863 while (true) { 11864 if (node.tag === HostComponent || node.tag === HostText) { 11865 if (before) { 11866 if (isContainer) { 11867 insertInContainerBefore(parent, node.stateNode, before); 11868 } else { 11869 insertBefore(parent, node.stateNode, before); 11870 } 11871 } else { 11872 if (isContainer) { 11873 appendChildToContainer(parent, node.stateNode); 11874 } else { 11875 appendChild(parent, node.stateNode); 11876 } 11877 } 11878 } else if (node.tag === HostPortal) { 11879 // If the insertion itself is a portal, then we don't want to traverse 11880 // down its children. Instead, we'll get insertions from each child in 11881 // the portal directly. 11882 } else if (node.child !== null) { 11883 node.child['return'] = node; 11884 node = node.child; 11885 continue; 11886 } 11887 if (node === finishedWork) { 11888 return; 11889 } 11890 while (node.sibling === null) { 11891 if (node['return'] === null || node['return'] === finishedWork) { 11892 return; 11893 } 11894 node = node['return']; 11895 } 11896 node.sibling['return'] = node['return']; 11897 node = node.sibling; 11898 } 11899 } 11900 11901 function unmountHostComponents(current) { 11902 // We only have the top Fiber that was inserted but we need recurse down its 11903 var node = current; 11904 11905 // Each iteration, currentParent is populated with node's host parent if not 11906 // currentParentIsValid. 11907 var currentParentIsValid = false; 11908 var currentParent = void 0; 11909 var currentParentIsContainer = void 0; 11910 11911 while (true) { 11912 if (!currentParentIsValid) { 11913 var parent = node['return']; 11914 findParent: while (true) { 11915 !(parent !== null) ? invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0; 11916 switch (parent.tag) { 11917 case HostComponent: 11918 currentParent = parent.stateNode; 11919 currentParentIsContainer = false; 11920 break findParent; 11921 case HostRoot: 11922 currentParent = parent.stateNode.containerInfo; 11923 currentParentIsContainer = true; 11924 break findParent; 11925 case HostPortal: 11926 currentParent = parent.stateNode.containerInfo; 11927 currentParentIsContainer = true; 11928 break findParent; 11929 } 11930 parent = parent['return']; 11931 } 11932 currentParentIsValid = true; 11933 } 11934 11935 if (node.tag === HostComponent || node.tag === HostText) { 11936 commitNestedUnmounts(node); 11937 // After all the children have unmounted, it is now safe to remove the 11938 // node from the tree. 11939 if (currentParentIsContainer) { 11940 removeChildFromContainer(currentParent, node.stateNode); 11941 } else { 11942 removeChild(currentParent, node.stateNode); 11943 } 11944 // Don't visit children because we already visited them. 11945 } else if (node.tag === HostPortal) { 11946 // When we go into a portal, it becomes the parent to remove from. 11947 // We will reassign it back when we pop the portal on the way up. 11948 currentParent = node.stateNode.containerInfo; 11949 // Visit children because portals might contain host components. 11950 if (node.child !== null) { 11951 node.child['return'] = node; 11952 node = node.child; 11953 continue; 11954 } 11955 } else { 11956 commitUnmount(node); 11957 // Visit children because we may find more host components below. 11958 if (node.child !== null) { 11959 node.child['return'] = node; 11960 node = node.child; 11961 continue; 11962 } 11963 } 11964 if (node === current) { 11965 return; 11966 } 11967 while (node.sibling === null) { 11968 if (node['return'] === null || node['return'] === current) { 11969 return; 11970 } 11971 node = node['return']; 11972 if (node.tag === HostPortal) { 11973 // When we go out of the portal, we need to restore the parent. 11974 // Since we don't keep a stack of them, we will search for it. 11975 currentParentIsValid = false; 11976 } 11977 } 11978 node.sibling['return'] = node['return']; 11979 node = node.sibling; 11980 } 11981 } 11982 11983 function commitDeletion(current) { 11984 // Recursively delete all host nodes from the parent. 11985 // Detach refs and call componentWillUnmount() on the whole subtree. 11986 unmountHostComponents(current); 11987 detachFiber(current); 11988 } 11989 11990 function commitWork(current, finishedWork) { 11991 switch (finishedWork.tag) { 11992 case ClassComponent: 11993 { 11994 return; 11995 } 11996 case HostComponent: 11997 { 11998 var instance = finishedWork.stateNode; 11999 if (instance != null) { 12000 // Commit the work prepared earlier. 12001 var newProps = finishedWork.memoizedProps; 12002 // For hydration we reuse the update path but we treat the oldProps 12003 // as the newProps. The updatePayload will contain the real change in 12004 // this case. 12005 var oldProps = current !== null ? current.memoizedProps : newProps; 12006 var type = finishedWork.type; 12007 // TODO: Type the updateQueue to be specific to host components. 12008 var updatePayload = finishedWork.updateQueue; 12009 finishedWork.updateQueue = null; 12010 if (updatePayload !== null) { 12011 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork); 12012 } 12013 } 12014 return; 12015 } 12016 case HostText: 12017 { 12018 !(finishedWork.stateNode !== null) ? invariant(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0; 12019 var textInstance = finishedWork.stateNode; 12020 var newText = finishedWork.memoizedProps; 12021 // For hydration we reuse the update path but we treat the oldProps 12022 // as the newProps. The updatePayload will contain the real change in 12023 // this case. 12024 var oldText = current !== null ? current.memoizedProps : newText; 12025 commitTextUpdate(textInstance, oldText, newText); 12026 return; 12027 } 12028 case HostRoot: 12029 { 12030 return; 12031 } 12032 default: 12033 { 12034 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 12035 } 12036 } 12037 } 12038 12039 function commitResetTextContent(current) { 12040 resetTextContent(current.stateNode); 12041 } 12042 12043 if (enableMutatingReconciler) { 12044 return { 12045 commitResetTextContent: commitResetTextContent, 12046 commitPlacement: commitPlacement, 12047 commitDeletion: commitDeletion, 12048 commitWork: commitWork, 12049 commitLifeCycles: commitLifeCycles, 12050 commitAttachRef: commitAttachRef, 12051 commitDetachRef: commitDetachRef 12052 }; 12053 } else { 12054 invariant(false, 'Mutating reconciler is disabled.'); 12055 } 12056 }; 12057 12058 var NO_CONTEXT = {}; 12059 12060 var ReactFiberHostContext = function (config) { 12061 var getChildHostContext = config.getChildHostContext, 12062 getRootHostContext = config.getRootHostContext; 12063 12064 12065 var contextStackCursor = createCursor(NO_CONTEXT); 12066 var contextFiberStackCursor = createCursor(NO_CONTEXT); 12067 var rootInstanceStackCursor = createCursor(NO_CONTEXT); 12068 12069 function requiredContext(c) { 12070 !(c !== NO_CONTEXT) ? invariant(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0; 12071 return c; 12072 } 12073 12074 function getRootHostContainer() { 12075 var rootInstance = requiredContext(rootInstanceStackCursor.current); 12076 return rootInstance; 12077 } 12078 12079 function pushHostContainer(fiber, nextRootInstance) { 12080 // Push current root instance onto the stack; 12081 // This allows us to reset root when portals are popped. 12082 push(rootInstanceStackCursor, nextRootInstance, fiber); 12083 12084 var nextRootContext = getRootHostContext(nextRootInstance); 12085 12086 // Track the context and the Fiber that provided it. 12087 // This enables us to pop only Fibers that provide unique contexts. 12088 push(contextFiberStackCursor, fiber, fiber); 12089 push(contextStackCursor, nextRootContext, fiber); 12090 } 12091 12092 function popHostContainer(fiber) { 12093 pop(contextStackCursor, fiber); 12094 pop(contextFiberStackCursor, fiber); 12095 pop(rootInstanceStackCursor, fiber); 12096 } 12097 12098 function getHostContext() { 12099 var context = requiredContext(contextStackCursor.current); 12100 return context; 12101 } 12102 12103 function pushHostContext(fiber) { 12104 var rootInstance = requiredContext(rootInstanceStackCursor.current); 12105 var context = requiredContext(contextStackCursor.current); 12106 var nextContext = getChildHostContext(context, fiber.type, rootInstance); 12107 12108 // Don't push this Fiber's context unless it's unique. 12109 if (context === nextContext) { 12110 return; 12111 } 12112 12113 // Track the context and the Fiber that provided it. 12114 // This enables us to pop only Fibers that provide unique contexts. 12115 push(contextFiberStackCursor, fiber, fiber); 12116 push(contextStackCursor, nextContext, fiber); 12117 } 12118 12119 function popHostContext(fiber) { 12120 // Do not pop unless this Fiber provided the current context. 12121 // pushHostContext() only pushes Fibers that provide unique contexts. 12122 if (contextFiberStackCursor.current !== fiber) { 12123 return; 12124 } 12125 12126 pop(contextStackCursor, fiber); 12127 pop(contextFiberStackCursor, fiber); 12128 } 12129 12130 function resetHostContainer() { 12131 contextStackCursor.current = NO_CONTEXT; 12132 rootInstanceStackCursor.current = NO_CONTEXT; 12133 } 12134 12135 return { 12136 getHostContext: getHostContext, 12137 getRootHostContainer: getRootHostContainer, 12138 popHostContainer: popHostContainer, 12139 popHostContext: popHostContext, 12140 pushHostContainer: pushHostContainer, 12141 pushHostContext: pushHostContext, 12142 resetHostContainer: resetHostContainer 12143 }; 12144 }; 12145 12146 var ReactFiberHydrationContext = function (config) { 12147 var shouldSetTextContent = config.shouldSetTextContent, 12148 hydration = config.hydration; 12149 12150 // If this doesn't have hydration mode. 12151 12152 if (!hydration) { 12153 return { 12154 enterHydrationState: function () { 12155 return false; 12156 }, 12157 resetHydrationState: function () {}, 12158 tryToClaimNextHydratableInstance: function () {}, 12159 prepareToHydrateHostInstance: function () { 12160 invariant(false, 'Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'); 12161 }, 12162 prepareToHydrateHostTextInstance: function () { 12163 invariant(false, 'Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'); 12164 }, 12165 popHydrationState: function (fiber) { 12166 return false; 12167 } 12168 }; 12169 } 12170 12171 var canHydrateInstance = hydration.canHydrateInstance, 12172 canHydrateTextInstance = hydration.canHydrateTextInstance, 12173 getNextHydratableSibling = hydration.getNextHydratableSibling, 12174 getFirstHydratableChild = hydration.getFirstHydratableChild, 12175 hydrateInstance = hydration.hydrateInstance, 12176 hydrateTextInstance = hydration.hydrateTextInstance, 12177 didNotMatchHydratedContainerTextInstance = hydration.didNotMatchHydratedContainerTextInstance, 12178 didNotMatchHydratedTextInstance = hydration.didNotMatchHydratedTextInstance, 12179 didNotHydrateContainerInstance = hydration.didNotHydrateContainerInstance, 12180 didNotHydrateInstance = hydration.didNotHydrateInstance, 12181 didNotFindHydratableContainerInstance = hydration.didNotFindHydratableContainerInstance, 12182 didNotFindHydratableContainerTextInstance = hydration.didNotFindHydratableContainerTextInstance, 12183 didNotFindHydratableInstance = hydration.didNotFindHydratableInstance, 12184 didNotFindHydratableTextInstance = hydration.didNotFindHydratableTextInstance; 12185 12186 // The deepest Fiber on the stack involved in a hydration context. 12187 // This may have been an insertion or a hydration. 12188 12189 var hydrationParentFiber = null; 12190 var nextHydratableInstance = null; 12191 var isHydrating = false; 12192 12193 function enterHydrationState(fiber) { 12194 var parentInstance = fiber.stateNode.containerInfo; 12195 nextHydratableInstance = getFirstHydratableChild(parentInstance); 12196 hydrationParentFiber = fiber; 12197 isHydrating = true; 12198 return true; 12199 } 12200 12201 function deleteHydratableInstance(returnFiber, instance) { 12202 { 12203 switch (returnFiber.tag) { 12204 case HostRoot: 12205 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 12206 break; 12207 case HostComponent: 12208 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 12209 break; 12210 } 12211 } 12212 12213 var childToDelete = createFiberFromHostInstanceForDeletion(); 12214 childToDelete.stateNode = instance; 12215 childToDelete['return'] = returnFiber; 12216 childToDelete.effectTag = Deletion; 12217 12218 // This might seem like it belongs on progressedFirstDeletion. However, 12219 // these children are not part of the reconciliation list of children. 12220 // Even if we abort and rereconcile the children, that will try to hydrate 12221 // again and the nodes are still in the host tree so these will be 12222 // recreated. 12223 if (returnFiber.lastEffect !== null) { 12224 returnFiber.lastEffect.nextEffect = childToDelete; 12225 returnFiber.lastEffect = childToDelete; 12226 } else { 12227 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 12228 } 12229 } 12230 12231 function insertNonHydratedInstance(returnFiber, fiber) { 12232 fiber.effectTag |= Placement; 12233 { 12234 switch (returnFiber.tag) { 12235 case HostRoot: 12236 { 12237 var parentContainer = returnFiber.stateNode.containerInfo; 12238 switch (fiber.tag) { 12239 case HostComponent: 12240 var type = fiber.type; 12241 var props = fiber.pendingProps; 12242 didNotFindHydratableContainerInstance(parentContainer, type, props); 12243 break; 12244 case HostText: 12245 var text = fiber.pendingProps; 12246 didNotFindHydratableContainerTextInstance(parentContainer, text); 12247 break; 12248 } 12249 break; 12250 } 12251 case HostComponent: 12252 { 12253 var parentType = returnFiber.type; 12254 var parentProps = returnFiber.memoizedProps; 12255 var parentInstance = returnFiber.stateNode; 12256 switch (fiber.tag) { 12257 case HostComponent: 12258 var _type = fiber.type; 12259 var _props = fiber.pendingProps; 12260 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props); 12261 break; 12262 case HostText: 12263 var _text = fiber.pendingProps; 12264 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 12265 break; 12266 } 12267 break; 12268 } 12269 default: 12270 return; 12271 } 12272 } 12273 } 12274 12275 function tryHydrate(fiber, nextInstance) { 12276 switch (fiber.tag) { 12277 case HostComponent: 12278 { 12279 var type = fiber.type; 12280 var props = fiber.pendingProps; 12281 var instance = canHydrateInstance(nextInstance, type, props); 12282 if (instance !== null) { 12283 fiber.stateNode = instance; 12284 return true; 12285 } 12286 return false; 12287 } 12288 case HostText: 12289 { 12290 var text = fiber.pendingProps; 12291 var textInstance = canHydrateTextInstance(nextInstance, text); 12292 if (textInstance !== null) { 12293 fiber.stateNode = textInstance; 12294 return true; 12295 } 12296 return false; 12297 } 12298 default: 12299 return false; 12300 } 12301 } 12302 12303 function tryToClaimNextHydratableInstance(fiber) { 12304 if (!isHydrating) { 12305 return; 12306 } 12307 var nextInstance = nextHydratableInstance; 12308 if (!nextInstance) { 12309 // Nothing to hydrate. Make it an insertion. 12310 insertNonHydratedInstance(hydrationParentFiber, fiber); 12311 isHydrating = false; 12312 hydrationParentFiber = fiber; 12313 return; 12314 } 12315 if (!tryHydrate(fiber, nextInstance)) { 12316 // If we can't hydrate this instance let's try the next one. 12317 // We use this as a heuristic. It's based on intuition and not data so it 12318 // might be flawed or unnecessary. 12319 nextInstance = getNextHydratableSibling(nextInstance); 12320 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 12321 // Nothing to hydrate. Make it an insertion. 12322 insertNonHydratedInstance(hydrationParentFiber, fiber); 12323 isHydrating = false; 12324 hydrationParentFiber = fiber; 12325 return; 12326 } 12327 // We matched the next one, we'll now assume that the first one was 12328 // superfluous and we'll delete it. Since we can't eagerly delete it 12329 // we'll have to schedule a deletion. To do that, this node needs a dummy 12330 // fiber associated with it. 12331 deleteHydratableInstance(hydrationParentFiber, nextHydratableInstance); 12332 } 12333 hydrationParentFiber = fiber; 12334 nextHydratableInstance = getFirstHydratableChild(nextInstance); 12335 } 12336 12337 function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 12338 var instance = fiber.stateNode; 12339 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); 12340 // TODO: Type this specific to this type of component. 12341 fiber.updateQueue = updatePayload; 12342 // If the update payload indicates that there is a change or if there 12343 // is a new ref we mark this as an update. 12344 if (updatePayload !== null) { 12345 return true; 12346 } 12347 return false; 12348 } 12349 12350 function prepareToHydrateHostTextInstance(fiber) { 12351 var textInstance = fiber.stateNode; 12352 var textContent = fiber.memoizedProps; 12353 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 12354 { 12355 if (shouldUpdate) { 12356 // We assume that prepareToHydrateHostTextInstance is called in a context where the 12357 // hydration parent is the parent host component of this host text. 12358 var returnFiber = hydrationParentFiber; 12359 if (returnFiber !== null) { 12360 switch (returnFiber.tag) { 12361 case HostRoot: 12362 { 12363 var parentContainer = returnFiber.stateNode.containerInfo; 12364 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 12365 break; 12366 } 12367 case HostComponent: 12368 { 12369 var parentType = returnFiber.type; 12370 var parentProps = returnFiber.memoizedProps; 12371 var parentInstance = returnFiber.stateNode; 12372 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 12373 break; 12374 } 12375 } 12376 } 12377 } 12378 } 12379 return shouldUpdate; 12380 } 12381 12382 function popToNextHostParent(fiber) { 12383 var parent = fiber['return']; 12384 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) { 12385 parent = parent['return']; 12386 } 12387 hydrationParentFiber = parent; 12388 } 12389 12390 function popHydrationState(fiber) { 12391 if (fiber !== hydrationParentFiber) { 12392 // We're deeper than the current hydration context, inside an inserted 12393 // tree. 12394 return false; 12395 } 12396 if (!isHydrating) { 12397 // If we're not currently hydrating but we're in a hydration context, then 12398 // we were an insertion and now need to pop up reenter hydration of our 12399 // siblings. 12400 popToNextHostParent(fiber); 12401 isHydrating = true; 12402 return false; 12403 } 12404 12405 var type = fiber.type; 12406 12407 // If we have any remaining hydratable nodes, we need to delete them now. 12408 // We only do this deeper than head and body since they tend to have random 12409 // other nodes in them. We also ignore components with pure text content in 12410 // side of them. 12411 // TODO: Better heuristic. 12412 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 12413 var nextInstance = nextHydratableInstance; 12414 while (nextInstance) { 12415 deleteHydratableInstance(fiber, nextInstance); 12416 nextInstance = getNextHydratableSibling(nextInstance); 12417 } 12418 } 12419 12420 popToNextHostParent(fiber); 12421 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 12422 return true; 12423 } 12424 12425 function resetHydrationState() { 12426 hydrationParentFiber = null; 12427 nextHydratableInstance = null; 12428 isHydrating = false; 12429 } 12430 12431 return { 12432 enterHydrationState: enterHydrationState, 12433 resetHydrationState: resetHydrationState, 12434 tryToClaimNextHydratableInstance: tryToClaimNextHydratableInstance, 12435 prepareToHydrateHostInstance: prepareToHydrateHostInstance, 12436 prepareToHydrateHostTextInstance: prepareToHydrateHostTextInstance, 12437 popHydrationState: popHydrationState 12438 }; 12439 }; 12440 12441 // This lets us hook into Fiber to debug what it's doing. 12442 // See https://github.com/facebook/react/pull/8033. 12443 // This is not part of the public API, not even for React DevTools. 12444 // You may only inject a debugTool if you work on React Fiber itself. 12445 var ReactFiberInstrumentation = { 12446 debugTool: null 12447 }; 12448 12449 var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; 12450 12451 var defaultShowDialog = function (capturedError) { 12452 return true; 12453 }; 12454 12455 var showDialog = defaultShowDialog; 12456 12457 function logCapturedError(capturedError) { 12458 var logError = showDialog(capturedError); 12459 12460 // Allow injected showDialog() to prevent default console.error logging. 12461 // This enables renderers like ReactNative to better manage redbox behavior. 12462 if (logError === false) { 12463 return; 12464 } 12465 12466 var error = capturedError.error; 12467 var suppressLogging = error && error.suppressReactErrorLogging; 12468 if (suppressLogging) { 12469 return; 12470 } 12471 12472 { 12473 var componentName = capturedError.componentName, 12474 componentStack = capturedError.componentStack, 12475 errorBoundaryName = capturedError.errorBoundaryName, 12476 errorBoundaryFound = capturedError.errorBoundaryFound, 12477 willRetry = capturedError.willRetry; 12478 12479 12480 var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:'; 12481 12482 var errorBoundaryMessage = void 0; 12483 // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. 12484 if (errorBoundaryFound && errorBoundaryName) { 12485 if (willRetry) { 12486 errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.'); 12487 } else { 12488 errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.'; 12489 } 12490 } else { 12491 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.'; 12492 } 12493 var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage); 12494 12495 // In development, we provide our own message with just the component stack. 12496 // We don't include the original error message and JS stack because the browser 12497 // has already printed it. Even if the application swallows the error, it is still 12498 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 12499 console.error(combinedMessage); 12500 } 12501 } 12502 12503 var invokeGuardedCallback$1 = ReactErrorUtils.invokeGuardedCallback; 12504 var hasCaughtError = ReactErrorUtils.hasCaughtError; 12505 var clearCaughtError = ReactErrorUtils.clearCaughtError; 12506 12507 12508 { 12509 var didWarnAboutStateTransition = false; 12510 var didWarnSetStateChildContext = false; 12511 var didWarnStateUpdateForUnmountedComponent = {}; 12512 12513 var warnAboutUpdateOnUnmounted = function (fiber) { 12514 var componentName = getComponentName(fiber) || 'ReactClass'; 12515 if (didWarnStateUpdateForUnmountedComponent[componentName]) { 12516 return; 12517 } 12518 warning(false, 'Can only update a mounted or mounting ' + 'component. This usually means you called setState, replaceState, ' + 'or forceUpdate on an unmounted component. This is a no-op.\n\nPlease ' + 'check the code for the %s component.', componentName); 12519 didWarnStateUpdateForUnmountedComponent[componentName] = true; 12520 }; 12521 12522 var warnAboutInvalidUpdates = function (instance) { 12523 switch (ReactDebugCurrentFiber.phase) { 12524 case 'getChildContext': 12525 if (didWarnSetStateChildContext) { 12526 return; 12527 } 12528 warning(false, 'setState(...): Cannot call setState() inside getChildContext()'); 12529 didWarnSetStateChildContext = true; 12530 break; 12531 case 'render': 12532 if (didWarnAboutStateTransition) { 12533 return; 12534 } 12535 warning(false, 'Cannot update during an existing state transition (such as within ' + "`render` or another component's constructor). Render methods should " + 'be a pure function of props and state; constructor side-effects are ' + 'an anti-pattern, but can be moved to `componentWillMount`.'); 12536 didWarnAboutStateTransition = true; 12537 break; 12538 } 12539 }; 12540 } 12541 12542 var ReactFiberScheduler = function (config) { 12543 var hostContext = ReactFiberHostContext(config); 12544 var hydrationContext = ReactFiberHydrationContext(config); 12545 var popHostContainer = hostContext.popHostContainer, 12546 popHostContext = hostContext.popHostContext, 12547 resetHostContainer = hostContext.resetHostContainer; 12548 12549 var _ReactFiberBeginWork = ReactFiberBeginWork(config, hostContext, hydrationContext, scheduleWork, computeExpirationForFiber), 12550 beginWork = _ReactFiberBeginWork.beginWork, 12551 beginFailedWork = _ReactFiberBeginWork.beginFailedWork; 12552 12553 var _ReactFiberCompleteWo = ReactFiberCompleteWork(config, hostContext, hydrationContext), 12554 completeWork = _ReactFiberCompleteWo.completeWork; 12555 12556 var _ReactFiberCommitWork = ReactFiberCommitWork(config, captureError), 12557 commitResetTextContent = _ReactFiberCommitWork.commitResetTextContent, 12558 commitPlacement = _ReactFiberCommitWork.commitPlacement, 12559 commitDeletion = _ReactFiberCommitWork.commitDeletion, 12560 commitWork = _ReactFiberCommitWork.commitWork, 12561 commitLifeCycles = _ReactFiberCommitWork.commitLifeCycles, 12562 commitAttachRef = _ReactFiberCommitWork.commitAttachRef, 12563 commitDetachRef = _ReactFiberCommitWork.commitDetachRef; 12564 12565 var now = config.now, 12566 scheduleDeferredCallback = config.scheduleDeferredCallback, 12567 cancelDeferredCallback = config.cancelDeferredCallback, 12568 useSyncScheduling = config.useSyncScheduling, 12569 prepareForCommit = config.prepareForCommit, 12570 resetAfterCommit = config.resetAfterCommit; 12571 12572 // Represents the current time in ms. 12573 12574 var startTime = now(); 12575 var mostRecentCurrentTime = msToExpirationTime(0); 12576 12577 // Represents the expiration time that incoming updates should use. (If this 12578 // is NoWork, use the default strategy: async updates in async mode, sync 12579 // updates in sync mode.) 12580 var expirationContext = NoWork; 12581 12582 var isWorking = false; 12583 12584 // The next work in progress fiber that we're currently working on. 12585 var nextUnitOfWork = null; 12586 var nextRoot = null; 12587 // The time at which we're currently rendering work. 12588 var nextRenderExpirationTime = NoWork; 12589 12590 // The next fiber with an effect that we're currently committing. 12591 var nextEffect = null; 12592 12593 // Keep track of which fibers have captured an error that need to be handled. 12594 // Work is removed from this collection after componentDidCatch is called. 12595 var capturedErrors = null; 12596 // Keep track of which fibers have failed during the current batch of work. 12597 // This is a different set than capturedErrors, because it is not reset until 12598 // the end of the batch. This is needed to propagate errors correctly if a 12599 // subtree fails more than once. 12600 var failedBoundaries = null; 12601 // Error boundaries that captured an error during the current commit. 12602 var commitPhaseBoundaries = null; 12603 var firstUncaughtError = null; 12604 var didFatal = false; 12605 12606 var isCommitting = false; 12607 var isUnmounting = false; 12608 12609 // Used for performance tracking. 12610 var interruptedBy = null; 12611 12612 function resetContextStack() { 12613 // Reset the stack 12614 reset$1(); 12615 // Reset the cursors 12616 resetContext(); 12617 resetHostContainer(); 12618 } 12619 12620 function commitAllHostEffects() { 12621 while (nextEffect !== null) { 12622 { 12623 ReactDebugCurrentFiber.setCurrentFiber(nextEffect); 12624 } 12625 recordEffect(); 12626 12627 var effectTag = nextEffect.effectTag; 12628 if (effectTag & ContentReset) { 12629 commitResetTextContent(nextEffect); 12630 } 12631 12632 if (effectTag & Ref) { 12633 var current = nextEffect.alternate; 12634 if (current !== null) { 12635 commitDetachRef(current); 12636 } 12637 } 12638 12639 // The following switch statement is only concerned about placement, 12640 // updates, and deletions. To avoid needing to add a case for every 12641 // possible bitmap value, we remove the secondary effects from the 12642 // effect tag and switch on that value. 12643 var primaryEffectTag = effectTag & ~(Callback | Err | ContentReset | Ref | PerformedWork); 12644 switch (primaryEffectTag) { 12645 case Placement: 12646 { 12647 commitPlacement(nextEffect); 12648 // Clear the "placement" from effect tag so that we know that this is inserted, before 12649 // any life-cycles like componentDidMount gets called. 12650 // TODO: findDOMNode doesn't rely on this any more but isMounted 12651 // does and isMounted is deprecated anyway so we should be able 12652 // to kill this. 12653 nextEffect.effectTag &= ~Placement; 12654 break; 12655 } 12656 case PlacementAndUpdate: 12657 { 12658 // Placement 12659 commitPlacement(nextEffect); 12660 // Clear the "placement" from effect tag so that we know that this is inserted, before 12661 // any life-cycles like componentDidMount gets called. 12662 nextEffect.effectTag &= ~Placement; 12663 12664 // Update 12665 var _current = nextEffect.alternate; 12666 commitWork(_current, nextEffect); 12667 break; 12668 } 12669 case Update: 12670 { 12671 var _current2 = nextEffect.alternate; 12672 commitWork(_current2, nextEffect); 12673 break; 12674 } 12675 case Deletion: 12676 { 12677 isUnmounting = true; 12678 commitDeletion(nextEffect); 12679 isUnmounting = false; 12680 break; 12681 } 12682 } 12683 nextEffect = nextEffect.nextEffect; 12684 } 12685 12686 { 12687 ReactDebugCurrentFiber.resetCurrentFiber(); 12688 } 12689 } 12690 12691 function commitAllLifeCycles() { 12692 while (nextEffect !== null) { 12693 var effectTag = nextEffect.effectTag; 12694 12695 if (effectTag & (Update | Callback)) { 12696 recordEffect(); 12697 var current = nextEffect.alternate; 12698 commitLifeCycles(current, nextEffect); 12699 } 12700 12701 if (effectTag & Ref) { 12702 recordEffect(); 12703 commitAttachRef(nextEffect); 12704 } 12705 12706 if (effectTag & Err) { 12707 recordEffect(); 12708 commitErrorHandling(nextEffect); 12709 } 12710 12711 var next = nextEffect.nextEffect; 12712 // Ensure that we clean these up so that we don't accidentally keep them. 12713 // I'm not actually sure this matters because we can't reset firstEffect 12714 // and lastEffect since they're on every node, not just the effectful 12715 // ones. So we have to clean everything as we reuse nodes anyway. 12716 nextEffect.nextEffect = null; 12717 // Ensure that we reset the effectTag here so that we can rely on effect 12718 // tags to reason about the current life-cycle. 12719 nextEffect = next; 12720 } 12721 } 12722 12723 function commitRoot(finishedWork) { 12724 // We keep track of this so that captureError can collect any boundaries 12725 // that capture an error during the commit phase. The reason these aren't 12726 // local to this function is because errors that occur during cWU are 12727 // captured elsewhere, to prevent the unmount from being interrupted. 12728 isWorking = true; 12729 isCommitting = true; 12730 startCommitTimer(); 12731 12732 var root = finishedWork.stateNode; 12733 !(root.current !== finishedWork) ? invariant(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0; 12734 root.isReadyForCommit = false; 12735 12736 // Reset this to null before calling lifecycles 12737 ReactCurrentOwner.current = null; 12738 12739 var firstEffect = void 0; 12740 if (finishedWork.effectTag > PerformedWork) { 12741 // A fiber's effect list consists only of its children, not itself. So if 12742 // the root has an effect, we need to add it to the end of the list. The 12743 // resulting list is the set that would belong to the root's parent, if 12744 // it had one; that is, all the effects in the tree including the root. 12745 if (finishedWork.lastEffect !== null) { 12746 finishedWork.lastEffect.nextEffect = finishedWork; 12747 firstEffect = finishedWork.firstEffect; 12748 } else { 12749 firstEffect = finishedWork; 12750 } 12751 } else { 12752 // There is no effect on the root. 12753 firstEffect = finishedWork.firstEffect; 12754 } 12755 12756 prepareForCommit(); 12757 12758 // Commit all the side-effects within a tree. We'll do this in two passes. 12759 // The first pass performs all the host insertions, updates, deletions and 12760 // ref unmounts. 12761 nextEffect = firstEffect; 12762 startCommitHostEffectsTimer(); 12763 while (nextEffect !== null) { 12764 var didError = false; 12765 var _error = void 0; 12766 { 12767 invokeGuardedCallback$1(null, commitAllHostEffects, null); 12768 if (hasCaughtError()) { 12769 didError = true; 12770 _error = clearCaughtError(); 12771 } 12772 } 12773 if (didError) { 12774 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0; 12775 captureError(nextEffect, _error); 12776 // Clean-up 12777 if (nextEffect !== null) { 12778 nextEffect = nextEffect.nextEffect; 12779 } 12780 } 12781 } 12782 stopCommitHostEffectsTimer(); 12783 12784 resetAfterCommit(); 12785 12786 // The work-in-progress tree is now the current tree. This must come after 12787 // the first pass of the commit phase, so that the previous tree is still 12788 // current during componentWillUnmount, but before the second pass, so that 12789 // the finished work is current during componentDidMount/Update. 12790 root.current = finishedWork; 12791 12792 // In the second pass we'll perform all life-cycles and ref callbacks. 12793 // Life-cycles happen as a separate pass so that all placements, updates, 12794 // and deletions in the entire tree have already been invoked. 12795 // This pass also triggers any renderer-specific initial effects. 12796 nextEffect = firstEffect; 12797 startCommitLifeCyclesTimer(); 12798 while (nextEffect !== null) { 12799 var _didError = false; 12800 var _error2 = void 0; 12801 { 12802 invokeGuardedCallback$1(null, commitAllLifeCycles, null); 12803 if (hasCaughtError()) { 12804 _didError = true; 12805 _error2 = clearCaughtError(); 12806 } 12807 } 12808 if (_didError) { 12809 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0; 12810 captureError(nextEffect, _error2); 12811 if (nextEffect !== null) { 12812 nextEffect = nextEffect.nextEffect; 12813 } 12814 } 12815 } 12816 12817 isCommitting = false; 12818 isWorking = false; 12819 stopCommitLifeCyclesTimer(); 12820 stopCommitTimer(); 12821 if (typeof onCommitRoot === 'function') { 12822 onCommitRoot(finishedWork.stateNode); 12823 } 12824 if (true && ReactFiberInstrumentation_1.debugTool) { 12825 ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork); 12826 } 12827 12828 // If we caught any errors during this commit, schedule their boundaries 12829 // to update. 12830 if (commitPhaseBoundaries) { 12831 commitPhaseBoundaries.forEach(scheduleErrorRecovery); 12832 commitPhaseBoundaries = null; 12833 } 12834 12835 if (firstUncaughtError !== null) { 12836 var _error3 = firstUncaughtError; 12837 firstUncaughtError = null; 12838 onUncaughtError(_error3); 12839 } 12840 12841 var remainingTime = root.current.expirationTime; 12842 12843 if (remainingTime === NoWork) { 12844 capturedErrors = null; 12845 failedBoundaries = null; 12846 } 12847 12848 return remainingTime; 12849 } 12850 12851 function resetExpirationTime(workInProgress, renderTime) { 12852 if (renderTime !== Never && workInProgress.expirationTime === Never) { 12853 // The children of this component are hidden. Don't bubble their 12854 // expiration times. 12855 return; 12856 } 12857 12858 // Check for pending updates. 12859 var newExpirationTime = getUpdateExpirationTime(workInProgress); 12860 12861 // TODO: Calls need to visit stateNode 12862 12863 // Bubble up the earliest expiration time. 12864 var child = workInProgress.child; 12865 while (child !== null) { 12866 if (child.expirationTime !== NoWork && (newExpirationTime === NoWork || newExpirationTime > child.expirationTime)) { 12867 newExpirationTime = child.expirationTime; 12868 } 12869 child = child.sibling; 12870 } 12871 workInProgress.expirationTime = newExpirationTime; 12872 } 12873 12874 function completeUnitOfWork(workInProgress) { 12875 while (true) { 12876 // The current, flushed, state of this fiber is the alternate. 12877 // Ideally nothing should rely on this, but relying on it here 12878 // means that we don't need an additional field on the work in 12879 // progress. 12880 var current = workInProgress.alternate; 12881 { 12882 ReactDebugCurrentFiber.setCurrentFiber(workInProgress); 12883 } 12884 var next = completeWork(current, workInProgress, nextRenderExpirationTime); 12885 { 12886 ReactDebugCurrentFiber.resetCurrentFiber(); 12887 } 12888 12889 var returnFiber = workInProgress['return']; 12890 var siblingFiber = workInProgress.sibling; 12891 12892 resetExpirationTime(workInProgress, nextRenderExpirationTime); 12893 12894 if (next !== null) { 12895 stopWorkTimer(workInProgress); 12896 if (true && ReactFiberInstrumentation_1.debugTool) { 12897 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 12898 } 12899 // If completing this work spawned new work, do that next. We'll come 12900 // back here again. 12901 return next; 12902 } 12903 12904 if (returnFiber !== null) { 12905 // Append all the effects of the subtree and this fiber onto the effect 12906 // list of the parent. The completion order of the children affects the 12907 // side-effect order. 12908 if (returnFiber.firstEffect === null) { 12909 returnFiber.firstEffect = workInProgress.firstEffect; 12910 } 12911 if (workInProgress.lastEffect !== null) { 12912 if (returnFiber.lastEffect !== null) { 12913 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; 12914 } 12915 returnFiber.lastEffect = workInProgress.lastEffect; 12916 } 12917 12918 // If this fiber had side-effects, we append it AFTER the children's 12919 // side-effects. We can perform certain side-effects earlier if 12920 // needed, by doing multiple passes over the effect list. We don't want 12921 // to schedule our own side-effect on our own list because if end up 12922 // reusing children we'll schedule this effect onto itself since we're 12923 // at the end. 12924 var effectTag = workInProgress.effectTag; 12925 // Skip both NoWork and PerformedWork tags when creating the effect list. 12926 // PerformedWork effect is read by React DevTools but shouldn't be committed. 12927 if (effectTag > PerformedWork) { 12928 if (returnFiber.lastEffect !== null) { 12929 returnFiber.lastEffect.nextEffect = workInProgress; 12930 } else { 12931 returnFiber.firstEffect = workInProgress; 12932 } 12933 returnFiber.lastEffect = workInProgress; 12934 } 12935 } 12936 12937 stopWorkTimer(workInProgress); 12938 if (true && ReactFiberInstrumentation_1.debugTool) { 12939 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 12940 } 12941 12942 if (siblingFiber !== null) { 12943 // If there is more work to do in this returnFiber, do that next. 12944 return siblingFiber; 12945 } else if (returnFiber !== null) { 12946 // If there's no more work in this returnFiber. Complete the returnFiber. 12947 workInProgress = returnFiber; 12948 continue; 12949 } else { 12950 // We've reached the root. 12951 var root = workInProgress.stateNode; 12952 root.isReadyForCommit = true; 12953 return null; 12954 } 12955 } 12956 12957 // Without this explicit null return Flow complains of invalid return type 12958 // TODO Remove the above while(true) loop 12959 // eslint-disable-next-line no-unreachable 12960 return null; 12961 } 12962 12963 function performUnitOfWork(workInProgress) { 12964 // The current, flushed, state of this fiber is the alternate. 12965 // Ideally nothing should rely on this, but relying on it here 12966 // means that we don't need an additional field on the work in 12967 // progress. 12968 var current = workInProgress.alternate; 12969 12970 // See if beginning this work spawns more work. 12971 startWorkTimer(workInProgress); 12972 { 12973 ReactDebugCurrentFiber.setCurrentFiber(workInProgress); 12974 } 12975 12976 var next = beginWork(current, workInProgress, nextRenderExpirationTime); 12977 { 12978 ReactDebugCurrentFiber.resetCurrentFiber(); 12979 } 12980 if (true && ReactFiberInstrumentation_1.debugTool) { 12981 ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress); 12982 } 12983 12984 if (next === null) { 12985 // If this doesn't spawn new work, complete the current work. 12986 next = completeUnitOfWork(workInProgress); 12987 } 12988 12989 ReactCurrentOwner.current = null; 12990 12991 return next; 12992 } 12993 12994 function performFailedUnitOfWork(workInProgress) { 12995 // The current, flushed, state of this fiber is the alternate. 12996 // Ideally nothing should rely on this, but relying on it here 12997 // means that we don't need an additional field on the work in 12998 // progress. 12999 var current = workInProgress.alternate; 13000 13001 // See if beginning this work spawns more work. 13002 startWorkTimer(workInProgress); 13003 { 13004 ReactDebugCurrentFiber.setCurrentFiber(workInProgress); 13005 } 13006 var next = beginFailedWork(current, workInProgress, nextRenderExpirationTime); 13007 { 13008 ReactDebugCurrentFiber.resetCurrentFiber(); 13009 } 13010 if (true && ReactFiberInstrumentation_1.debugTool) { 13011 ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress); 13012 } 13013 13014 if (next === null) { 13015 // If this doesn't spawn new work, complete the current work. 13016 next = completeUnitOfWork(workInProgress); 13017 } 13018 13019 ReactCurrentOwner.current = null; 13020 13021 return next; 13022 } 13023 13024 function workLoop(expirationTime) { 13025 if (capturedErrors !== null) { 13026 // If there are unhandled errors, switch to the slow work loop. 13027 // TODO: How to avoid this check in the fast path? Maybe the renderer 13028 // could keep track of which roots have unhandled errors and call a 13029 // forked version of renderRoot. 13030 slowWorkLoopThatChecksForFailedWork(expirationTime); 13031 return; 13032 } 13033 if (nextRenderExpirationTime === NoWork || nextRenderExpirationTime > expirationTime) { 13034 return; 13035 } 13036 13037 if (nextRenderExpirationTime <= mostRecentCurrentTime) { 13038 // Flush all expired work. 13039 while (nextUnitOfWork !== null) { 13040 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 13041 } 13042 } else { 13043 // Flush asynchronous work until the deadline runs out of time. 13044 while (nextUnitOfWork !== null && !shouldYield()) { 13045 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 13046 } 13047 } 13048 } 13049 13050 function slowWorkLoopThatChecksForFailedWork(expirationTime) { 13051 if (nextRenderExpirationTime === NoWork || nextRenderExpirationTime > expirationTime) { 13052 return; 13053 } 13054 13055 if (nextRenderExpirationTime <= mostRecentCurrentTime) { 13056 // Flush all expired work. 13057 while (nextUnitOfWork !== null) { 13058 if (hasCapturedError(nextUnitOfWork)) { 13059 // Use a forked version of performUnitOfWork 13060 nextUnitOfWork = performFailedUnitOfWork(nextUnitOfWork); 13061 } else { 13062 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 13063 } 13064 } 13065 } else { 13066 // Flush asynchronous work until the deadline runs out of time. 13067 while (nextUnitOfWork !== null && !shouldYield()) { 13068 if (hasCapturedError(nextUnitOfWork)) { 13069 // Use a forked version of performUnitOfWork 13070 nextUnitOfWork = performFailedUnitOfWork(nextUnitOfWork); 13071 } else { 13072 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 13073 } 13074 } 13075 } 13076 } 13077 13078 function renderRootCatchBlock(root, failedWork, boundary, expirationTime) { 13079 // We're going to restart the error boundary that captured the error. 13080 // Conceptually, we're unwinding the stack. We need to unwind the 13081 // context stack, too. 13082 unwindContexts(failedWork, boundary); 13083 13084 // Restart the error boundary using a forked version of 13085 // performUnitOfWork that deletes the boundary's children. The entire 13086 // failed subree will be unmounted. During the commit phase, a special 13087 // lifecycle method is called on the error boundary, which triggers 13088 // a re-render. 13089 nextUnitOfWork = performFailedUnitOfWork(boundary); 13090 13091 // Continue working. 13092 workLoop(expirationTime); 13093 } 13094 13095 function renderRoot(root, expirationTime) { 13096 !!isWorking ? invariant(false, 'renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13097 isWorking = true; 13098 13099 // We're about to mutate the work-in-progress tree. If the root was pending 13100 // commit, it no longer is: we'll need to complete it again. 13101 root.isReadyForCommit = false; 13102 13103 // Check if we're starting from a fresh stack, or if we're resuming from 13104 // previously yielded work. 13105 if (root !== nextRoot || expirationTime !== nextRenderExpirationTime || nextUnitOfWork === null) { 13106 // Reset the stack and start working from the root. 13107 resetContextStack(); 13108 nextRoot = root; 13109 nextRenderExpirationTime = expirationTime; 13110 nextUnitOfWork = createWorkInProgress(nextRoot.current, null, expirationTime); 13111 } 13112 13113 startWorkLoopTimer(nextUnitOfWork); 13114 13115 var didError = false; 13116 var error = null; 13117 { 13118 invokeGuardedCallback$1(null, workLoop, null, expirationTime); 13119 if (hasCaughtError()) { 13120 didError = true; 13121 error = clearCaughtError(); 13122 } 13123 } 13124 13125 // An error was thrown during the render phase. 13126 while (didError) { 13127 if (didFatal) { 13128 // This was a fatal error. Don't attempt to recover from it. 13129 firstUncaughtError = error; 13130 break; 13131 } 13132 13133 var failedWork = nextUnitOfWork; 13134 if (failedWork === null) { 13135 // An error was thrown but there's no current unit of work. This can 13136 // happen during the commit phase if there's a bug in the renderer. 13137 didFatal = true; 13138 continue; 13139 } 13140 13141 // "Capture" the error by finding the nearest boundary. If there is no 13142 // error boundary, we use the root. 13143 var boundary = captureError(failedWork, error); 13144 !(boundary !== null) ? invariant(false, 'Should have found an error boundary. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13145 13146 if (didFatal) { 13147 // The error we just captured was a fatal error. This happens 13148 // when the error propagates to the root more than once. 13149 continue; 13150 } 13151 13152 didError = false; 13153 error = null; 13154 { 13155 invokeGuardedCallback$1(null, renderRootCatchBlock, null, root, failedWork, boundary, expirationTime); 13156 if (hasCaughtError()) { 13157 didError = true; 13158 error = clearCaughtError(); 13159 continue; 13160 } 13161 } 13162 // We're finished working. Exit the error loop. 13163 break; 13164 } 13165 13166 var uncaughtError = firstUncaughtError; 13167 13168 // We're done performing work. Time to clean up. 13169 stopWorkLoopTimer(interruptedBy); 13170 interruptedBy = null; 13171 isWorking = false; 13172 didFatal = false; 13173 firstUncaughtError = null; 13174 13175 if (uncaughtError !== null) { 13176 onUncaughtError(uncaughtError); 13177 } 13178 13179 return root.isReadyForCommit ? root.current.alternate : null; 13180 } 13181 13182 // Returns the boundary that captured the error, or null if the error is ignored 13183 function captureError(failedWork, error) { 13184 // It is no longer valid because we exited the user code. 13185 ReactCurrentOwner.current = null; 13186 { 13187 ReactDebugCurrentFiber.resetCurrentFiber(); 13188 } 13189 13190 // Search for the nearest error boundary. 13191 var boundary = null; 13192 13193 // Passed to logCapturedError() 13194 var errorBoundaryFound = false; 13195 var willRetry = false; 13196 var errorBoundaryName = null; 13197 13198 // Host containers are a special case. If the failed work itself is a host 13199 // container, then it acts as its own boundary. In all other cases, we 13200 // ignore the work itself and only search through the parents. 13201 if (failedWork.tag === HostRoot) { 13202 boundary = failedWork; 13203 13204 if (isFailedBoundary(failedWork)) { 13205 // If this root already failed, there must have been an error when 13206 // attempting to unmount it. This is a worst-case scenario and 13207 // should only be possible if there's a bug in the renderer. 13208 didFatal = true; 13209 } 13210 } else { 13211 var node = failedWork['return']; 13212 while (node !== null && boundary === null) { 13213 if (node.tag === ClassComponent) { 13214 var instance = node.stateNode; 13215 if (typeof instance.componentDidCatch === 'function') { 13216 errorBoundaryFound = true; 13217 errorBoundaryName = getComponentName(node); 13218 13219 // Found an error boundary! 13220 boundary = node; 13221 willRetry = true; 13222 } 13223 } else if (node.tag === HostRoot) { 13224 // Treat the root like a no-op error boundary 13225 boundary = node; 13226 } 13227 13228 if (isFailedBoundary(node)) { 13229 // This boundary is already in a failed state. 13230 13231 // If we're currently unmounting, that means this error was 13232 // thrown while unmounting a failed subtree. We should ignore 13233 // the error. 13234 if (isUnmounting) { 13235 return null; 13236 } 13237 13238 // If we're in the commit phase, we should check to see if 13239 // this boundary already captured an error during this commit. 13240 // This case exists because multiple errors can be thrown during 13241 // a single commit without interruption. 13242 if (commitPhaseBoundaries !== null && (commitPhaseBoundaries.has(node) || node.alternate !== null && commitPhaseBoundaries.has(node.alternate))) { 13243 // If so, we should ignore this error. 13244 return null; 13245 } 13246 13247 // The error should propagate to the next boundary -— we keep looking. 13248 boundary = null; 13249 willRetry = false; 13250 } 13251 13252 node = node['return']; 13253 } 13254 } 13255 13256 if (boundary !== null) { 13257 // Add to the collection of failed boundaries. This lets us know that 13258 // subsequent errors in this subtree should propagate to the next boundary. 13259 if (failedBoundaries === null) { 13260 failedBoundaries = new Set(); 13261 } 13262 failedBoundaries.add(boundary); 13263 13264 // This method is unsafe outside of the begin and complete phases. 13265 // We might be in the commit phase when an error is captured. 13266 // The risk is that the return path from this Fiber may not be accurate. 13267 // That risk is acceptable given the benefit of providing users more context. 13268 var _componentStack = getStackAddendumByWorkInProgressFiber(failedWork); 13269 var _componentName = getComponentName(failedWork); 13270 13271 // Add to the collection of captured errors. This is stored as a global 13272 // map of errors and their component stack location keyed by the boundaries 13273 // that capture them. We mostly use this Map as a Set; it's a Map only to 13274 // avoid adding a field to Fiber to store the error. 13275 if (capturedErrors === null) { 13276 capturedErrors = new Map(); 13277 } 13278 13279 var capturedError = { 13280 componentName: _componentName, 13281 componentStack: _componentStack, 13282 error: error, 13283 errorBoundary: errorBoundaryFound ? boundary.stateNode : null, 13284 errorBoundaryFound: errorBoundaryFound, 13285 errorBoundaryName: errorBoundaryName, 13286 willRetry: willRetry 13287 }; 13288 13289 capturedErrors.set(boundary, capturedError); 13290 13291 try { 13292 logCapturedError(capturedError); 13293 } catch (e) { 13294 // Prevent cycle if logCapturedError() throws. 13295 // A cycle may still occur if logCapturedError renders a component that throws. 13296 var suppressLogging = e && e.suppressReactErrorLogging; 13297 if (!suppressLogging) { 13298 console.error(e); 13299 } 13300 } 13301 13302 // If we're in the commit phase, defer scheduling an update on the 13303 // boundary until after the commit is complete 13304 if (isCommitting) { 13305 if (commitPhaseBoundaries === null) { 13306 commitPhaseBoundaries = new Set(); 13307 } 13308 commitPhaseBoundaries.add(boundary); 13309 } else { 13310 // Otherwise, schedule an update now. 13311 // TODO: Is this actually necessary during the render phase? Is it 13312 // possible to unwind and continue rendering at the same priority, 13313 // without corrupting internal state? 13314 scheduleErrorRecovery(boundary); 13315 } 13316 return boundary; 13317 } else if (firstUncaughtError === null) { 13318 // If no boundary is found, we'll need to throw the error 13319 firstUncaughtError = error; 13320 } 13321 return null; 13322 } 13323 13324 function hasCapturedError(fiber) { 13325 // TODO: capturedErrors should store the boundary instance, to avoid needing 13326 // to check the alternate. 13327 return capturedErrors !== null && (capturedErrors.has(fiber) || fiber.alternate !== null && capturedErrors.has(fiber.alternate)); 13328 } 13329 13330 function isFailedBoundary(fiber) { 13331 // TODO: failedBoundaries should store the boundary instance, to avoid 13332 // needing to check the alternate. 13333 return failedBoundaries !== null && (failedBoundaries.has(fiber) || fiber.alternate !== null && failedBoundaries.has(fiber.alternate)); 13334 } 13335 13336 function commitErrorHandling(effectfulFiber) { 13337 var capturedError = void 0; 13338 if (capturedErrors !== null) { 13339 capturedError = capturedErrors.get(effectfulFiber); 13340 capturedErrors['delete'](effectfulFiber); 13341 if (capturedError == null) { 13342 if (effectfulFiber.alternate !== null) { 13343 effectfulFiber = effectfulFiber.alternate; 13344 capturedError = capturedErrors.get(effectfulFiber); 13345 capturedErrors['delete'](effectfulFiber); 13346 } 13347 } 13348 } 13349 13350 !(capturedError != null) ? invariant(false, 'No error for given unit of work. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13351 13352 switch (effectfulFiber.tag) { 13353 case ClassComponent: 13354 var instance = effectfulFiber.stateNode; 13355 13356 var info = { 13357 componentStack: capturedError.componentStack 13358 }; 13359 13360 // Allow the boundary to handle the error, usually by scheduling 13361 // an update to itself 13362 instance.componentDidCatch(capturedError.error, info); 13363 return; 13364 case HostRoot: 13365 if (firstUncaughtError === null) { 13366 firstUncaughtError = capturedError.error; 13367 } 13368 return; 13369 default: 13370 invariant(false, 'Invalid type of work. This error is likely caused by a bug in React. Please file an issue.'); 13371 } 13372 } 13373 13374 function unwindContexts(from, to) { 13375 var node = from; 13376 while (node !== null) { 13377 switch (node.tag) { 13378 case ClassComponent: 13379 popContextProvider(node); 13380 break; 13381 case HostComponent: 13382 popHostContext(node); 13383 break; 13384 case HostRoot: 13385 popHostContainer(node); 13386 break; 13387 case HostPortal: 13388 popHostContainer(node); 13389 break; 13390 } 13391 if (node === to || node.alternate === to) { 13392 stopFailedWorkTimer(node); 13393 break; 13394 } else { 13395 stopWorkTimer(node); 13396 } 13397 node = node['return']; 13398 } 13399 } 13400 13401 function computeAsyncExpiration() { 13402 // Given the current clock time, returns an expiration time. We use rounding 13403 // to batch like updates together. 13404 // Should complete within ~1000ms. 1200ms max. 13405 var currentTime = recalculateCurrentTime(); 13406 var expirationMs = 1000; 13407 var bucketSizeMs = 200; 13408 return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs); 13409 } 13410 13411 function computeExpirationForFiber(fiber) { 13412 var expirationTime = void 0; 13413 if (expirationContext !== NoWork) { 13414 // An explicit expiration context was set; 13415 expirationTime = expirationContext; 13416 } else if (isWorking) { 13417 if (isCommitting) { 13418 // Updates that occur during the commit phase should have sync priority 13419 // by default. 13420 expirationTime = Sync; 13421 } else { 13422 // Updates during the render phase should expire at the same time as 13423 // the work that is being rendered. 13424 expirationTime = nextRenderExpirationTime; 13425 } 13426 } else { 13427 // No explicit expiration context was set, and we're not currently 13428 // performing work. Calculate a new expiration time. 13429 if (useSyncScheduling && !(fiber.internalContextTag & AsyncUpdates)) { 13430 // This is a sync update 13431 expirationTime = Sync; 13432 } else { 13433 // This is an async update 13434 expirationTime = computeAsyncExpiration(); 13435 } 13436 } 13437 return expirationTime; 13438 } 13439 13440 function scheduleWork(fiber, expirationTime) { 13441 return scheduleWorkImpl(fiber, expirationTime, false); 13442 } 13443 13444 function checkRootNeedsClearing(root, fiber, expirationTime) { 13445 if (!isWorking && root === nextRoot && expirationTime < nextRenderExpirationTime) { 13446 // Restart the root from the top. 13447 if (nextUnitOfWork !== null) { 13448 // This is an interruption. (Used for performance tracking.) 13449 interruptedBy = fiber; 13450 } 13451 nextRoot = null; 13452 nextUnitOfWork = null; 13453 nextRenderExpirationTime = NoWork; 13454 } 13455 } 13456 13457 function scheduleWorkImpl(fiber, expirationTime, isErrorRecovery) { 13458 recordScheduleUpdate(); 13459 13460 { 13461 if (!isErrorRecovery && fiber.tag === ClassComponent) { 13462 var instance = fiber.stateNode; 13463 warnAboutInvalidUpdates(instance); 13464 } 13465 } 13466 13467 var node = fiber; 13468 while (node !== null) { 13469 // Walk the parent path to the root and update each node's 13470 // expiration time. 13471 if (node.expirationTime === NoWork || node.expirationTime > expirationTime) { 13472 node.expirationTime = expirationTime; 13473 } 13474 if (node.alternate !== null) { 13475 if (node.alternate.expirationTime === NoWork || node.alternate.expirationTime > expirationTime) { 13476 node.alternate.expirationTime = expirationTime; 13477 } 13478 } 13479 if (node['return'] === null) { 13480 if (node.tag === HostRoot) { 13481 var root = node.stateNode; 13482 13483 checkRootNeedsClearing(root, fiber, expirationTime); 13484 requestWork(root, expirationTime); 13485 checkRootNeedsClearing(root, fiber, expirationTime); 13486 } else { 13487 { 13488 if (!isErrorRecovery && fiber.tag === ClassComponent) { 13489 warnAboutUpdateOnUnmounted(fiber); 13490 } 13491 } 13492 return; 13493 } 13494 } 13495 node = node['return']; 13496 } 13497 } 13498 13499 function scheduleErrorRecovery(fiber) { 13500 scheduleWorkImpl(fiber, Sync, true); 13501 } 13502 13503 function recalculateCurrentTime() { 13504 // Subtract initial time so it fits inside 32bits 13505 var ms = now() - startTime; 13506 mostRecentCurrentTime = msToExpirationTime(ms); 13507 return mostRecentCurrentTime; 13508 } 13509 13510 function deferredUpdates(fn) { 13511 var previousExpirationContext = expirationContext; 13512 expirationContext = computeAsyncExpiration(); 13513 try { 13514 return fn(); 13515 } finally { 13516 expirationContext = previousExpirationContext; 13517 } 13518 } 13519 13520 function syncUpdates(fn) { 13521 var previousExpirationContext = expirationContext; 13522 expirationContext = Sync; 13523 try { 13524 return fn(); 13525 } finally { 13526 expirationContext = previousExpirationContext; 13527 } 13528 } 13529 13530 // TODO: Everything below this is written as if it has been lifted to the 13531 // renderers. I'll do this in a follow-up. 13532 13533 // Linked-list of roots 13534 var firstScheduledRoot = null; 13535 var lastScheduledRoot = null; 13536 13537 var callbackExpirationTime = NoWork; 13538 var callbackID = -1; 13539 var isRendering = false; 13540 var nextFlushedRoot = null; 13541 var nextFlushedExpirationTime = NoWork; 13542 var deadlineDidExpire = false; 13543 var hasUnhandledError = false; 13544 var unhandledError = null; 13545 var deadline = null; 13546 13547 var isBatchingUpdates = false; 13548 var isUnbatchingUpdates = false; 13549 13550 // Use these to prevent an infinite loop of nested updates 13551 var NESTED_UPDATE_LIMIT = 1000; 13552 var nestedUpdateCount = 0; 13553 13554 var timeHeuristicForUnitOfWork = 1; 13555 13556 function scheduleCallbackWithExpiration(expirationTime) { 13557 if (callbackExpirationTime !== NoWork) { 13558 // A callback is already scheduled. Check its expiration time (timeout). 13559 if (expirationTime > callbackExpirationTime) { 13560 // Existing callback has sufficient timeout. Exit. 13561 return; 13562 } else { 13563 // Existing callback has insufficient timeout. Cancel and schedule a 13564 // new one. 13565 cancelDeferredCallback(callbackID); 13566 } 13567 // The request callback timer is already running. Don't start a new one. 13568 } else { 13569 startRequestCallbackTimer(); 13570 } 13571 13572 // Compute a timeout for the given expiration time. 13573 var currentMs = now() - startTime; 13574 var expirationMs = expirationTimeToMs(expirationTime); 13575 var timeout = expirationMs - currentMs; 13576 13577 callbackExpirationTime = expirationTime; 13578 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout }); 13579 } 13580 13581 // requestWork is called by the scheduler whenever a root receives an update. 13582 // It's up to the renderer to call renderRoot at some point in the future. 13583 function requestWork(root, expirationTime) { 13584 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 13585 invariant(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.'); 13586 } 13587 13588 // Add the root to the schedule. 13589 // Check if this root is already part of the schedule. 13590 if (root.nextScheduledRoot === null) { 13591 // This root is not already scheduled. Add it. 13592 root.remainingExpirationTime = expirationTime; 13593 if (lastScheduledRoot === null) { 13594 firstScheduledRoot = lastScheduledRoot = root; 13595 root.nextScheduledRoot = root; 13596 } else { 13597 lastScheduledRoot.nextScheduledRoot = root; 13598 lastScheduledRoot = root; 13599 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; 13600 } 13601 } else { 13602 // This root is already scheduled, but its priority may have increased. 13603 var remainingExpirationTime = root.remainingExpirationTime; 13604 if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { 13605 // Update the priority. 13606 root.remainingExpirationTime = expirationTime; 13607 } 13608 } 13609 13610 if (isRendering) { 13611 // Prevent reentrancy. Remaining work will be scheduled at the end of 13612 // the currently rendering batch. 13613 return; 13614 } 13615 13616 if (isBatchingUpdates) { 13617 // Flush work at the end of the batch. 13618 if (isUnbatchingUpdates) { 13619 // ...unless we're inside unbatchedUpdates, in which case we should 13620 // flush it now. 13621 nextFlushedRoot = root; 13622 nextFlushedExpirationTime = Sync; 13623 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime); 13624 } 13625 return; 13626 } 13627 13628 // TODO: Get rid of Sync and use current time? 13629 if (expirationTime === Sync) { 13630 performWork(Sync, null); 13631 } else { 13632 scheduleCallbackWithExpiration(expirationTime); 13633 } 13634 } 13635 13636 function findHighestPriorityRoot() { 13637 var highestPriorityWork = NoWork; 13638 var highestPriorityRoot = null; 13639 13640 if (lastScheduledRoot !== null) { 13641 var previousScheduledRoot = lastScheduledRoot; 13642 var root = firstScheduledRoot; 13643 while (root !== null) { 13644 var remainingExpirationTime = root.remainingExpirationTime; 13645 if (remainingExpirationTime === NoWork) { 13646 // This root no longer has work. Remove it from the scheduler. 13647 13648 // TODO: This check is redudant, but Flow is confused by the branch 13649 // below where we set lastScheduledRoot to null, even though we break 13650 // from the loop right after. 13651 !(previousScheduledRoot !== null && lastScheduledRoot !== null) ? invariant(false, 'Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13652 if (root === root.nextScheduledRoot) { 13653 // This is the only root in the list. 13654 root.nextScheduledRoot = null; 13655 firstScheduledRoot = lastScheduledRoot = null; 13656 break; 13657 } else if (root === firstScheduledRoot) { 13658 // This is the first root in the list. 13659 var next = root.nextScheduledRoot; 13660 firstScheduledRoot = next; 13661 lastScheduledRoot.nextScheduledRoot = next; 13662 root.nextScheduledRoot = null; 13663 } else if (root === lastScheduledRoot) { 13664 // This is the last root in the list. 13665 lastScheduledRoot = previousScheduledRoot; 13666 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; 13667 root.nextScheduledRoot = null; 13668 break; 13669 } else { 13670 previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot; 13671 root.nextScheduledRoot = null; 13672 } 13673 root = previousScheduledRoot.nextScheduledRoot; 13674 } else { 13675 if (highestPriorityWork === NoWork || remainingExpirationTime < highestPriorityWork) { 13676 // Update the priority, if it's higher 13677 highestPriorityWork = remainingExpirationTime; 13678 highestPriorityRoot = root; 13679 } 13680 if (root === lastScheduledRoot) { 13681 break; 13682 } 13683 previousScheduledRoot = root; 13684 root = root.nextScheduledRoot; 13685 } 13686 } 13687 } 13688 13689 // If the next root is the same as the previous root, this is a nested 13690 // update. To prevent an infinite loop, increment the nested update count. 13691 var previousFlushedRoot = nextFlushedRoot; 13692 if (previousFlushedRoot !== null && previousFlushedRoot === highestPriorityRoot) { 13693 nestedUpdateCount++; 13694 } else { 13695 // Reset whenever we switch roots. 13696 nestedUpdateCount = 0; 13697 } 13698 nextFlushedRoot = highestPriorityRoot; 13699 nextFlushedExpirationTime = highestPriorityWork; 13700 } 13701 13702 function performAsyncWork(dl) { 13703 performWork(NoWork, dl); 13704 } 13705 13706 function performWork(minExpirationTime, dl) { 13707 deadline = dl; 13708 13709 // Keep working on roots until there's no more work, or until the we reach 13710 // the deadline. 13711 findHighestPriorityRoot(); 13712 13713 if (enableUserTimingAPI && deadline !== null) { 13714 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime(); 13715 stopRequestCallbackTimer(didExpire); 13716 } 13717 13718 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || nextFlushedExpirationTime <= minExpirationTime) && !deadlineDidExpire) { 13719 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime); 13720 // Find the next highest priority work. 13721 findHighestPriorityRoot(); 13722 } 13723 13724 // We're done flushing work. Either we ran out of time in this callback, 13725 // or there's no more work left with sufficient priority. 13726 13727 // If we're inside a callback, set this to false since we just completed it. 13728 if (deadline !== null) { 13729 callbackExpirationTime = NoWork; 13730 callbackID = -1; 13731 } 13732 // If there's work left over, schedule a new callback. 13733 if (nextFlushedExpirationTime !== NoWork) { 13734 scheduleCallbackWithExpiration(nextFlushedExpirationTime); 13735 } 13736 13737 // Clean-up. 13738 deadline = null; 13739 deadlineDidExpire = false; 13740 nestedUpdateCount = 0; 13741 13742 if (hasUnhandledError) { 13743 var _error4 = unhandledError; 13744 unhandledError = null; 13745 hasUnhandledError = false; 13746 throw _error4; 13747 } 13748 } 13749 13750 function performWorkOnRoot(root, expirationTime) { 13751 !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13752 13753 isRendering = true; 13754 13755 // Check if this is async work or sync/expired work. 13756 // TODO: Pass current time as argument to renderRoot, commitRoot 13757 if (expirationTime <= recalculateCurrentTime()) { 13758 // Flush sync work. 13759 var finishedWork = root.finishedWork; 13760 if (finishedWork !== null) { 13761 // This root is already complete. We can commit it. 13762 root.finishedWork = null; 13763 root.remainingExpirationTime = commitRoot(finishedWork); 13764 } else { 13765 root.finishedWork = null; 13766 finishedWork = renderRoot(root, expirationTime); 13767 if (finishedWork !== null) { 13768 // We've completed the root. Commit it. 13769 root.remainingExpirationTime = commitRoot(finishedWork); 13770 } 13771 } 13772 } else { 13773 // Flush async work. 13774 var _finishedWork = root.finishedWork; 13775 if (_finishedWork !== null) { 13776 // This root is already complete. We can commit it. 13777 root.finishedWork = null; 13778 root.remainingExpirationTime = commitRoot(_finishedWork); 13779 } else { 13780 root.finishedWork = null; 13781 _finishedWork = renderRoot(root, expirationTime); 13782 if (_finishedWork !== null) { 13783 // We've completed the root. Check the deadline one more time 13784 // before committing. 13785 if (!shouldYield()) { 13786 // Still time left. Commit the root. 13787 root.remainingExpirationTime = commitRoot(_finishedWork); 13788 } else { 13789 // There's no time left. Mark this root as complete. We'll come 13790 // back and commit it later. 13791 root.finishedWork = _finishedWork; 13792 } 13793 } 13794 } 13795 } 13796 13797 isRendering = false; 13798 } 13799 13800 // When working on async work, the reconciler asks the renderer if it should 13801 // yield execution. For DOM, we implement this with requestIdleCallback. 13802 function shouldYield() { 13803 if (deadline === null) { 13804 return false; 13805 } 13806 if (deadline.timeRemaining() > timeHeuristicForUnitOfWork) { 13807 // Disregard deadline.didTimeout. Only expired work should be flushed 13808 // during a timeout. This path is only hit for non-expired work. 13809 return false; 13810 } 13811 deadlineDidExpire = true; 13812 return true; 13813 } 13814 13815 // TODO: Not happy about this hook. Conceptually, renderRoot should return a 13816 // tuple of (isReadyForCommit, didError, error) 13817 function onUncaughtError(error) { 13818 !(nextFlushedRoot !== null) ? invariant(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 13819 // Unschedule this root so we don't work on it again until there's 13820 // another update. 13821 nextFlushedRoot.remainingExpirationTime = NoWork; 13822 if (!hasUnhandledError) { 13823 hasUnhandledError = true; 13824 unhandledError = error; 13825 } 13826 } 13827 13828 // TODO: Batching should be implemented at the renderer level, not inside 13829 // the reconciler. 13830 function batchedUpdates(fn, a) { 13831 var previousIsBatchingUpdates = isBatchingUpdates; 13832 isBatchingUpdates = true; 13833 try { 13834 return fn(a); 13835 } finally { 13836 isBatchingUpdates = previousIsBatchingUpdates; 13837 if (!isBatchingUpdates && !isRendering) { 13838 performWork(Sync, null); 13839 } 13840 } 13841 } 13842 13843 // TODO: Batching should be implemented at the renderer level, not inside 13844 // the reconciler. 13845 function unbatchedUpdates(fn) { 13846 if (isBatchingUpdates && !isUnbatchingUpdates) { 13847 isUnbatchingUpdates = true; 13848 try { 13849 return fn(); 13850 } finally { 13851 isUnbatchingUpdates = false; 13852 } 13853 } 13854 return fn(); 13855 } 13856 13857 // TODO: Batching should be implemented at the renderer level, not within 13858 // the reconciler. 13859 function flushSync(fn) { 13860 var previousIsBatchingUpdates = isBatchingUpdates; 13861 isBatchingUpdates = true; 13862 try { 13863 return syncUpdates(fn); 13864 } finally { 13865 isBatchingUpdates = previousIsBatchingUpdates; 13866 !!isRendering ? invariant(false, 'flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.') : void 0; 13867 performWork(Sync, null); 13868 } 13869 } 13870 13871 return { 13872 computeAsyncExpiration: computeAsyncExpiration, 13873 computeExpirationForFiber: computeExpirationForFiber, 13874 scheduleWork: scheduleWork, 13875 batchedUpdates: batchedUpdates, 13876 unbatchedUpdates: unbatchedUpdates, 13877 flushSync: flushSync, 13878 deferredUpdates: deferredUpdates 13879 }; 13880 }; 13881 13882 { 13883 var didWarnAboutNestedUpdates = false; 13884 } 13885 13886 // 0 is PROD, 1 is DEV. 13887 // Might add PROFILE later. 13888 13889 13890 function getContextForSubtree(parentComponent) { 13891 if (!parentComponent) { 13892 return emptyObject; 13893 } 13894 13895 var fiber = get(parentComponent); 13896 var parentContext = findCurrentUnmaskedContext(fiber); 13897 return isContextProvider(fiber) ? processChildContext(fiber, parentContext) : parentContext; 13898 } 13899 13900 var ReactFiberReconciler$1 = function (config) { 13901 var getPublicInstance = config.getPublicInstance; 13902 13903 var _ReactFiberScheduler = ReactFiberScheduler(config), 13904 computeAsyncExpiration = _ReactFiberScheduler.computeAsyncExpiration, 13905 computeExpirationForFiber = _ReactFiberScheduler.computeExpirationForFiber, 13906 scheduleWork = _ReactFiberScheduler.scheduleWork, 13907 batchedUpdates = _ReactFiberScheduler.batchedUpdates, 13908 unbatchedUpdates = _ReactFiberScheduler.unbatchedUpdates, 13909 flushSync = _ReactFiberScheduler.flushSync, 13910 deferredUpdates = _ReactFiberScheduler.deferredUpdates; 13911 13912 function scheduleTopLevelUpdate(current, element, callback) { 13913 { 13914 if (ReactDebugCurrentFiber.phase === 'render' && ReactDebugCurrentFiber.current !== null && !didWarnAboutNestedUpdates) { 13915 didWarnAboutNestedUpdates = true; 13916 warning(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(ReactDebugCurrentFiber.current) || 'Unknown'); 13917 } 13918 } 13919 13920 callback = callback === undefined ? null : callback; 13921 { 13922 warning(callback === null || typeof callback === 'function', 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); 13923 } 13924 13925 var expirationTime = void 0; 13926 // Check if the top-level element is an async wrapper component. If so, 13927 // treat updates to the root as async. This is a bit weird but lets us 13928 // avoid a separate `renderAsync` API. 13929 if (enableAsyncSubtreeAPI && element != null && element.type != null && element.type.prototype != null && element.type.prototype.unstable_isAsyncReactComponent === true) { 13930 expirationTime = computeAsyncExpiration(); 13931 } else { 13932 expirationTime = computeExpirationForFiber(current); 13933 } 13934 13935 var update = { 13936 expirationTime: expirationTime, 13937 partialState: { element: element }, 13938 callback: callback, 13939 isReplace: false, 13940 isForced: false, 13941 nextCallback: null, 13942 next: null 13943 }; 13944 insertUpdateIntoFiber(current, update); 13945 scheduleWork(current, expirationTime); 13946 } 13947 13948 function findHostInstance(fiber) { 13949 var hostFiber = findCurrentHostFiber(fiber); 13950 if (hostFiber === null) { 13951 return null; 13952 } 13953 return hostFiber.stateNode; 13954 } 13955 13956 return { 13957 createContainer: function (containerInfo, hydrate) { 13958 return createFiberRoot(containerInfo, hydrate); 13959 }, 13960 updateContainer: function (element, container, parentComponent, callback) { 13961 // TODO: If this is a nested container, this won't be the root. 13962 var current = container.current; 13963 13964 { 13965 if (ReactFiberInstrumentation_1.debugTool) { 13966 if (current.alternate === null) { 13967 ReactFiberInstrumentation_1.debugTool.onMountContainer(container); 13968 } else if (element === null) { 13969 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); 13970 } else { 13971 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); 13972 } 13973 } 13974 } 13975 13976 var context = getContextForSubtree(parentComponent); 13977 if (container.context === null) { 13978 container.context = context; 13979 } else { 13980 container.pendingContext = context; 13981 } 13982 13983 scheduleTopLevelUpdate(current, element, callback); 13984 }, 13985 13986 13987 batchedUpdates: batchedUpdates, 13988 13989 unbatchedUpdates: unbatchedUpdates, 13990 13991 deferredUpdates: deferredUpdates, 13992 13993 flushSync: flushSync, 13994 13995 getPublicRootInstance: function (container) { 13996 var containerFiber = container.current; 13997 if (!containerFiber.child) { 13998 return null; 13999 } 14000 switch (containerFiber.child.tag) { 14001 case HostComponent: 14002 return getPublicInstance(containerFiber.child.stateNode); 14003 default: 14004 return containerFiber.child.stateNode; 14005 } 14006 }, 14007 14008 14009 findHostInstance: findHostInstance, 14010 14011 findHostInstanceWithNoPortals: function (fiber) { 14012 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 14013 if (hostFiber === null) { 14014 return null; 14015 } 14016 return hostFiber.stateNode; 14017 }, 14018 injectIntoDevTools: function (devToolsConfig) { 14019 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 14020 14021 return injectInternals(_assign({}, devToolsConfig, { 14022 findHostInstanceByFiber: function (fiber) { 14023 return findHostInstance(fiber); 14024 }, 14025 findFiberByHostInstance: function (instance) { 14026 if (!findFiberByHostInstance) { 14027 // Might not be implemented by the renderer. 14028 return null; 14029 } 14030 return findFiberByHostInstance(instance); 14031 } 14032 })); 14033 } 14034 }; 14035 }; 14036 14037 var ReactFiberReconciler$2 = Object.freeze({ 14038 default: ReactFiberReconciler$1 14039 }); 14040 14041 var ReactFiberReconciler$3 = ( ReactFiberReconciler$2 && ReactFiberReconciler$1 ) || ReactFiberReconciler$2; 14042 14043 // TODO: bundle Flow types with the package. 14044 14045 14046 14047 // TODO: decide on the top-level export form. 14048 // This is hacky but makes it work with both Rollup and Jest. 14049 var reactReconciler = ReactFiberReconciler$3['default'] ? ReactFiberReconciler$3['default'] : ReactFiberReconciler$3; 14050 14051 function createPortal$1(children, containerInfo, 14052 // TODO: figure out the API for cross-renderer implementation. 14053 implementation) { 14054 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 14055 14056 return { 14057 // This tag allow us to uniquely identify this as a React Portal 14058 $$typeof: REACT_PORTAL_TYPE, 14059 key: key == null ? null : '' + key, 14060 children: children, 14061 containerInfo: containerInfo, 14062 implementation: implementation 14063 }; 14064 } 14065 14066 // TODO: this is special because it gets imported during build. 14067 14068 var ReactVersion = '16.2.0'; 14069 14070 // a requestAnimationFrame, storing the time for the start of the frame, then 14071 // scheduling a postMessage which gets scheduled after paint. Within the 14072 // postMessage handler do as much work as possible until time + frame rate. 14073 // By separating the idle call into a separate event tick we ensure that 14074 // layout, paint and other browser work is counted against the available time. 14075 // The frame rate is dynamically adjusted. 14076 14077 { 14078 if (ExecutionEnvironment.canUseDOM && typeof requestAnimationFrame !== 'function') { 14079 warning(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. http://fb.me/react-polyfills'); 14080 } 14081 } 14082 14083 var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 14084 14085 var now = void 0; 14086 if (hasNativePerformanceNow) { 14087 now = function () { 14088 return performance.now(); 14089 }; 14090 } else { 14091 now = function () { 14092 return Date.now(); 14093 }; 14094 } 14095 14096 // TODO: There's no way to cancel, because Fiber doesn't atm. 14097 var rIC = void 0; 14098 var cIC = void 0; 14099 14100 if (!ExecutionEnvironment.canUseDOM) { 14101 rIC = function (frameCallback) { 14102 return setTimeout(function () { 14103 frameCallback({ 14104 timeRemaining: function () { 14105 return Infinity; 14106 } 14107 }); 14108 }); 14109 }; 14110 cIC = function (timeoutID) { 14111 clearTimeout(timeoutID); 14112 }; 14113 } else if (typeof requestIdleCallback !== 'function' || typeof cancelIdleCallback !== 'function') { 14114 // Polyfill requestIdleCallback and cancelIdleCallback 14115 14116 var scheduledRICCallback = null; 14117 var isIdleScheduled = false; 14118 var timeoutTime = -1; 14119 14120 var isAnimationFrameScheduled = false; 14121 14122 var frameDeadline = 0; 14123 // We start out assuming that we run at 30fps but then the heuristic tracking 14124 // will adjust this value to a faster fps if we get more frequent animation 14125 // frames. 14126 var previousFrameTime = 33; 14127 var activeFrameTime = 33; 14128 14129 var frameDeadlineObject; 14130 if (hasNativePerformanceNow) { 14131 frameDeadlineObject = { 14132 didTimeout: false, 14133 timeRemaining: function () { 14134 // We assume that if we have a performance timer that the rAF callback 14135 // gets a performance timer value. Not sure if this is always true. 14136 var remaining = frameDeadline - performance.now(); 14137 return remaining > 0 ? remaining : 0; 14138 } 14139 }; 14140 } else { 14141 frameDeadlineObject = { 14142 didTimeout: false, 14143 timeRemaining: function () { 14144 // Fallback to Date.now() 14145 var remaining = frameDeadline - Date.now(); 14146 return remaining > 0 ? remaining : 0; 14147 } 14148 }; 14149 } 14150 14151 // We use the postMessage trick to defer idle work until after the repaint. 14152 var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2); 14153 var idleTick = function (event) { 14154 if (event.source !== window || event.data !== messageKey) { 14155 return; 14156 } 14157 14158 isIdleScheduled = false; 14159 14160 var currentTime = now(); 14161 if (frameDeadline - currentTime <= 0) { 14162 // There's no time left in this idle period. Check if the callback has 14163 // a timeout and whether it's been exceeded. 14164 if (timeoutTime !== -1 && timeoutTime <= currentTime) { 14165 // Exceeded the timeout. Invoke the callback even though there's no 14166 // time left. 14167 frameDeadlineObject.didTimeout = true; 14168 } else { 14169 // No timeout. 14170 if (!isAnimationFrameScheduled) { 14171 // Schedule another animation callback so we retry later. 14172 isAnimationFrameScheduled = true; 14173 requestAnimationFrame(animationTick); 14174 } 14175 // Exit without invoking the callback. 14176 return; 14177 } 14178 } else { 14179 // There's still time left in this idle period. 14180 frameDeadlineObject.didTimeout = false; 14181 } 14182 14183 timeoutTime = -1; 14184 var callback = scheduledRICCallback; 14185 scheduledRICCallback = null; 14186 if (callback !== null) { 14187 callback(frameDeadlineObject); 14188 } 14189 }; 14190 // Assumes that we have addEventListener in this environment. Might need 14191 // something better for old IE. 14192 window.addEventListener('message', idleTick, false); 14193 14194 var animationTick = function (rafTime) { 14195 isAnimationFrameScheduled = false; 14196 var nextFrameTime = rafTime - frameDeadline + activeFrameTime; 14197 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { 14198 if (nextFrameTime < 8) { 14199 // Defensive coding. We don't support higher frame rates than 120hz. 14200 // If we get lower than that, it is probably a bug. 14201 nextFrameTime = 8; 14202 } 14203 // If one frame goes long, then the next one can be short to catch up. 14204 // If two frames are short in a row, then that's an indication that we 14205 // actually have a higher frame rate than what we're currently optimizing. 14206 // We adjust our heuristic dynamically accordingly. For example, if we're 14207 // running on 120hz display or 90hz VR display. 14208 // Take the max of the two in case one of them was an anomaly due to 14209 // missed frame deadlines. 14210 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; 14211 } else { 14212 previousFrameTime = nextFrameTime; 14213 } 14214 frameDeadline = rafTime + activeFrameTime; 14215 if (!isIdleScheduled) { 14216 isIdleScheduled = true; 14217 window.postMessage(messageKey, '*'); 14218 } 14219 }; 14220 14221 rIC = function (callback, options) { 14222 // This assumes that we only schedule one callback at a time because that's 14223 // how Fiber uses it. 14224 scheduledRICCallback = callback; 14225 if (options != null && typeof options.timeout === 'number') { 14226 timeoutTime = now() + options.timeout; 14227 } 14228 if (!isAnimationFrameScheduled) { 14229 // If rAF didn't already schedule one, we need to schedule a frame. 14230 // TODO: If this rAF doesn't materialize because the browser throttles, we 14231 // might want to still have setTimeout trigger rIC as a backup to ensure 14232 // that we keep performing work. 14233 isAnimationFrameScheduled = true; 14234 requestAnimationFrame(animationTick); 14235 } 14236 return 0; 14237 }; 14238 14239 cIC = function () { 14240 scheduledRICCallback = null; 14241 isIdleScheduled = false; 14242 timeoutTime = -1; 14243 }; 14244 } else { 14245 rIC = window.requestIdleCallback; 14246 cIC = window.cancelIdleCallback; 14247 } 14248 14249 /** 14250 * Forked from fbjs/warning: 14251 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js 14252 * 14253 * Only change is we use console.warn instead of console.error, 14254 * and do nothing when 'console' is not supported. 14255 * This really simplifies the code. 14256 * --- 14257 * Similar to invariant but only logs a warning if the condition is not met. 14258 * This can be used to log issues in development environments in critical 14259 * paths. Removing the logging code for production environments will keep the 14260 * same logic and follow the same code paths. 14261 */ 14262 14263 var lowPriorityWarning = function () {}; 14264 14265 { 14266 var printWarning = function (format) { 14267 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 14268 args[_key - 1] = arguments[_key]; 14269 } 14270 14271 var argIndex = 0; 14272 var message = 'Warning: ' + format.replace(/%s/g, function () { 14273 return args[argIndex++]; 14274 }); 14275 if (typeof console !== 'undefined') { 14276 console.warn(message); 14277 } 14278 try { 14279 // --- Welcome to debugging React --- 14280 // This error was thrown as a convenience so that you can use this stack 14281 // to find the callsite that caused this warning to fire. 14282 throw new Error(message); 14283 } catch (x) {} 14284 }; 14285 14286 lowPriorityWarning = function (condition, format) { 14287 if (format === undefined) { 14288 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 14289 } 14290 if (!condition) { 14291 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 14292 args[_key2 - 2] = arguments[_key2]; 14293 } 14294 14295 printWarning.apply(undefined, [format].concat(args)); 14296 } 14297 }; 14298 } 14299 14300 var lowPriorityWarning$1 = lowPriorityWarning; 14301 14302 // isAttributeNameSafe() is currently duplicated in DOMMarkupOperations. 14303 // TODO: Find a better place for this. 14304 var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 14305 var illegalAttributeNameCache = {}; 14306 var validatedAttributeNameCache = {}; 14307 function isAttributeNameSafe(attributeName) { 14308 if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { 14309 return true; 14310 } 14311 if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { 14312 return false; 14313 } 14314 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 14315 validatedAttributeNameCache[attributeName] = true; 14316 return true; 14317 } 14318 illegalAttributeNameCache[attributeName] = true; 14319 { 14320 warning(false, 'Invalid attribute name: `%s`', attributeName); 14321 } 14322 return false; 14323 } 14324 14325 // shouldIgnoreValue() is currently duplicated in DOMMarkupOperations. 14326 // TODO: Find a better place for this. 14327 function shouldIgnoreValue(propertyInfo, value) { 14328 return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false; 14329 } 14330 14331 /** 14332 * Operations for dealing with DOM properties. 14333 */ 14334 14335 14336 14337 14338 14339 /** 14340 * Get the value for a property on a node. Only used in DEV for SSR validation. 14341 * The "expected" argument is used as a hint of what the expected value is. 14342 * Some properties have multiple equivalent values. 14343 */ 14344 function getValueForProperty(node, name, expected) { 14345 { 14346 var propertyInfo = getPropertyInfo(name); 14347 if (propertyInfo) { 14348 var mutationMethod = propertyInfo.mutationMethod; 14349 if (mutationMethod || propertyInfo.mustUseProperty) { 14350 return node[propertyInfo.propertyName]; 14351 } else { 14352 var attributeName = propertyInfo.attributeName; 14353 14354 var stringValue = null; 14355 14356 if (propertyInfo.hasOverloadedBooleanValue) { 14357 if (node.hasAttribute(attributeName)) { 14358 var value = node.getAttribute(attributeName); 14359 if (value === '') { 14360 return true; 14361 } 14362 if (shouldIgnoreValue(propertyInfo, expected)) { 14363 return value; 14364 } 14365 if (value === '' + expected) { 14366 return expected; 14367 } 14368 return value; 14369 } 14370 } else if (node.hasAttribute(attributeName)) { 14371 if (shouldIgnoreValue(propertyInfo, expected)) { 14372 // We had an attribute but shouldn't have had one, so read it 14373 // for the error message. 14374 return node.getAttribute(attributeName); 14375 } 14376 if (propertyInfo.hasBooleanValue) { 14377 // If this was a boolean, it doesn't matter what the value is 14378 // the fact that we have it is the same as the expected. 14379 return expected; 14380 } 14381 // Even if this property uses a namespace we use getAttribute 14382 // because we assume its namespaced name is the same as our config. 14383 // To use getAttributeNS we need the local name which we don't have 14384 // in our config atm. 14385 stringValue = node.getAttribute(attributeName); 14386 } 14387 14388 if (shouldIgnoreValue(propertyInfo, expected)) { 14389 return stringValue === null ? expected : stringValue; 14390 } else if (stringValue === '' + expected) { 14391 return expected; 14392 } else { 14393 return stringValue; 14394 } 14395 } 14396 } 14397 } 14398 } 14399 14400 /** 14401 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 14402 * The third argument is used as a hint of what the expected value is. Some 14403 * attributes have multiple equivalent values. 14404 */ 14405 function getValueForAttribute(node, name, expected) { 14406 { 14407 if (!isAttributeNameSafe(name)) { 14408 return; 14409 } 14410 if (!node.hasAttribute(name)) { 14411 return expected === undefined ? undefined : null; 14412 } 14413 var value = node.getAttribute(name); 14414 if (value === '' + expected) { 14415 return expected; 14416 } 14417 return value; 14418 } 14419 } 14420 14421 /** 14422 * Sets the value for a property on a node. 14423 * 14424 * @param {DOMElement} node 14425 * @param {string} name 14426 * @param {*} value 14427 */ 14428 function setValueForProperty(node, name, value) { 14429 var propertyInfo = getPropertyInfo(name); 14430 14431 if (propertyInfo && shouldSetAttribute(name, value)) { 14432 var mutationMethod = propertyInfo.mutationMethod; 14433 if (mutationMethod) { 14434 mutationMethod(node, value); 14435 } else if (shouldIgnoreValue(propertyInfo, value)) { 14436 deleteValueForProperty(node, name); 14437 return; 14438 } else if (propertyInfo.mustUseProperty) { 14439 // Contrary to `setAttribute`, object properties are properly 14440 // `toString`ed by IE8/9. 14441 node[propertyInfo.propertyName] = value; 14442 } else { 14443 var attributeName = propertyInfo.attributeName; 14444 var namespace = propertyInfo.attributeNamespace; 14445 // `setAttribute` with objects becomes only `[object]` in IE8/9, 14446 // ('' + value) makes it output the correct toString()-value. 14447 if (namespace) { 14448 node.setAttributeNS(namespace, attributeName, '' + value); 14449 } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { 14450 node.setAttribute(attributeName, ''); 14451 } else { 14452 node.setAttribute(attributeName, '' + value); 14453 } 14454 } 14455 } else { 14456 setValueForAttribute(node, name, shouldSetAttribute(name, value) ? value : null); 14457 return; 14458 } 14459 14460 { 14461 14462 } 14463 } 14464 14465 function setValueForAttribute(node, name, value) { 14466 if (!isAttributeNameSafe(name)) { 14467 return; 14468 } 14469 if (value == null) { 14470 node.removeAttribute(name); 14471 } else { 14472 node.setAttribute(name, '' + value); 14473 } 14474 14475 { 14476 14477 } 14478 } 14479 14480 /** 14481 * Deletes an attributes from a node. 14482 * 14483 * @param {DOMElement} node 14484 * @param {string} name 14485 */ 14486 function deleteValueForAttribute(node, name) { 14487 node.removeAttribute(name); 14488 } 14489 14490 /** 14491 * Deletes the value for a property on a node. 14492 * 14493 * @param {DOMElement} node 14494 * @param {string} name 14495 */ 14496 function deleteValueForProperty(node, name) { 14497 var propertyInfo = getPropertyInfo(name); 14498 if (propertyInfo) { 14499 var mutationMethod = propertyInfo.mutationMethod; 14500 if (mutationMethod) { 14501 mutationMethod(node, undefined); 14502 } else if (propertyInfo.mustUseProperty) { 14503 var propName = propertyInfo.propertyName; 14504 if (propertyInfo.hasBooleanValue) { 14505 node[propName] = false; 14506 } else { 14507 node[propName] = ''; 14508 } 14509 } else { 14510 node.removeAttribute(propertyInfo.attributeName); 14511 } 14512 } else { 14513 node.removeAttribute(name); 14514 } 14515 } 14516 14517 var ReactControlledValuePropTypes = { 14518 checkPropTypes: null 14519 }; 14520 14521 { 14522 var hasReadOnlyValue = { 14523 button: true, 14524 checkbox: true, 14525 image: true, 14526 hidden: true, 14527 radio: true, 14528 reset: true, 14529 submit: true 14530 }; 14531 14532 var propTypes = { 14533 value: function (props, propName, componentName) { 14534 if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) { 14535 return null; 14536 } 14537 return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 14538 }, 14539 checked: function (props, propName, componentName) { 14540 if (!props[propName] || props.onChange || props.readOnly || props.disabled) { 14541 return null; 14542 } 14543 return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 14544 } 14545 }; 14546 14547 /** 14548 * Provide a linked `value` attribute for controlled forms. You should not use 14549 * this outside of the ReactDOM controlled form components. 14550 */ 14551 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props, getStack) { 14552 checkPropTypes(propTypes, props, 'prop', tagName, getStack); 14553 }; 14554 } 14555 14556 // TODO: direct imports like some-package/src/* are bad. Fix me. 14557 var getCurrentFiberOwnerName$2 = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 14558 var getCurrentFiberStackAddendum$3 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 14559 14560 var didWarnValueDefaultValue = false; 14561 var didWarnCheckedDefaultChecked = false; 14562 var didWarnControlledToUncontrolled = false; 14563 var didWarnUncontrolledToControlled = false; 14564 14565 function isControlled(props) { 14566 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 14567 return usesChecked ? props.checked != null : props.value != null; 14568 } 14569 14570 /** 14571 * Implements an <input> host component that allows setting these optional 14572 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 14573 * 14574 * If `checked` or `value` are not supplied (or null/undefined), user actions 14575 * that affect the checked state or value will trigger updates to the element. 14576 * 14577 * If they are supplied (and not null/undefined), the rendered element will not 14578 * trigger updates to the element. Instead, the props must change in order for 14579 * the rendered element to be updated. 14580 * 14581 * The rendered element will be initialized as unchecked (or `defaultChecked`) 14582 * with an empty value (or `defaultValue`). 14583 * 14584 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 14585 */ 14586 14587 function getHostProps(element, props) { 14588 var node = element; 14589 var value = props.value; 14590 var checked = props.checked; 14591 14592 var hostProps = _assign({ 14593 // Make sure we set .type before any other properties (setting .value 14594 // before .type means .value is lost in IE11 and below) 14595 type: undefined, 14596 // Make sure we set .step before .value (setting .value before .step 14597 // means .value is rounded on mount, based upon step precision) 14598 step: undefined, 14599 // Make sure we set .min & .max before .value (to ensure proper order 14600 // in corner cases such as min or max deriving from value, e.g. Issue #7170) 14601 min: undefined, 14602 max: undefined 14603 }, props, { 14604 defaultChecked: undefined, 14605 defaultValue: undefined, 14606 value: value != null ? value : node._wrapperState.initialValue, 14607 checked: checked != null ? checked : node._wrapperState.initialChecked 14608 }); 14609 14610 return hostProps; 14611 } 14612 14613 function initWrapperState(element, props) { 14614 { 14615 ReactControlledValuePropTypes.checkPropTypes('input', props, getCurrentFiberStackAddendum$3); 14616 14617 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 14618 warning(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName$2() || 'A component', props.type); 14619 didWarnCheckedDefaultChecked = true; 14620 } 14621 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 14622 warning(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName$2() || 'A component', props.type); 14623 didWarnValueDefaultValue = true; 14624 } 14625 } 14626 14627 var defaultValue = props.defaultValue; 14628 var node = element; 14629 node._wrapperState = { 14630 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 14631 initialValue: props.value != null ? props.value : defaultValue, 14632 controlled: isControlled(props) 14633 }; 14634 } 14635 14636 function updateChecked(element, props) { 14637 var node = element; 14638 var checked = props.checked; 14639 if (checked != null) { 14640 setValueForProperty(node, 'checked', checked); 14641 } 14642 } 14643 14644 function updateWrapper(element, props) { 14645 var node = element; 14646 { 14647 var controlled = isControlled(props); 14648 14649 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { 14650 warning(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum$3()); 14651 didWarnUncontrolledToControlled = true; 14652 } 14653 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { 14654 warning(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum$3()); 14655 didWarnControlledToUncontrolled = true; 14656 } 14657 } 14658 14659 updateChecked(element, props); 14660 14661 var value = props.value; 14662 if (value != null) { 14663 if (value === 0 && node.value === '') { 14664 node.value = '0'; 14665 // Note: IE9 reports a number inputs as 'text', so check props instead. 14666 } else if (props.type === 'number') { 14667 // Simulate `input.valueAsNumber`. IE9 does not support it 14668 var valueAsNumber = parseFloat(node.value) || 0; 14669 14670 if ( 14671 // eslint-disable-next-line 14672 value != valueAsNumber || 14673 // eslint-disable-next-line 14674 value == valueAsNumber && node.value != value) { 14675 // Cast `value` to a string to ensure the value is set correctly. While 14676 // browsers typically do this as necessary, jsdom doesn't. 14677 node.value = '' + value; 14678 } 14679 } else if (node.value !== '' + value) { 14680 // Cast `value` to a string to ensure the value is set correctly. While 14681 // browsers typically do this as necessary, jsdom doesn't. 14682 node.value = '' + value; 14683 } 14684 } else { 14685 if (props.value == null && props.defaultValue != null) { 14686 // In Chrome, assigning defaultValue to certain input types triggers input validation. 14687 // For number inputs, the display value loses trailing decimal points. For email inputs, 14688 // Chrome raises "The specified value <x> is not a valid email address". 14689 // 14690 // Here we check to see if the defaultValue has actually changed, avoiding these problems 14691 // when the user is inputting text 14692 // 14693 // https://github.com/facebook/react/issues/7253 14694 if (node.defaultValue !== '' + props.defaultValue) { 14695 node.defaultValue = '' + props.defaultValue; 14696 } 14697 } 14698 if (props.checked == null && props.defaultChecked != null) { 14699 node.defaultChecked = !!props.defaultChecked; 14700 } 14701 } 14702 } 14703 14704 function postMountWrapper(element, props) { 14705 var node = element; 14706 14707 // Detach value from defaultValue. We won't do anything if we're working on 14708 // submit or reset inputs as those values & defaultValues are linked. They 14709 // are not resetable nodes so this operation doesn't matter and actually 14710 // removes browser-default values (eg "Submit Query") when no value is 14711 // provided. 14712 14713 switch (props.type) { 14714 case 'submit': 14715 case 'reset': 14716 break; 14717 case 'color': 14718 case 'date': 14719 case 'datetime': 14720 case 'datetime-local': 14721 case 'month': 14722 case 'time': 14723 case 'week': 14724 // This fixes the no-show issue on iOS Safari and Android Chrome: 14725 // https://github.com/facebook/react/issues/7233 14726 node.value = ''; 14727 node.value = node.defaultValue; 14728 break; 14729 default: 14730 node.value = node.value; 14731 break; 14732 } 14733 14734 // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 14735 // this is needed to work around a chrome bug where setting defaultChecked 14736 // will sometimes influence the value of checked (even after detachment). 14737 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 14738 // We need to temporarily unset name to avoid disrupting radio button groups. 14739 var name = node.name; 14740 if (name !== '') { 14741 node.name = ''; 14742 } 14743 node.defaultChecked = !node.defaultChecked; 14744 node.defaultChecked = !node.defaultChecked; 14745 if (name !== '') { 14746 node.name = name; 14747 } 14748 } 14749 14750 function restoreControlledState$1(element, props) { 14751 var node = element; 14752 updateWrapper(node, props); 14753 updateNamedCousins(node, props); 14754 } 14755 14756 function updateNamedCousins(rootNode, props) { 14757 var name = props.name; 14758 if (props.type === 'radio' && name != null) { 14759 var queryRoot = rootNode; 14760 14761 while (queryRoot.parentNode) { 14762 queryRoot = queryRoot.parentNode; 14763 } 14764 14765 // If `rootNode.form` was non-null, then we could try `form.elements`, 14766 // but that sometimes behaves strangely in IE8. We could also try using 14767 // `form.getElementsByName`, but that will only return direct children 14768 // and won't include inputs that use the HTML5 `form=` attribute. Since 14769 // the input might not even be in a form. It might not even be in the 14770 // document. Let's just use the local `querySelectorAll` to ensure we don't 14771 // miss anything. 14772 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 14773 14774 for (var i = 0; i < group.length; i++) { 14775 var otherNode = group[i]; 14776 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 14777 continue; 14778 } 14779 // This will throw if radio buttons rendered by different copies of React 14780 // and the same name are rendered into the same form (same as #1939). 14781 // That's probably okay; we don't support it just as we don't support 14782 // mixing React radio buttons with non-React ones. 14783 var otherProps = getFiberCurrentPropsFromNode$1(otherNode); 14784 !otherProps ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : void 0; 14785 14786 // We need update the tracked value on the named cousin since the value 14787 // was changed but the input saw no event or value set 14788 updateValueIfChanged(otherNode); 14789 14790 // If this is a controlled radio button group, forcing the input that 14791 // was previously checked to update will cause it to be come re-checked 14792 // as appropriate. 14793 updateWrapper(otherNode, otherProps); 14794 } 14795 } 14796 } 14797 14798 function flattenChildren(children) { 14799 var content = ''; 14800 14801 // Flatten children and warn if they aren't strings or numbers; 14802 // invalid types are ignored. 14803 // We can silently skip them because invalid DOM nesting warning 14804 // catches these cases in Fiber. 14805 React.Children.forEach(children, function (child) { 14806 if (child == null) { 14807 return; 14808 } 14809 if (typeof child === 'string' || typeof child === 'number') { 14810 content += child; 14811 } 14812 }); 14813 14814 return content; 14815 } 14816 14817 /** 14818 * Implements an <option> host component that warns when `selected` is set. 14819 */ 14820 14821 function validateProps(element, props) { 14822 // TODO (yungsters): Remove support for `selected` in <option>. 14823 { 14824 warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 14825 } 14826 } 14827 14828 function postMountWrapper$1(element, props) { 14829 // value="" should make a value attribute (#6219) 14830 if (props.value != null) { 14831 element.setAttribute('value', props.value); 14832 } 14833 } 14834 14835 function getHostProps$1(element, props) { 14836 var hostProps = _assign({ children: undefined }, props); 14837 var content = flattenChildren(props.children); 14838 14839 if (content) { 14840 hostProps.children = content; 14841 } 14842 14843 return hostProps; 14844 } 14845 14846 // TODO: direct imports like some-package/src/* are bad. Fix me. 14847 var getCurrentFiberOwnerName$3 = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 14848 var getCurrentFiberStackAddendum$4 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 14849 14850 14851 { 14852 var didWarnValueDefaultValue$1 = false; 14853 } 14854 14855 function getDeclarationErrorAddendum() { 14856 var ownerName = getCurrentFiberOwnerName$3(); 14857 if (ownerName) { 14858 return '\n\nCheck the render method of `' + ownerName + '`.'; 14859 } 14860 return ''; 14861 } 14862 14863 var valuePropNames = ['value', 'defaultValue']; 14864 14865 /** 14866 * Validation function for `value` and `defaultValue`. 14867 */ 14868 function checkSelectPropTypes(props) { 14869 ReactControlledValuePropTypes.checkPropTypes('select', props, getCurrentFiberStackAddendum$4); 14870 14871 for (var i = 0; i < valuePropNames.length; i++) { 14872 var propName = valuePropNames[i]; 14873 if (props[propName] == null) { 14874 continue; 14875 } 14876 var isArray = Array.isArray(props[propName]); 14877 if (props.multiple && !isArray) { 14878 warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 14879 } else if (!props.multiple && isArray) { 14880 warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 14881 } 14882 } 14883 } 14884 14885 function updateOptions(node, multiple, propValue, setDefaultSelected) { 14886 var options = node.options; 14887 14888 if (multiple) { 14889 var selectedValues = propValue; 14890 var selectedValue = {}; 14891 for (var i = 0; i < selectedValues.length; i++) { 14892 // Prefix to avoid chaos with special keys. 14893 selectedValue['$' + selectedValues[i]] = true; 14894 } 14895 for (var _i = 0; _i < options.length; _i++) { 14896 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 14897 if (options[_i].selected !== selected) { 14898 options[_i].selected = selected; 14899 } 14900 if (selected && setDefaultSelected) { 14901 options[_i].defaultSelected = true; 14902 } 14903 } 14904 } else { 14905 // Do not set `select.value` as exact behavior isn't consistent across all 14906 // browsers for all cases. 14907 var _selectedValue = '' + propValue; 14908 var defaultSelected = null; 14909 for (var _i2 = 0; _i2 < options.length; _i2++) { 14910 if (options[_i2].value === _selectedValue) { 14911 options[_i2].selected = true; 14912 if (setDefaultSelected) { 14913 options[_i2].defaultSelected = true; 14914 } 14915 return; 14916 } 14917 if (defaultSelected === null && !options[_i2].disabled) { 14918 defaultSelected = options[_i2]; 14919 } 14920 } 14921 if (defaultSelected !== null) { 14922 defaultSelected.selected = true; 14923 } 14924 } 14925 } 14926 14927 /** 14928 * Implements a <select> host component that allows optionally setting the 14929 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 14930 * stringable. If `multiple` is true, the prop must be an array of stringables. 14931 * 14932 * If `value` is not supplied (or null/undefined), user actions that change the 14933 * selected option will trigger updates to the rendered options. 14934 * 14935 * If it is supplied (and not null/undefined), the rendered options will not 14936 * update in response to user actions. Instead, the `value` prop must change in 14937 * order for the rendered options to update. 14938 * 14939 * If `defaultValue` is provided, any options with the supplied values will be 14940 * selected. 14941 */ 14942 14943 function getHostProps$2(element, props) { 14944 return _assign({}, props, { 14945 value: undefined 14946 }); 14947 } 14948 14949 function initWrapperState$1(element, props) { 14950 var node = element; 14951 { 14952 checkSelectPropTypes(props); 14953 } 14954 14955 var value = props.value; 14956 node._wrapperState = { 14957 initialValue: value != null ? value : props.defaultValue, 14958 wasMultiple: !!props.multiple 14959 }; 14960 14961 { 14962 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 14963 warning(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components'); 14964 didWarnValueDefaultValue$1 = true; 14965 } 14966 } 14967 } 14968 14969 function postMountWrapper$2(element, props) { 14970 var node = element; 14971 node.multiple = !!props.multiple; 14972 var value = props.value; 14973 if (value != null) { 14974 updateOptions(node, !!props.multiple, value, false); 14975 } else if (props.defaultValue != null) { 14976 updateOptions(node, !!props.multiple, props.defaultValue, true); 14977 } 14978 } 14979 14980 function postUpdateWrapper(element, props) { 14981 var node = element; 14982 // After the initial mount, we control selected-ness manually so don't pass 14983 // this value down 14984 node._wrapperState.initialValue = undefined; 14985 14986 var wasMultiple = node._wrapperState.wasMultiple; 14987 node._wrapperState.wasMultiple = !!props.multiple; 14988 14989 var value = props.value; 14990 if (value != null) { 14991 updateOptions(node, !!props.multiple, value, false); 14992 } else if (wasMultiple !== !!props.multiple) { 14993 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 14994 if (props.defaultValue != null) { 14995 updateOptions(node, !!props.multiple, props.defaultValue, true); 14996 } else { 14997 // Revert the select back to its default unselected state. 14998 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 14999 } 15000 } 15001 } 15002 15003 function restoreControlledState$2(element, props) { 15004 var node = element; 15005 var value = props.value; 15006 15007 if (value != null) { 15008 updateOptions(node, !!props.multiple, value, false); 15009 } 15010 } 15011 15012 // TODO: direct imports like some-package/src/* are bad. Fix me. 15013 var getCurrentFiberStackAddendum$5 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 15014 15015 var didWarnValDefaultVal = false; 15016 15017 /** 15018 * Implements a <textarea> host component that allows setting `value`, and 15019 * `defaultValue`. This differs from the traditional DOM API because value is 15020 * usually set as PCDATA children. 15021 * 15022 * If `value` is not supplied (or null/undefined), user actions that affect the 15023 * value will trigger updates to the element. 15024 * 15025 * If `value` is supplied (and not null/undefined), the rendered element will 15026 * not trigger updates to the element. Instead, the `value` prop must change in 15027 * order for the rendered element to be updated. 15028 * 15029 * The rendered element will be initialized with an empty value, the prop 15030 * `defaultValue` if specified, or the children content (deprecated). 15031 */ 15032 15033 function getHostProps$3(element, props) { 15034 var node = element; 15035 !(props.dangerouslySetInnerHTML == null) ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : void 0; 15036 15037 // Always set children to the same thing. In IE9, the selection range will 15038 // get reset if `textContent` is mutated. We could add a check in setTextContent 15039 // to only set the value if/when the value differs from the node value (which would 15040 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 15041 // solution. The value can be a boolean or object so that's why it's forced 15042 // to be a string. 15043 var hostProps = _assign({}, props, { 15044 value: undefined, 15045 defaultValue: undefined, 15046 children: '' + node._wrapperState.initialValue 15047 }); 15048 15049 return hostProps; 15050 } 15051 15052 function initWrapperState$2(element, props) { 15053 var node = element; 15054 { 15055 ReactControlledValuePropTypes.checkPropTypes('textarea', props, getCurrentFiberStackAddendum$5); 15056 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 15057 warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components'); 15058 didWarnValDefaultVal = true; 15059 } 15060 } 15061 15062 var initialValue = props.value; 15063 15064 // Only bother fetching default value if we're going to use it 15065 if (initialValue == null) { 15066 var defaultValue = props.defaultValue; 15067 // TODO (yungsters): Remove support for children content in <textarea>. 15068 var children = props.children; 15069 if (children != null) { 15070 { 15071 warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 15072 } 15073 !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0; 15074 if (Array.isArray(children)) { 15075 !(children.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0; 15076 children = children[0]; 15077 } 15078 15079 defaultValue = '' + children; 15080 } 15081 if (defaultValue == null) { 15082 defaultValue = ''; 15083 } 15084 initialValue = defaultValue; 15085 } 15086 15087 node._wrapperState = { 15088 initialValue: '' + initialValue 15089 }; 15090 } 15091 15092 function updateWrapper$1(element, props) { 15093 var node = element; 15094 var value = props.value; 15095 if (value != null) { 15096 // Cast `value` to a string to ensure the value is set correctly. While 15097 // browsers typically do this as necessary, jsdom doesn't. 15098 var newValue = '' + value; 15099 15100 // To avoid side effects (such as losing text selection), only set value if changed 15101 if (newValue !== node.value) { 15102 node.value = newValue; 15103 } 15104 if (props.defaultValue == null) { 15105 node.defaultValue = newValue; 15106 } 15107 } 15108 if (props.defaultValue != null) { 15109 node.defaultValue = props.defaultValue; 15110 } 15111 } 15112 15113 function postMountWrapper$3(element, props) { 15114 var node = element; 15115 // This is in postMount because we need access to the DOM node, which is not 15116 // available until after the component has mounted. 15117 var textContent = node.textContent; 15118 15119 // Only set node.value if textContent is equal to the expected 15120 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 15121 // will populate textContent as well. 15122 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 15123 if (textContent === node._wrapperState.initialValue) { 15124 node.value = textContent; 15125 } 15126 } 15127 15128 function restoreControlledState$3(element, props) { 15129 // DOM component is still mounted; update 15130 updateWrapper$1(element, props); 15131 } 15132 15133 var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml'; 15134 var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 15135 var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 15136 15137 var Namespaces = { 15138 html: HTML_NAMESPACE$1, 15139 mathml: MATH_NAMESPACE, 15140 svg: SVG_NAMESPACE 15141 }; 15142 15143 // Assumes there is no parent namespace. 15144 function getIntrinsicNamespace(type) { 15145 switch (type) { 15146 case 'svg': 15147 return SVG_NAMESPACE; 15148 case 'math': 15149 return MATH_NAMESPACE; 15150 default: 15151 return HTML_NAMESPACE$1; 15152 } 15153 } 15154 15155 function getChildNamespace(parentNamespace, type) { 15156 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) { 15157 // No (or default) parent namespace: potential entry point. 15158 return getIntrinsicNamespace(type); 15159 } 15160 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 15161 // We're leaving SVG. 15162 return HTML_NAMESPACE$1; 15163 } 15164 // By default, pass namespace below. 15165 return parentNamespace; 15166 } 15167 15168 /* globals MSApp */ 15169 15170 /** 15171 * Create a function which has 'unsafe' privileges (required by windows8 apps) 15172 */ 15173 var createMicrosoftUnsafeLocalFunction = function (func) { 15174 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 15175 return function (arg0, arg1, arg2, arg3) { 15176 MSApp.execUnsafeLocalFunction(function () { 15177 return func(arg0, arg1, arg2, arg3); 15178 }); 15179 }; 15180 } else { 15181 return func; 15182 } 15183 }; 15184 15185 // SVG temp container for IE lacking innerHTML 15186 var reusableSVGContainer = void 0; 15187 15188 /** 15189 * Set the innerHTML property of a node 15190 * 15191 * @param {DOMElement} node 15192 * @param {string} html 15193 * @internal 15194 */ 15195 var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 15196 // IE does not have innerHTML for SVG nodes, so instead we inject the 15197 // new markup in a temp node and then move the child nodes across into 15198 // the target node 15199 15200 if (node.namespaceURI === Namespaces.svg && !('innerHTML' in node)) { 15201 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 15202 reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>'; 15203 var svgNode = reusableSVGContainer.firstChild; 15204 while (node.firstChild) { 15205 node.removeChild(node.firstChild); 15206 } 15207 while (svgNode.firstChild) { 15208 node.appendChild(svgNode.firstChild); 15209 } 15210 } else { 15211 node.innerHTML = html; 15212 } 15213 }); 15214 15215 /** 15216 * Set the textContent property of a node, ensuring that whitespace is preserved 15217 * even in IE8. innerText is a poor substitute for textContent and, among many 15218 * issues, inserts <br> instead of the literal newline chars. innerHTML behaves 15219 * as it should. 15220 * 15221 * @param {DOMElement} node 15222 * @param {string} text 15223 * @internal 15224 */ 15225 var setTextContent = function (node, text) { 15226 if (text) { 15227 var firstChild = node.firstChild; 15228 15229 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 15230 firstChild.nodeValue = text; 15231 return; 15232 } 15233 } 15234 node.textContent = text; 15235 }; 15236 15237 /** 15238 * CSS properties which accept numbers but are not in units of "px". 15239 */ 15240 var isUnitlessNumber = { 15241 animationIterationCount: true, 15242 borderImageOutset: true, 15243 borderImageSlice: true, 15244 borderImageWidth: true, 15245 boxFlex: true, 15246 boxFlexGroup: true, 15247 boxOrdinalGroup: true, 15248 columnCount: true, 15249 columns: true, 15250 flex: true, 15251 flexGrow: true, 15252 flexPositive: true, 15253 flexShrink: true, 15254 flexNegative: true, 15255 flexOrder: true, 15256 gridRow: true, 15257 gridRowEnd: true, 15258 gridRowSpan: true, 15259 gridRowStart: true, 15260 gridColumn: true, 15261 gridColumnEnd: true, 15262 gridColumnSpan: true, 15263 gridColumnStart: true, 15264 fontWeight: true, 15265 lineClamp: true, 15266 lineHeight: true, 15267 opacity: true, 15268 order: true, 15269 orphans: true, 15270 tabSize: true, 15271 widows: true, 15272 zIndex: true, 15273 zoom: true, 15274 15275 // SVG-related properties 15276 fillOpacity: true, 15277 floodOpacity: true, 15278 stopOpacity: true, 15279 strokeDasharray: true, 15280 strokeDashoffset: true, 15281 strokeMiterlimit: true, 15282 strokeOpacity: true, 15283 strokeWidth: true 15284 }; 15285 15286 /** 15287 * @param {string} prefix vendor-specific prefix, eg: Webkit 15288 * @param {string} key style name, eg: transitionDuration 15289 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 15290 * WebkitTransitionDuration 15291 */ 15292 function prefixKey(prefix, key) { 15293 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 15294 } 15295 15296 /** 15297 * Support style names that may come passed in prefixed by adding permutations 15298 * of vendor prefixes. 15299 */ 15300 var prefixes = ['Webkit', 'ms', 'Moz', 'O']; 15301 15302 // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 15303 // infinite loop, because it iterates over the newly added props too. 15304 Object.keys(isUnitlessNumber).forEach(function (prop) { 15305 prefixes.forEach(function (prefix) { 15306 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 15307 }); 15308 }); 15309 15310 /** 15311 * Convert a value into the proper css writable value. The style name `name` 15312 * should be logical (no hyphens), as specified 15313 * in `CSSProperty.isUnitlessNumber`. 15314 * 15315 * @param {string} name CSS property name such as `topMargin`. 15316 * @param {*} value CSS property value such as `10px`. 15317 * @return {string} Normalized style value with dimensions applied. 15318 */ 15319 function dangerousStyleValue(name, value, isCustomProperty) { 15320 // Note that we've removed escapeTextForBrowser() calls here since the 15321 // whole string will be escaped when the attribute is injected into 15322 // the markup. If you provide unsafe user data here they can inject 15323 // arbitrary CSS which may be problematic (I couldn't repro this): 15324 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 15325 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 15326 // This is not an XSS hole but instead a potential CSS injection issue 15327 // which has lead to a greater discussion about how we're going to 15328 // trust URLs moving forward. See #2115901 15329 15330 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 15331 if (isEmpty) { 15332 return ''; 15333 } 15334 15335 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 15336 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 15337 } 15338 15339 return ('' + value).trim(); 15340 } 15341 15342 var warnValidStyle = emptyFunction; 15343 15344 { 15345 // 'msTransform' is correct, but the other prefixes should be capitalized 15346 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 15347 15348 // style values shouldn't contain a semicolon 15349 var badStyleValueWithSemicolonPattern = /;\s*$/; 15350 15351 var warnedStyleNames = {}; 15352 var warnedStyleValues = {}; 15353 var warnedForNaNValue = false; 15354 var warnedForInfinityValue = false; 15355 15356 var warnHyphenatedStyleName = function (name, getStack) { 15357 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 15358 return; 15359 } 15360 15361 warnedStyleNames[name] = true; 15362 warning(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName(name), getStack()); 15363 }; 15364 15365 var warnBadVendoredStyleName = function (name, getStack) { 15366 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 15367 return; 15368 } 15369 15370 warnedStyleNames[name] = true; 15371 warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), getStack()); 15372 }; 15373 15374 var warnStyleValueWithSemicolon = function (name, value, getStack) { 15375 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 15376 return; 15377 } 15378 15379 warnedStyleValues[value] = true; 15380 warning(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.%s', name, value.replace(badStyleValueWithSemicolonPattern, ''), getStack()); 15381 }; 15382 15383 var warnStyleValueIsNaN = function (name, value, getStack) { 15384 if (warnedForNaNValue) { 15385 return; 15386 } 15387 15388 warnedForNaNValue = true; 15389 warning(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, getStack()); 15390 }; 15391 15392 var warnStyleValueIsInfinity = function (name, value, getStack) { 15393 if (warnedForInfinityValue) { 15394 return; 15395 } 15396 15397 warnedForInfinityValue = true; 15398 warning(false, '`Infinity` is an invalid value for the `%s` css style property.%s', name, getStack()); 15399 }; 15400 15401 warnValidStyle = function (name, value, getStack) { 15402 if (name.indexOf('-') > -1) { 15403 warnHyphenatedStyleName(name, getStack); 15404 } else if (badVendoredStyleNamePattern.test(name)) { 15405 warnBadVendoredStyleName(name, getStack); 15406 } else if (badStyleValueWithSemicolonPattern.test(value)) { 15407 warnStyleValueWithSemicolon(name, value, getStack); 15408 } 15409 15410 if (typeof value === 'number') { 15411 if (isNaN(value)) { 15412 warnStyleValueIsNaN(name, value, getStack); 15413 } else if (!isFinite(value)) { 15414 warnStyleValueIsInfinity(name, value, getStack); 15415 } 15416 } 15417 }; 15418 } 15419 15420 var warnValidStyle$1 = warnValidStyle; 15421 15422 /** 15423 * Operations for dealing with CSS properties. 15424 */ 15425 15426 /** 15427 * This creates a string that is expected to be equivalent to the style 15428 * attribute generated by server-side rendering. It by-passes warnings and 15429 * security checks so it's not safe to use this value for anything other than 15430 * comparison. It is only used in DEV for SSR validation. 15431 */ 15432 function createDangerousStringForStyles(styles) { 15433 { 15434 var serialized = ''; 15435 var delimiter = ''; 15436 for (var styleName in styles) { 15437 if (!styles.hasOwnProperty(styleName)) { 15438 continue; 15439 } 15440 var styleValue = styles[styleName]; 15441 if (styleValue != null) { 15442 var isCustomProperty = styleName.indexOf('--') === 0; 15443 serialized += delimiter + hyphenateStyleName(styleName) + ':'; 15444 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 15445 15446 delimiter = ';'; 15447 } 15448 } 15449 return serialized || null; 15450 } 15451 } 15452 15453 /** 15454 * Sets the value for multiple styles on a node. If a value is specified as 15455 * '' (empty string), the corresponding style property will be unset. 15456 * 15457 * @param {DOMElement} node 15458 * @param {object} styles 15459 */ 15460 function setValueForStyles(node, styles, getStack) { 15461 var style = node.style; 15462 for (var styleName in styles) { 15463 if (!styles.hasOwnProperty(styleName)) { 15464 continue; 15465 } 15466 var isCustomProperty = styleName.indexOf('--') === 0; 15467 { 15468 if (!isCustomProperty) { 15469 warnValidStyle$1(styleName, styles[styleName], getStack); 15470 } 15471 } 15472 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 15473 if (styleName === 'float') { 15474 styleName = 'cssFloat'; 15475 } 15476 if (isCustomProperty) { 15477 style.setProperty(styleName, styleValue); 15478 } else { 15479 style[styleName] = styleValue; 15480 } 15481 } 15482 } 15483 15484 // For HTML, certain tags should omit their close tag. We keep a whitelist for 15485 // those special-case tags. 15486 15487 var omittedCloseTags = { 15488 area: true, 15489 base: true, 15490 br: true, 15491 col: true, 15492 embed: true, 15493 hr: true, 15494 img: true, 15495 input: true, 15496 keygen: true, 15497 link: true, 15498 meta: true, 15499 param: true, 15500 source: true, 15501 track: true, 15502 wbr: true 15503 }; 15504 15505 // For HTML, certain tags cannot have children. This has the same purpose as 15506 // `omittedCloseTags` except that `menuitem` should still have its closing tag. 15507 15508 var voidElementTags = _assign({ 15509 menuitem: true 15510 }, omittedCloseTags); 15511 15512 var HTML$1 = '__html'; 15513 15514 function assertValidProps(tag, props, getStack) { 15515 if (!props) { 15516 return; 15517 } 15518 // Note the use of `==` which checks for null or undefined. 15519 if (voidElementTags[tag]) { 15520 !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, getStack()) : void 0; 15521 } 15522 if (props.dangerouslySetInnerHTML != null) { 15523 !(props.children == null) ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0; 15524 !(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML) ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0; 15525 } 15526 { 15527 warning(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack()); 15528 } 15529 !(props.style == null || typeof props.style === 'object') ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getStack()) : void 0; 15530 } 15531 15532 function isCustomComponent(tagName, props) { 15533 if (tagName.indexOf('-') === -1) { 15534 return typeof props.is === 'string'; 15535 } 15536 switch (tagName) { 15537 // These are reserved SVG and MathML elements. 15538 // We don't mind this whitelist too much because we expect it to never grow. 15539 // The alternative is to track the namespace in a few places which is convoluted. 15540 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 15541 case 'annotation-xml': 15542 case 'color-profile': 15543 case 'font-face': 15544 case 'font-face-src': 15545 case 'font-face-uri': 15546 case 'font-face-format': 15547 case 'font-face-name': 15548 case 'missing-glyph': 15549 return false; 15550 default: 15551 return true; 15552 } 15553 } 15554 15555 var ariaProperties = { 15556 'aria-current': 0, // state 15557 'aria-details': 0, 15558 'aria-disabled': 0, // state 15559 'aria-hidden': 0, // state 15560 'aria-invalid': 0, // state 15561 'aria-keyshortcuts': 0, 15562 'aria-label': 0, 15563 'aria-roledescription': 0, 15564 // Widget Attributes 15565 'aria-autocomplete': 0, 15566 'aria-checked': 0, 15567 'aria-expanded': 0, 15568 'aria-haspopup': 0, 15569 'aria-level': 0, 15570 'aria-modal': 0, 15571 'aria-multiline': 0, 15572 'aria-multiselectable': 0, 15573 'aria-orientation': 0, 15574 'aria-placeholder': 0, 15575 'aria-pressed': 0, 15576 'aria-readonly': 0, 15577 'aria-required': 0, 15578 'aria-selected': 0, 15579 'aria-sort': 0, 15580 'aria-valuemax': 0, 15581 'aria-valuemin': 0, 15582 'aria-valuenow': 0, 15583 'aria-valuetext': 0, 15584 // Live Region Attributes 15585 'aria-atomic': 0, 15586 'aria-busy': 0, 15587 'aria-live': 0, 15588 'aria-relevant': 0, 15589 // Drag-and-Drop Attributes 15590 'aria-dropeffect': 0, 15591 'aria-grabbed': 0, 15592 // Relationship Attributes 15593 'aria-activedescendant': 0, 15594 'aria-colcount': 0, 15595 'aria-colindex': 0, 15596 'aria-colspan': 0, 15597 'aria-controls': 0, 15598 'aria-describedby': 0, 15599 'aria-errormessage': 0, 15600 'aria-flowto': 0, 15601 'aria-labelledby': 0, 15602 'aria-owns': 0, 15603 'aria-posinset': 0, 15604 'aria-rowcount': 0, 15605 'aria-rowindex': 0, 15606 'aria-rowspan': 0, 15607 'aria-setsize': 0 15608 }; 15609 15610 var warnedProperties = {}; 15611 var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 15612 var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 15613 15614 var hasOwnProperty = Object.prototype.hasOwnProperty; 15615 15616 function getStackAddendum() { 15617 var stack = ReactDebugCurrentFrame.getStackAddendum(); 15618 return stack != null ? stack : ''; 15619 } 15620 15621 function validateProperty(tagName, name) { 15622 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) { 15623 return true; 15624 } 15625 15626 if (rARIACamel.test(name)) { 15627 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 15628 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; 15629 15630 // If this is an aria-* attribute, but is not listed in the known DOM 15631 // DOM properties, then it is an invalid aria-* attribute. 15632 if (correctName == null) { 15633 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum()); 15634 warnedProperties[name] = true; 15635 return true; 15636 } 15637 // aria-* attributes should be lowercase; suggest the lowercase version. 15638 if (name !== correctName) { 15639 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum()); 15640 warnedProperties[name] = true; 15641 return true; 15642 } 15643 } 15644 15645 if (rARIA.test(name)) { 15646 var lowerCasedName = name.toLowerCase(); 15647 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; 15648 15649 // If this is an aria-* attribute, but is not listed in the known DOM 15650 // DOM properties, then it is an invalid aria-* attribute. 15651 if (standardName == null) { 15652 warnedProperties[name] = true; 15653 return false; 15654 } 15655 // aria-* attributes should be lowercase; suggest the lowercase version. 15656 if (name !== standardName) { 15657 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum()); 15658 warnedProperties[name] = true; 15659 return true; 15660 } 15661 } 15662 15663 return true; 15664 } 15665 15666 function warnInvalidARIAProps(type, props) { 15667 var invalidProps = []; 15668 15669 for (var key in props) { 15670 var isValid = validateProperty(type, key); 15671 if (!isValid) { 15672 invalidProps.push(key); 15673 } 15674 } 15675 15676 var unknownPropString = invalidProps.map(function (prop) { 15677 return '`' + prop + '`'; 15678 }).join(', '); 15679 15680 if (invalidProps.length === 1) { 15681 warning(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum()); 15682 } else if (invalidProps.length > 1) { 15683 warning(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum()); 15684 } 15685 } 15686 15687 function validateProperties(type, props) { 15688 if (isCustomComponent(type, props)) { 15689 return; 15690 } 15691 warnInvalidARIAProps(type, props); 15692 } 15693 15694 var didWarnValueNull = false; 15695 15696 function getStackAddendum$1() { 15697 var stack = ReactDebugCurrentFrame.getStackAddendum(); 15698 return stack != null ? stack : ''; 15699 } 15700 15701 function validateProperties$1(type, props) { 15702 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 15703 return; 15704 } 15705 15706 if (props != null && props.value === null && !didWarnValueNull) { 15707 didWarnValueNull = true; 15708 if (type === 'select' && props.multiple) { 15709 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.%s', type, getStackAddendum$1()); 15710 } else { 15711 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$1()); 15712 } 15713 } 15714 } 15715 15716 // When adding attributes to the HTML or SVG whitelist, be sure to 15717 // also add them to this module to ensure casing and incorrect name 15718 // warnings. 15719 var possibleStandardNames = { 15720 // HTML 15721 accept: 'accept', 15722 acceptcharset: 'acceptCharset', 15723 'accept-charset': 'acceptCharset', 15724 accesskey: 'accessKey', 15725 action: 'action', 15726 allowfullscreen: 'allowFullScreen', 15727 alt: 'alt', 15728 as: 'as', 15729 async: 'async', 15730 autocapitalize: 'autoCapitalize', 15731 autocomplete: 'autoComplete', 15732 autocorrect: 'autoCorrect', 15733 autofocus: 'autoFocus', 15734 autoplay: 'autoPlay', 15735 autosave: 'autoSave', 15736 capture: 'capture', 15737 cellpadding: 'cellPadding', 15738 cellspacing: 'cellSpacing', 15739 challenge: 'challenge', 15740 charset: 'charSet', 15741 checked: 'checked', 15742 children: 'children', 15743 cite: 'cite', 15744 'class': 'className', 15745 classid: 'classID', 15746 classname: 'className', 15747 cols: 'cols', 15748 colspan: 'colSpan', 15749 content: 'content', 15750 contenteditable: 'contentEditable', 15751 contextmenu: 'contextMenu', 15752 controls: 'controls', 15753 controlslist: 'controlsList', 15754 coords: 'coords', 15755 crossorigin: 'crossOrigin', 15756 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 15757 data: 'data', 15758 datetime: 'dateTime', 15759 'default': 'default', 15760 defaultchecked: 'defaultChecked', 15761 defaultvalue: 'defaultValue', 15762 defer: 'defer', 15763 dir: 'dir', 15764 disabled: 'disabled', 15765 download: 'download', 15766 draggable: 'draggable', 15767 enctype: 'encType', 15768 'for': 'htmlFor', 15769 form: 'form', 15770 formmethod: 'formMethod', 15771 formaction: 'formAction', 15772 formenctype: 'formEncType', 15773 formnovalidate: 'formNoValidate', 15774 formtarget: 'formTarget', 15775 frameborder: 'frameBorder', 15776 headers: 'headers', 15777 height: 'height', 15778 hidden: 'hidden', 15779 high: 'high', 15780 href: 'href', 15781 hreflang: 'hrefLang', 15782 htmlfor: 'htmlFor', 15783 httpequiv: 'httpEquiv', 15784 'http-equiv': 'httpEquiv', 15785 icon: 'icon', 15786 id: 'id', 15787 innerhtml: 'innerHTML', 15788 inputmode: 'inputMode', 15789 integrity: 'integrity', 15790 is: 'is', 15791 itemid: 'itemID', 15792 itemprop: 'itemProp', 15793 itemref: 'itemRef', 15794 itemscope: 'itemScope', 15795 itemtype: 'itemType', 15796 keyparams: 'keyParams', 15797 keytype: 'keyType', 15798 kind: 'kind', 15799 label: 'label', 15800 lang: 'lang', 15801 list: 'list', 15802 loop: 'loop', 15803 low: 'low', 15804 manifest: 'manifest', 15805 marginwidth: 'marginWidth', 15806 marginheight: 'marginHeight', 15807 max: 'max', 15808 maxlength: 'maxLength', 15809 media: 'media', 15810 mediagroup: 'mediaGroup', 15811 method: 'method', 15812 min: 'min', 15813 minlength: 'minLength', 15814 multiple: 'multiple', 15815 muted: 'muted', 15816 name: 'name', 15817 nonce: 'nonce', 15818 novalidate: 'noValidate', 15819 open: 'open', 15820 optimum: 'optimum', 15821 pattern: 'pattern', 15822 placeholder: 'placeholder', 15823 playsinline: 'playsInline', 15824 poster: 'poster', 15825 preload: 'preload', 15826 profile: 'profile', 15827 radiogroup: 'radioGroup', 15828 readonly: 'readOnly', 15829 referrerpolicy: 'referrerPolicy', 15830 rel: 'rel', 15831 required: 'required', 15832 reversed: 'reversed', 15833 role: 'role', 15834 rows: 'rows', 15835 rowspan: 'rowSpan', 15836 sandbox: 'sandbox', 15837 scope: 'scope', 15838 scoped: 'scoped', 15839 scrolling: 'scrolling', 15840 seamless: 'seamless', 15841 selected: 'selected', 15842 shape: 'shape', 15843 size: 'size', 15844 sizes: 'sizes', 15845 span: 'span', 15846 spellcheck: 'spellCheck', 15847 src: 'src', 15848 srcdoc: 'srcDoc', 15849 srclang: 'srcLang', 15850 srcset: 'srcSet', 15851 start: 'start', 15852 step: 'step', 15853 style: 'style', 15854 summary: 'summary', 15855 tabindex: 'tabIndex', 15856 target: 'target', 15857 title: 'title', 15858 type: 'type', 15859 usemap: 'useMap', 15860 value: 'value', 15861 width: 'width', 15862 wmode: 'wmode', 15863 wrap: 'wrap', 15864 15865 // SVG 15866 about: 'about', 15867 accentheight: 'accentHeight', 15868 'accent-height': 'accentHeight', 15869 accumulate: 'accumulate', 15870 additive: 'additive', 15871 alignmentbaseline: 'alignmentBaseline', 15872 'alignment-baseline': 'alignmentBaseline', 15873 allowreorder: 'allowReorder', 15874 alphabetic: 'alphabetic', 15875 amplitude: 'amplitude', 15876 arabicform: 'arabicForm', 15877 'arabic-form': 'arabicForm', 15878 ascent: 'ascent', 15879 attributename: 'attributeName', 15880 attributetype: 'attributeType', 15881 autoreverse: 'autoReverse', 15882 azimuth: 'azimuth', 15883 basefrequency: 'baseFrequency', 15884 baselineshift: 'baselineShift', 15885 'baseline-shift': 'baselineShift', 15886 baseprofile: 'baseProfile', 15887 bbox: 'bbox', 15888 begin: 'begin', 15889 bias: 'bias', 15890 by: 'by', 15891 calcmode: 'calcMode', 15892 capheight: 'capHeight', 15893 'cap-height': 'capHeight', 15894 clip: 'clip', 15895 clippath: 'clipPath', 15896 'clip-path': 'clipPath', 15897 clippathunits: 'clipPathUnits', 15898 cliprule: 'clipRule', 15899 'clip-rule': 'clipRule', 15900 color: 'color', 15901 colorinterpolation: 'colorInterpolation', 15902 'color-interpolation': 'colorInterpolation', 15903 colorinterpolationfilters: 'colorInterpolationFilters', 15904 'color-interpolation-filters': 'colorInterpolationFilters', 15905 colorprofile: 'colorProfile', 15906 'color-profile': 'colorProfile', 15907 colorrendering: 'colorRendering', 15908 'color-rendering': 'colorRendering', 15909 contentscripttype: 'contentScriptType', 15910 contentstyletype: 'contentStyleType', 15911 cursor: 'cursor', 15912 cx: 'cx', 15913 cy: 'cy', 15914 d: 'd', 15915 datatype: 'datatype', 15916 decelerate: 'decelerate', 15917 descent: 'descent', 15918 diffuseconstant: 'diffuseConstant', 15919 direction: 'direction', 15920 display: 'display', 15921 divisor: 'divisor', 15922 dominantbaseline: 'dominantBaseline', 15923 'dominant-baseline': 'dominantBaseline', 15924 dur: 'dur', 15925 dx: 'dx', 15926 dy: 'dy', 15927 edgemode: 'edgeMode', 15928 elevation: 'elevation', 15929 enablebackground: 'enableBackground', 15930 'enable-background': 'enableBackground', 15931 end: 'end', 15932 exponent: 'exponent', 15933 externalresourcesrequired: 'externalResourcesRequired', 15934 fill: 'fill', 15935 fillopacity: 'fillOpacity', 15936 'fill-opacity': 'fillOpacity', 15937 fillrule: 'fillRule', 15938 'fill-rule': 'fillRule', 15939 filter: 'filter', 15940 filterres: 'filterRes', 15941 filterunits: 'filterUnits', 15942 floodopacity: 'floodOpacity', 15943 'flood-opacity': 'floodOpacity', 15944 floodcolor: 'floodColor', 15945 'flood-color': 'floodColor', 15946 focusable: 'focusable', 15947 fontfamily: 'fontFamily', 15948 'font-family': 'fontFamily', 15949 fontsize: 'fontSize', 15950 'font-size': 'fontSize', 15951 fontsizeadjust: 'fontSizeAdjust', 15952 'font-size-adjust': 'fontSizeAdjust', 15953 fontstretch: 'fontStretch', 15954 'font-stretch': 'fontStretch', 15955 fontstyle: 'fontStyle', 15956 'font-style': 'fontStyle', 15957 fontvariant: 'fontVariant', 15958 'font-variant': 'fontVariant', 15959 fontweight: 'fontWeight', 15960 'font-weight': 'fontWeight', 15961 format: 'format', 15962 from: 'from', 15963 fx: 'fx', 15964 fy: 'fy', 15965 g1: 'g1', 15966 g2: 'g2', 15967 glyphname: 'glyphName', 15968 'glyph-name': 'glyphName', 15969 glyphorientationhorizontal: 'glyphOrientationHorizontal', 15970 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 15971 glyphorientationvertical: 'glyphOrientationVertical', 15972 'glyph-orientation-vertical': 'glyphOrientationVertical', 15973 glyphref: 'glyphRef', 15974 gradienttransform: 'gradientTransform', 15975 gradientunits: 'gradientUnits', 15976 hanging: 'hanging', 15977 horizadvx: 'horizAdvX', 15978 'horiz-adv-x': 'horizAdvX', 15979 horizoriginx: 'horizOriginX', 15980 'horiz-origin-x': 'horizOriginX', 15981 ideographic: 'ideographic', 15982 imagerendering: 'imageRendering', 15983 'image-rendering': 'imageRendering', 15984 in2: 'in2', 15985 'in': 'in', 15986 inlist: 'inlist', 15987 intercept: 'intercept', 15988 k1: 'k1', 15989 k2: 'k2', 15990 k3: 'k3', 15991 k4: 'k4', 15992 k: 'k', 15993 kernelmatrix: 'kernelMatrix', 15994 kernelunitlength: 'kernelUnitLength', 15995 kerning: 'kerning', 15996 keypoints: 'keyPoints', 15997 keysplines: 'keySplines', 15998 keytimes: 'keyTimes', 15999 lengthadjust: 'lengthAdjust', 16000 letterspacing: 'letterSpacing', 16001 'letter-spacing': 'letterSpacing', 16002 lightingcolor: 'lightingColor', 16003 'lighting-color': 'lightingColor', 16004 limitingconeangle: 'limitingConeAngle', 16005 local: 'local', 16006 markerend: 'markerEnd', 16007 'marker-end': 'markerEnd', 16008 markerheight: 'markerHeight', 16009 markermid: 'markerMid', 16010 'marker-mid': 'markerMid', 16011 markerstart: 'markerStart', 16012 'marker-start': 'markerStart', 16013 markerunits: 'markerUnits', 16014 markerwidth: 'markerWidth', 16015 mask: 'mask', 16016 maskcontentunits: 'maskContentUnits', 16017 maskunits: 'maskUnits', 16018 mathematical: 'mathematical', 16019 mode: 'mode', 16020 numoctaves: 'numOctaves', 16021 offset: 'offset', 16022 opacity: 'opacity', 16023 operator: 'operator', 16024 order: 'order', 16025 orient: 'orient', 16026 orientation: 'orientation', 16027 origin: 'origin', 16028 overflow: 'overflow', 16029 overlineposition: 'overlinePosition', 16030 'overline-position': 'overlinePosition', 16031 overlinethickness: 'overlineThickness', 16032 'overline-thickness': 'overlineThickness', 16033 paintorder: 'paintOrder', 16034 'paint-order': 'paintOrder', 16035 panose1: 'panose1', 16036 'panose-1': 'panose1', 16037 pathlength: 'pathLength', 16038 patterncontentunits: 'patternContentUnits', 16039 patterntransform: 'patternTransform', 16040 patternunits: 'patternUnits', 16041 pointerevents: 'pointerEvents', 16042 'pointer-events': 'pointerEvents', 16043 points: 'points', 16044 pointsatx: 'pointsAtX', 16045 pointsaty: 'pointsAtY', 16046 pointsatz: 'pointsAtZ', 16047 prefix: 'prefix', 16048 preservealpha: 'preserveAlpha', 16049 preserveaspectratio: 'preserveAspectRatio', 16050 primitiveunits: 'primitiveUnits', 16051 property: 'property', 16052 r: 'r', 16053 radius: 'radius', 16054 refx: 'refX', 16055 refy: 'refY', 16056 renderingintent: 'renderingIntent', 16057 'rendering-intent': 'renderingIntent', 16058 repeatcount: 'repeatCount', 16059 repeatdur: 'repeatDur', 16060 requiredextensions: 'requiredExtensions', 16061 requiredfeatures: 'requiredFeatures', 16062 resource: 'resource', 16063 restart: 'restart', 16064 result: 'result', 16065 results: 'results', 16066 rotate: 'rotate', 16067 rx: 'rx', 16068 ry: 'ry', 16069 scale: 'scale', 16070 security: 'security', 16071 seed: 'seed', 16072 shaperendering: 'shapeRendering', 16073 'shape-rendering': 'shapeRendering', 16074 slope: 'slope', 16075 spacing: 'spacing', 16076 specularconstant: 'specularConstant', 16077 specularexponent: 'specularExponent', 16078 speed: 'speed', 16079 spreadmethod: 'spreadMethod', 16080 startoffset: 'startOffset', 16081 stddeviation: 'stdDeviation', 16082 stemh: 'stemh', 16083 stemv: 'stemv', 16084 stitchtiles: 'stitchTiles', 16085 stopcolor: 'stopColor', 16086 'stop-color': 'stopColor', 16087 stopopacity: 'stopOpacity', 16088 'stop-opacity': 'stopOpacity', 16089 strikethroughposition: 'strikethroughPosition', 16090 'strikethrough-position': 'strikethroughPosition', 16091 strikethroughthickness: 'strikethroughThickness', 16092 'strikethrough-thickness': 'strikethroughThickness', 16093 string: 'string', 16094 stroke: 'stroke', 16095 strokedasharray: 'strokeDasharray', 16096 'stroke-dasharray': 'strokeDasharray', 16097 strokedashoffset: 'strokeDashoffset', 16098 'stroke-dashoffset': 'strokeDashoffset', 16099 strokelinecap: 'strokeLinecap', 16100 'stroke-linecap': 'strokeLinecap', 16101 strokelinejoin: 'strokeLinejoin', 16102 'stroke-linejoin': 'strokeLinejoin', 16103 strokemiterlimit: 'strokeMiterlimit', 16104 'stroke-miterlimit': 'strokeMiterlimit', 16105 strokewidth: 'strokeWidth', 16106 'stroke-width': 'strokeWidth', 16107 strokeopacity: 'strokeOpacity', 16108 'stroke-opacity': 'strokeOpacity', 16109 suppresscontenteditablewarning: 'suppressContentEditableWarning', 16110 suppresshydrationwarning: 'suppressHydrationWarning', 16111 surfacescale: 'surfaceScale', 16112 systemlanguage: 'systemLanguage', 16113 tablevalues: 'tableValues', 16114 targetx: 'targetX', 16115 targety: 'targetY', 16116 textanchor: 'textAnchor', 16117 'text-anchor': 'textAnchor', 16118 textdecoration: 'textDecoration', 16119 'text-decoration': 'textDecoration', 16120 textlength: 'textLength', 16121 textrendering: 'textRendering', 16122 'text-rendering': 'textRendering', 16123 to: 'to', 16124 transform: 'transform', 16125 'typeof': 'typeof', 16126 u1: 'u1', 16127 u2: 'u2', 16128 underlineposition: 'underlinePosition', 16129 'underline-position': 'underlinePosition', 16130 underlinethickness: 'underlineThickness', 16131 'underline-thickness': 'underlineThickness', 16132 unicode: 'unicode', 16133 unicodebidi: 'unicodeBidi', 16134 'unicode-bidi': 'unicodeBidi', 16135 unicoderange: 'unicodeRange', 16136 'unicode-range': 'unicodeRange', 16137 unitsperem: 'unitsPerEm', 16138 'units-per-em': 'unitsPerEm', 16139 unselectable: 'unselectable', 16140 valphabetic: 'vAlphabetic', 16141 'v-alphabetic': 'vAlphabetic', 16142 values: 'values', 16143 vectoreffect: 'vectorEffect', 16144 'vector-effect': 'vectorEffect', 16145 version: 'version', 16146 vertadvy: 'vertAdvY', 16147 'vert-adv-y': 'vertAdvY', 16148 vertoriginx: 'vertOriginX', 16149 'vert-origin-x': 'vertOriginX', 16150 vertoriginy: 'vertOriginY', 16151 'vert-origin-y': 'vertOriginY', 16152 vhanging: 'vHanging', 16153 'v-hanging': 'vHanging', 16154 videographic: 'vIdeographic', 16155 'v-ideographic': 'vIdeographic', 16156 viewbox: 'viewBox', 16157 viewtarget: 'viewTarget', 16158 visibility: 'visibility', 16159 vmathematical: 'vMathematical', 16160 'v-mathematical': 'vMathematical', 16161 vocab: 'vocab', 16162 widths: 'widths', 16163 wordspacing: 'wordSpacing', 16164 'word-spacing': 'wordSpacing', 16165 writingmode: 'writingMode', 16166 'writing-mode': 'writingMode', 16167 x1: 'x1', 16168 x2: 'x2', 16169 x: 'x', 16170 xchannelselector: 'xChannelSelector', 16171 xheight: 'xHeight', 16172 'x-height': 'xHeight', 16173 xlinkactuate: 'xlinkActuate', 16174 'xlink:actuate': 'xlinkActuate', 16175 xlinkarcrole: 'xlinkArcrole', 16176 'xlink:arcrole': 'xlinkArcrole', 16177 xlinkhref: 'xlinkHref', 16178 'xlink:href': 'xlinkHref', 16179 xlinkrole: 'xlinkRole', 16180 'xlink:role': 'xlinkRole', 16181 xlinkshow: 'xlinkShow', 16182 'xlink:show': 'xlinkShow', 16183 xlinktitle: 'xlinkTitle', 16184 'xlink:title': 'xlinkTitle', 16185 xlinktype: 'xlinkType', 16186 'xlink:type': 'xlinkType', 16187 xmlbase: 'xmlBase', 16188 'xml:base': 'xmlBase', 16189 xmllang: 'xmlLang', 16190 'xml:lang': 'xmlLang', 16191 xmlns: 'xmlns', 16192 'xml:space': 'xmlSpace', 16193 xmlnsxlink: 'xmlnsXlink', 16194 'xmlns:xlink': 'xmlnsXlink', 16195 xmlspace: 'xmlSpace', 16196 y1: 'y1', 16197 y2: 'y2', 16198 y: 'y', 16199 ychannelselector: 'yChannelSelector', 16200 z: 'z', 16201 zoomandpan: 'zoomAndPan' 16202 }; 16203 16204 function getStackAddendum$2() { 16205 var stack = ReactDebugCurrentFrame.getStackAddendum(); 16206 return stack != null ? stack : ''; 16207 } 16208 16209 { 16210 var warnedProperties$1 = {}; 16211 var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 16212 var EVENT_NAME_REGEX = /^on./; 16213 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 16214 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 16215 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 16216 16217 var validateProperty$1 = function (tagName, name, value, canUseEventSystem) { 16218 if (hasOwnProperty$1.call(warnedProperties$1, name) && warnedProperties$1[name]) { 16219 return true; 16220 } 16221 16222 var lowerCasedName = name.toLowerCase(); 16223 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 16224 warning(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.'); 16225 warnedProperties$1[name] = true; 16226 return true; 16227 } 16228 16229 // We can't rely on the event system being injected on the server. 16230 if (canUseEventSystem) { 16231 if (registrationNameModules.hasOwnProperty(name)) { 16232 return true; 16233 } 16234 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 16235 if (registrationName != null) { 16236 warning(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2()); 16237 warnedProperties$1[name] = true; 16238 return true; 16239 } 16240 if (EVENT_NAME_REGEX.test(name)) { 16241 warning(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$2()); 16242 warnedProperties$1[name] = true; 16243 return true; 16244 } 16245 } else if (EVENT_NAME_REGEX.test(name)) { 16246 // If no event plugins have been injected, we are in a server environment. 16247 // So we can't tell if the event name is correct for sure, but we can filter 16248 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 16249 if (INVALID_EVENT_NAME_REGEX.test(name)) { 16250 warning(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.%s', name, getStackAddendum$2()); 16251 } 16252 warnedProperties$1[name] = true; 16253 return true; 16254 } 16255 16256 // Let the ARIA attribute hook validate ARIA attributes 16257 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 16258 return true; 16259 } 16260 16261 if (lowerCasedName === 'innerhtml') { 16262 warning(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 16263 warnedProperties$1[name] = true; 16264 return true; 16265 } 16266 16267 if (lowerCasedName === 'aria') { 16268 warning(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 16269 warnedProperties$1[name] = true; 16270 return true; 16271 } 16272 16273 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 16274 warning(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.%s', typeof value, getStackAddendum$2()); 16275 warnedProperties$1[name] = true; 16276 return true; 16277 } 16278 16279 if (typeof value === 'number' && isNaN(value)) { 16280 warning(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.%s', name, getStackAddendum$2()); 16281 warnedProperties$1[name] = true; 16282 return true; 16283 } 16284 16285 var isReserved = isReservedProp(name); 16286 16287 // Known attributes should match the casing specified in the property config. 16288 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 16289 var standardName = possibleStandardNames[lowerCasedName]; 16290 if (standardName !== name) { 16291 warning(false, 'Invalid DOM property `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum$2()); 16292 warnedProperties$1[name] = true; 16293 return true; 16294 } 16295 } else if (!isReserved && name !== lowerCasedName) { 16296 // Unknown attributes should have lowercase casing since that's how they 16297 // will be cased anyway with server rendering. 16298 warning(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.%s', name, lowerCasedName, getStackAddendum$2()); 16299 warnedProperties$1[name] = true; 16300 return true; 16301 } 16302 16303 if (typeof value === 'boolean' && !shouldAttributeAcceptBooleanValue(name)) { 16304 if (value) { 16305 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.%s', value, name, name, value, name, getStackAddendum$2()); 16306 } else { 16307 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', value, name, name, value, name, name, name, getStackAddendum$2()); 16308 } 16309 warnedProperties$1[name] = true; 16310 return true; 16311 } 16312 16313 // Now that we've validated casing, do not validate 16314 // data types for reserved props 16315 if (isReserved) { 16316 return true; 16317 } 16318 16319 // Warn when a known attribute is a bad type 16320 if (!shouldSetAttribute(name, value)) { 16321 warnedProperties$1[name] = true; 16322 return false; 16323 } 16324 16325 return true; 16326 }; 16327 } 16328 16329 var warnUnknownProperties = function (type, props, canUseEventSystem) { 16330 var unknownProps = []; 16331 for (var key in props) { 16332 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem); 16333 if (!isValid) { 16334 unknownProps.push(key); 16335 } 16336 } 16337 16338 var unknownPropString = unknownProps.map(function (prop) { 16339 return '`' + prop + '`'; 16340 }).join(', '); 16341 if (unknownProps.length === 1) { 16342 warning(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2()); 16343 } else if (unknownProps.length > 1) { 16344 warning(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2()); 16345 } 16346 }; 16347 16348 function validateProperties$2(type, props, canUseEventSystem) { 16349 if (isCustomComponent(type, props)) { 16350 return; 16351 } 16352 warnUnknownProperties(type, props, canUseEventSystem); 16353 } 16354 16355 // TODO: direct imports like some-package/src/* are bad. Fix me. 16356 var getCurrentFiberOwnerName$1 = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 16357 var getCurrentFiberStackAddendum$2 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 16358 16359 var didWarnInvalidHydration = false; 16360 var didWarnShadyDOM = false; 16361 16362 var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 16363 var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 16364 var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 16365 var AUTOFOCUS = 'autoFocus'; 16366 var CHILDREN = 'children'; 16367 var STYLE = 'style'; 16368 var HTML = '__html'; 16369 16370 var HTML_NAMESPACE = Namespaces.html; 16371 16372 16373 var getStack = emptyFunction.thatReturns(''); 16374 16375 { 16376 getStack = getCurrentFiberStackAddendum$2; 16377 16378 var warnedUnknownTags = { 16379 // Chrome is the only major browser not shipping <time>. But as of July 16380 // 2017 it intends to ship it due to widespread usage. We intentionally 16381 // *don't* warn for <time> even if it's unrecognized by Chrome because 16382 // it soon will be, and many apps have been using it anyway. 16383 time: true, 16384 // There are working polyfills for <dialog>. Let people use it. 16385 dialog: true 16386 }; 16387 16388 var validatePropertiesInDevelopment = function (type, props) { 16389 validateProperties(type, props); 16390 validateProperties$1(type, props); 16391 validateProperties$2(type, props, /* canUseEventSystem */true); 16392 }; 16393 16394 // HTML parsing normalizes CR and CRLF to LF. 16395 // It also can turn \u0000 into \uFFFD inside attributes. 16396 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 16397 // If we have a mismatch, it might be caused by that. 16398 // We will still patch up in this case but not fire the warning. 16399 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 16400 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 16401 16402 var normalizeMarkupForTextOrAttribute = function (markup) { 16403 var markupString = typeof markup === 'string' ? markup : '' + markup; 16404 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 16405 }; 16406 16407 var warnForTextDifference = function (serverText, clientText) { 16408 if (didWarnInvalidHydration) { 16409 return; 16410 } 16411 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 16412 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 16413 if (normalizedServerText === normalizedClientText) { 16414 return; 16415 } 16416 didWarnInvalidHydration = true; 16417 warning(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 16418 }; 16419 16420 var warnForPropDifference = function (propName, serverValue, clientValue) { 16421 if (didWarnInvalidHydration) { 16422 return; 16423 } 16424 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 16425 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 16426 if (normalizedServerValue === normalizedClientValue) { 16427 return; 16428 } 16429 didWarnInvalidHydration = true; 16430 warning(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 16431 }; 16432 16433 var warnForExtraAttributes = function (attributeNames) { 16434 if (didWarnInvalidHydration) { 16435 return; 16436 } 16437 didWarnInvalidHydration = true; 16438 var names = []; 16439 attributeNames.forEach(function (name) { 16440 names.push(name); 16441 }); 16442 warning(false, 'Extra attributes from the server: %s', names); 16443 }; 16444 16445 var warnForInvalidEventListener = function (registrationName, listener) { 16446 if (listener === false) { 16447 warning(false, 'Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', registrationName, registrationName, registrationName, getCurrentFiberStackAddendum$2()); 16448 } else { 16449 warning(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.%s', registrationName, typeof listener, getCurrentFiberStackAddendum$2()); 16450 } 16451 }; 16452 16453 // Parse the HTML and read it back to normalize the HTML string so that it 16454 // can be used for comparison. 16455 var normalizeHTML = function (parent, html) { 16456 // We could have created a separate document here to avoid 16457 // re-initializing custom elements if they exist. But this breaks 16458 // how <noscript> is being handled. So we use the same document. 16459 // See the discussion in https://github.com/facebook/react/pull/11157. 16460 var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 16461 testElement.innerHTML = html; 16462 return testElement.innerHTML; 16463 }; 16464 } 16465 16466 function ensureListeningTo(rootContainerElement, registrationName) { 16467 var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE; 16468 var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument; 16469 listenTo(registrationName, doc); 16470 } 16471 16472 function getOwnerDocumentFromRootContainer(rootContainerElement) { 16473 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 16474 } 16475 16476 // There are so many media events, it makes sense to just 16477 // maintain a list rather than create a `trapBubbledEvent` for each 16478 var mediaEvents = { 16479 topAbort: 'abort', 16480 topCanPlay: 'canplay', 16481 topCanPlayThrough: 'canplaythrough', 16482 topDurationChange: 'durationchange', 16483 topEmptied: 'emptied', 16484 topEncrypted: 'encrypted', 16485 topEnded: 'ended', 16486 topError: 'error', 16487 topLoadedData: 'loadeddata', 16488 topLoadedMetadata: 'loadedmetadata', 16489 topLoadStart: 'loadstart', 16490 topPause: 'pause', 16491 topPlay: 'play', 16492 topPlaying: 'playing', 16493 topProgress: 'progress', 16494 topRateChange: 'ratechange', 16495 topSeeked: 'seeked', 16496 topSeeking: 'seeking', 16497 topStalled: 'stalled', 16498 topSuspend: 'suspend', 16499 topTimeUpdate: 'timeupdate', 16500 topVolumeChange: 'volumechange', 16501 topWaiting: 'waiting' 16502 }; 16503 16504 function trapClickOnNonInteractiveElement(node) { 16505 // Mobile Safari does not fire properly bubble click events on 16506 // non-interactive elements, which means delegated click listeners do not 16507 // fire. The workaround for this bug involves attaching an empty click 16508 // listener on the target node. 16509 // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 16510 // Just set it using the onclick property so that we don't have to manage any 16511 // bookkeeping for it. Not sure if we need to clear it when the listener is 16512 // removed. 16513 // TODO: Only do this for the relevant Safaris maybe? 16514 node.onclick = emptyFunction; 16515 } 16516 16517 function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 16518 for (var propKey in nextProps) { 16519 if (!nextProps.hasOwnProperty(propKey)) { 16520 continue; 16521 } 16522 var nextProp = nextProps[propKey]; 16523 if (propKey === STYLE) { 16524 { 16525 if (nextProp) { 16526 // Freeze the next style object so that we can assume it won't be 16527 // mutated. We have already warned for this in the past. 16528 Object.freeze(nextProp); 16529 } 16530 } 16531 // Relies on `updateStylesByID` not mutating `styleUpdates`. 16532 setValueForStyles(domElement, nextProp, getStack); 16533 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 16534 var nextHtml = nextProp ? nextProp[HTML] : undefined; 16535 if (nextHtml != null) { 16536 setInnerHTML(domElement, nextHtml); 16537 } 16538 } else if (propKey === CHILDREN) { 16539 if (typeof nextProp === 'string') { 16540 // Avoid setting initial textContent when the text is empty. In IE11 setting 16541 // textContent on a <textarea> will cause the placeholder to not 16542 // show within the <textarea> until it has been focused and blurred again. 16543 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 16544 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 16545 if (canSetTextContent) { 16546 setTextContent(domElement, nextProp); 16547 } 16548 } else if (typeof nextProp === 'number') { 16549 setTextContent(domElement, '' + nextProp); 16550 } 16551 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 16552 // Noop 16553 } else if (propKey === AUTOFOCUS) { 16554 // We polyfill it separately on the client during commit. 16555 // We blacklist it here rather than in the property list because we emit it in SSR. 16556 } else if (registrationNameModules.hasOwnProperty(propKey)) { 16557 if (nextProp != null) { 16558 if (true && typeof nextProp !== 'function') { 16559 warnForInvalidEventListener(propKey, nextProp); 16560 } 16561 ensureListeningTo(rootContainerElement, propKey); 16562 } 16563 } else if (isCustomComponentTag) { 16564 setValueForAttribute(domElement, propKey, nextProp); 16565 } else if (nextProp != null) { 16566 // If we're updating to null or undefined, we should remove the property 16567 // from the DOM node instead of inadvertently setting to a string. This 16568 // brings us in line with the same behavior we have on initial render. 16569 setValueForProperty(domElement, propKey, nextProp); 16570 } 16571 } 16572 } 16573 16574 function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 16575 // TODO: Handle wasCustomComponentTag 16576 for (var i = 0; i < updatePayload.length; i += 2) { 16577 var propKey = updatePayload[i]; 16578 var propValue = updatePayload[i + 1]; 16579 if (propKey === STYLE) { 16580 setValueForStyles(domElement, propValue, getStack); 16581 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 16582 setInnerHTML(domElement, propValue); 16583 } else if (propKey === CHILDREN) { 16584 setTextContent(domElement, propValue); 16585 } else if (isCustomComponentTag) { 16586 if (propValue != null) { 16587 setValueForAttribute(domElement, propKey, propValue); 16588 } else { 16589 deleteValueForAttribute(domElement, propKey); 16590 } 16591 } else if (propValue != null) { 16592 setValueForProperty(domElement, propKey, propValue); 16593 } else { 16594 // If we're updating to null or undefined, we should remove the property 16595 // from the DOM node instead of inadvertently setting to a string. This 16596 // brings us in line with the same behavior we have on initial render. 16597 deleteValueForProperty(domElement, propKey); 16598 } 16599 } 16600 } 16601 16602 function createElement$1(type, props, rootContainerElement, parentNamespace) { 16603 // We create tags in the namespace of their parent container, except HTML 16604 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 16605 var domElement; 16606 var namespaceURI = parentNamespace; 16607 if (namespaceURI === HTML_NAMESPACE) { 16608 namespaceURI = getIntrinsicNamespace(type); 16609 } 16610 if (namespaceURI === HTML_NAMESPACE) { 16611 { 16612 var isCustomComponentTag = isCustomComponent(type, props); 16613 // Should this check be gated by parent namespace? Not sure we want to 16614 // allow <SVG> or <mATH>. 16615 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type); 16616 } 16617 16618 if (type === 'script') { 16619 // Create the script via .innerHTML so its "parser-inserted" flag is 16620 // set to true and it does not execute 16621 var div = ownerDocument.createElement('div'); 16622 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 16623 // This is guaranteed to yield a script element. 16624 var firstChild = div.firstChild; 16625 domElement = div.removeChild(firstChild); 16626 } else if (typeof props.is === 'string') { 16627 // $FlowIssue `createElement` should be updated for Web Components 16628 domElement = ownerDocument.createElement(type, { is: props.is }); 16629 } else { 16630 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 16631 // See discussion in https://github.com/facebook/react/pull/6896 16632 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 16633 domElement = ownerDocument.createElement(type); 16634 } 16635 } else { 16636 domElement = ownerDocument.createElementNS(namespaceURI, type); 16637 } 16638 16639 { 16640 if (namespaceURI === HTML_NAMESPACE) { 16641 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 16642 warnedUnknownTags[type] = true; 16643 warning(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); 16644 } 16645 } 16646 } 16647 16648 return domElement; 16649 } 16650 16651 function createTextNode$1(text, rootContainerElement) { 16652 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 16653 } 16654 16655 function setInitialProperties$1(domElement, tag, rawProps, rootContainerElement) { 16656 var isCustomComponentTag = isCustomComponent(tag, rawProps); 16657 { 16658 validatePropertiesInDevelopment(tag, rawProps); 16659 if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { 16660 warning(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$1() || 'A component'); 16661 didWarnShadyDOM = true; 16662 } 16663 } 16664 16665 // TODO: Make sure that we check isMounted before firing any of these events. 16666 var props; 16667 switch (tag) { 16668 case 'iframe': 16669 case 'object': 16670 trapBubbledEvent('topLoad', 'load', domElement); 16671 props = rawProps; 16672 break; 16673 case 'video': 16674 case 'audio': 16675 // Create listener for each media event 16676 for (var event in mediaEvents) { 16677 if (mediaEvents.hasOwnProperty(event)) { 16678 trapBubbledEvent(event, mediaEvents[event], domElement); 16679 } 16680 } 16681 props = rawProps; 16682 break; 16683 case 'source': 16684 trapBubbledEvent('topError', 'error', domElement); 16685 props = rawProps; 16686 break; 16687 case 'img': 16688 case 'image': 16689 trapBubbledEvent('topError', 'error', domElement); 16690 trapBubbledEvent('topLoad', 'load', domElement); 16691 props = rawProps; 16692 break; 16693 case 'form': 16694 trapBubbledEvent('topReset', 'reset', domElement); 16695 trapBubbledEvent('topSubmit', 'submit', domElement); 16696 props = rawProps; 16697 break; 16698 case 'details': 16699 trapBubbledEvent('topToggle', 'toggle', domElement); 16700 props = rawProps; 16701 break; 16702 case 'input': 16703 initWrapperState(domElement, rawProps); 16704 props = getHostProps(domElement, rawProps); 16705 trapBubbledEvent('topInvalid', 'invalid', domElement); 16706 // For controlled components we always need to ensure we're listening 16707 // to onChange. Even if there is no listener. 16708 ensureListeningTo(rootContainerElement, 'onChange'); 16709 break; 16710 case 'option': 16711 validateProps(domElement, rawProps); 16712 props = getHostProps$1(domElement, rawProps); 16713 break; 16714 case 'select': 16715 initWrapperState$1(domElement, rawProps); 16716 props = getHostProps$2(domElement, rawProps); 16717 trapBubbledEvent('topInvalid', 'invalid', domElement); 16718 // For controlled components we always need to ensure we're listening 16719 // to onChange. Even if there is no listener. 16720 ensureListeningTo(rootContainerElement, 'onChange'); 16721 break; 16722 case 'textarea': 16723 initWrapperState$2(domElement, rawProps); 16724 props = getHostProps$3(domElement, rawProps); 16725 trapBubbledEvent('topInvalid', 'invalid', domElement); 16726 // For controlled components we always need to ensure we're listening 16727 // to onChange. Even if there is no listener. 16728 ensureListeningTo(rootContainerElement, 'onChange'); 16729 break; 16730 default: 16731 props = rawProps; 16732 } 16733 16734 assertValidProps(tag, props, getStack); 16735 16736 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 16737 16738 switch (tag) { 16739 case 'input': 16740 // TODO: Make sure we check if this is still unmounted or do any clean 16741 // up necessary since we never stop tracking anymore. 16742 track(domElement); 16743 postMountWrapper(domElement, rawProps); 16744 break; 16745 case 'textarea': 16746 // TODO: Make sure we check if this is still unmounted or do any clean 16747 // up necessary since we never stop tracking anymore. 16748 track(domElement); 16749 postMountWrapper$3(domElement, rawProps); 16750 break; 16751 case 'option': 16752 postMountWrapper$1(domElement, rawProps); 16753 break; 16754 case 'select': 16755 postMountWrapper$2(domElement, rawProps); 16756 break; 16757 default: 16758 if (typeof props.onClick === 'function') { 16759 // TODO: This cast may not be sound for SVG, MathML or custom elements. 16760 trapClickOnNonInteractiveElement(domElement); 16761 } 16762 break; 16763 } 16764 } 16765 16766 // Calculate the diff between the two objects. 16767 function diffProperties$1(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 16768 { 16769 validatePropertiesInDevelopment(tag, nextRawProps); 16770 } 16771 16772 var updatePayload = null; 16773 16774 var lastProps; 16775 var nextProps; 16776 switch (tag) { 16777 case 'input': 16778 lastProps = getHostProps(domElement, lastRawProps); 16779 nextProps = getHostProps(domElement, nextRawProps); 16780 updatePayload = []; 16781 break; 16782 case 'option': 16783 lastProps = getHostProps$1(domElement, lastRawProps); 16784 nextProps = getHostProps$1(domElement, nextRawProps); 16785 updatePayload = []; 16786 break; 16787 case 'select': 16788 lastProps = getHostProps$2(domElement, lastRawProps); 16789 nextProps = getHostProps$2(domElement, nextRawProps); 16790 updatePayload = []; 16791 break; 16792 case 'textarea': 16793 lastProps = getHostProps$3(domElement, lastRawProps); 16794 nextProps = getHostProps$3(domElement, nextRawProps); 16795 updatePayload = []; 16796 break; 16797 default: 16798 lastProps = lastRawProps; 16799 nextProps = nextRawProps; 16800 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 16801 // TODO: This cast may not be sound for SVG, MathML or custom elements. 16802 trapClickOnNonInteractiveElement(domElement); 16803 } 16804 break; 16805 } 16806 16807 assertValidProps(tag, nextProps, getStack); 16808 16809 var propKey; 16810 var styleName; 16811 var styleUpdates = null; 16812 for (propKey in lastProps) { 16813 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 16814 continue; 16815 } 16816 if (propKey === STYLE) { 16817 var lastStyle = lastProps[propKey]; 16818 for (styleName in lastStyle) { 16819 if (lastStyle.hasOwnProperty(styleName)) { 16820 if (!styleUpdates) { 16821 styleUpdates = {}; 16822 } 16823 styleUpdates[styleName] = ''; 16824 } 16825 } 16826 } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) { 16827 // Noop. This is handled by the clear text mechanism. 16828 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 16829 // Noop 16830 } else if (propKey === AUTOFOCUS) { 16831 // Noop. It doesn't work on updates anyway. 16832 } else if (registrationNameModules.hasOwnProperty(propKey)) { 16833 // This is a special case. If any listener updates we need to ensure 16834 // that the "current" fiber pointer gets updated so we need a commit 16835 // to update this element. 16836 if (!updatePayload) { 16837 updatePayload = []; 16838 } 16839 } else { 16840 // For all other deleted properties we add it to the queue. We use 16841 // the whitelist in the commit phase instead. 16842 (updatePayload = updatePayload || []).push(propKey, null); 16843 } 16844 } 16845 for (propKey in nextProps) { 16846 var nextProp = nextProps[propKey]; 16847 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 16848 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 16849 continue; 16850 } 16851 if (propKey === STYLE) { 16852 { 16853 if (nextProp) { 16854 // Freeze the next style object so that we can assume it won't be 16855 // mutated. We have already warned for this in the past. 16856 Object.freeze(nextProp); 16857 } 16858 } 16859 if (lastProp) { 16860 // Unset styles on `lastProp` but not on `nextProp`. 16861 for (styleName in lastProp) { 16862 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 16863 if (!styleUpdates) { 16864 styleUpdates = {}; 16865 } 16866 styleUpdates[styleName] = ''; 16867 } 16868 } 16869 // Update styles that changed since `lastProp`. 16870 for (styleName in nextProp) { 16871 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 16872 if (!styleUpdates) { 16873 styleUpdates = {}; 16874 } 16875 styleUpdates[styleName] = nextProp[styleName]; 16876 } 16877 } 16878 } else { 16879 // Relies on `updateStylesByID` not mutating `styleUpdates`. 16880 if (!styleUpdates) { 16881 if (!updatePayload) { 16882 updatePayload = []; 16883 } 16884 updatePayload.push(propKey, styleUpdates); 16885 } 16886 styleUpdates = nextProp; 16887 } 16888 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 16889 var nextHtml = nextProp ? nextProp[HTML] : undefined; 16890 var lastHtml = lastProp ? lastProp[HTML] : undefined; 16891 if (nextHtml != null) { 16892 if (lastHtml !== nextHtml) { 16893 (updatePayload = updatePayload || []).push(propKey, '' + nextHtml); 16894 } 16895 } else { 16896 // TODO: It might be too late to clear this if we have children 16897 // inserted already. 16898 } 16899 } else if (propKey === CHILDREN) { 16900 if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { 16901 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 16902 } 16903 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 16904 // Noop 16905 } else if (registrationNameModules.hasOwnProperty(propKey)) { 16906 if (nextProp != null) { 16907 // We eagerly listen to this even though we haven't committed yet. 16908 if (true && typeof nextProp !== 'function') { 16909 warnForInvalidEventListener(propKey, nextProp); 16910 } 16911 ensureListeningTo(rootContainerElement, propKey); 16912 } 16913 if (!updatePayload && lastProp !== nextProp) { 16914 // This is a special case. If any listener updates we need to ensure 16915 // that the "current" props pointer gets updated so we need a commit 16916 // to update this element. 16917 updatePayload = []; 16918 } 16919 } else { 16920 // For any other property we always add it to the queue and then we 16921 // filter it out using the whitelist during the commit. 16922 (updatePayload = updatePayload || []).push(propKey, nextProp); 16923 } 16924 } 16925 if (styleUpdates) { 16926 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 16927 } 16928 return updatePayload; 16929 } 16930 16931 // Apply the diff. 16932 function updateProperties$1(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 16933 // Update checked *before* name. 16934 // In the middle of an update, it is possible to have multiple checked. 16935 // When a checked radio tries to change name, browser makes another radio's checked false. 16936 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 16937 updateChecked(domElement, nextRawProps); 16938 } 16939 16940 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 16941 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); 16942 // Apply the diff. 16943 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); 16944 16945 // TODO: Ensure that an update gets scheduled if any of the special props 16946 // changed. 16947 switch (tag) { 16948 case 'input': 16949 // Update the wrapper around inputs *after* updating props. This has to 16950 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 16951 // raise warnings and prevent the new value from being assigned. 16952 updateWrapper(domElement, nextRawProps); 16953 break; 16954 case 'textarea': 16955 updateWrapper$1(domElement, nextRawProps); 16956 break; 16957 case 'select': 16958 // <select> value update needs to occur after <option> children 16959 // reconciliation 16960 postUpdateWrapper(domElement, nextRawProps); 16961 break; 16962 } 16963 } 16964 16965 function diffHydratedProperties$1(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 16966 { 16967 var suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true; 16968 var isCustomComponentTag = isCustomComponent(tag, rawProps); 16969 validatePropertiesInDevelopment(tag, rawProps); 16970 if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { 16971 warning(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$1() || 'A component'); 16972 didWarnShadyDOM = true; 16973 } 16974 } 16975 16976 // TODO: Make sure that we check isMounted before firing any of these events. 16977 switch (tag) { 16978 case 'iframe': 16979 case 'object': 16980 trapBubbledEvent('topLoad', 'load', domElement); 16981 break; 16982 case 'video': 16983 case 'audio': 16984 // Create listener for each media event 16985 for (var event in mediaEvents) { 16986 if (mediaEvents.hasOwnProperty(event)) { 16987 trapBubbledEvent(event, mediaEvents[event], domElement); 16988 } 16989 } 16990 break; 16991 case 'source': 16992 trapBubbledEvent('topError', 'error', domElement); 16993 break; 16994 case 'img': 16995 case 'image': 16996 trapBubbledEvent('topError', 'error', domElement); 16997 trapBubbledEvent('topLoad', 'load', domElement); 16998 break; 16999 case 'form': 17000 trapBubbledEvent('topReset', 'reset', domElement); 17001 trapBubbledEvent('topSubmit', 'submit', domElement); 17002 break; 17003 case 'details': 17004 trapBubbledEvent('topToggle', 'toggle', domElement); 17005 break; 17006 case 'input': 17007 initWrapperState(domElement, rawProps); 17008 trapBubbledEvent('topInvalid', 'invalid', domElement); 17009 // For controlled components we always need to ensure we're listening 17010 // to onChange. Even if there is no listener. 17011 ensureListeningTo(rootContainerElement, 'onChange'); 17012 break; 17013 case 'option': 17014 validateProps(domElement, rawProps); 17015 break; 17016 case 'select': 17017 initWrapperState$1(domElement, rawProps); 17018 trapBubbledEvent('topInvalid', 'invalid', domElement); 17019 // For controlled components we always need to ensure we're listening 17020 // to onChange. Even if there is no listener. 17021 ensureListeningTo(rootContainerElement, 'onChange'); 17022 break; 17023 case 'textarea': 17024 initWrapperState$2(domElement, rawProps); 17025 trapBubbledEvent('topInvalid', 'invalid', domElement); 17026 // For controlled components we always need to ensure we're listening 17027 // to onChange. Even if there is no listener. 17028 ensureListeningTo(rootContainerElement, 'onChange'); 17029 break; 17030 } 17031 17032 assertValidProps(tag, rawProps, getStack); 17033 17034 { 17035 var extraAttributeNames = new Set(); 17036 var attributes = domElement.attributes; 17037 for (var i = 0; i < attributes.length; i++) { 17038 var name = attributes[i].name.toLowerCase(); 17039 switch (name) { 17040 // Built-in SSR attribute is whitelisted 17041 case 'data-reactroot': 17042 break; 17043 // Controlled attributes are not validated 17044 // TODO: Only ignore them on controlled tags. 17045 case 'value': 17046 break; 17047 case 'checked': 17048 break; 17049 case 'selected': 17050 break; 17051 default: 17052 // Intentionally use the original name. 17053 // See discussion in https://github.com/facebook/react/pull/10676. 17054 extraAttributeNames.add(attributes[i].name); 17055 } 17056 } 17057 } 17058 17059 var updatePayload = null; 17060 for (var propKey in rawProps) { 17061 if (!rawProps.hasOwnProperty(propKey)) { 17062 continue; 17063 } 17064 var nextProp = rawProps[propKey]; 17065 if (propKey === CHILDREN) { 17066 // For text content children we compare against textContent. This 17067 // might match additional HTML that is hidden when we read it using 17068 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 17069 // satisfies our requirement. Our requirement is not to produce perfect 17070 // HTML and attributes. Ideally we should preserve structure but it's 17071 // ok not to if the visible content is still enough to indicate what 17072 // even listeners these nodes might be wired up to. 17073 // TODO: Warn if there is more than a single textNode as a child. 17074 // TODO: Should we use domElement.firstChild.nodeValue to compare? 17075 if (typeof nextProp === 'string') { 17076 if (domElement.textContent !== nextProp) { 17077 if (true && !suppressHydrationWarning) { 17078 warnForTextDifference(domElement.textContent, nextProp); 17079 } 17080 updatePayload = [CHILDREN, nextProp]; 17081 } 17082 } else if (typeof nextProp === 'number') { 17083 if (domElement.textContent !== '' + nextProp) { 17084 if (true && !suppressHydrationWarning) { 17085 warnForTextDifference(domElement.textContent, nextProp); 17086 } 17087 updatePayload = [CHILDREN, '' + nextProp]; 17088 } 17089 } 17090 } else if (registrationNameModules.hasOwnProperty(propKey)) { 17091 if (nextProp != null) { 17092 if (true && typeof nextProp !== 'function') { 17093 warnForInvalidEventListener(propKey, nextProp); 17094 } 17095 ensureListeningTo(rootContainerElement, propKey); 17096 } 17097 } else { 17098 // Validate that the properties correspond to their expected values. 17099 var serverValue; 17100 var propertyInfo; 17101 if (suppressHydrationWarning) { 17102 // Don't bother comparing. We're ignoring all these warnings. 17103 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 || 17104 // Controlled attributes are not validated 17105 // TODO: Only ignore them on controlled tags. 17106 propKey === 'value' || propKey === 'checked' || propKey === 'selected') { 17107 // Noop 17108 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 17109 var rawHtml = nextProp ? nextProp[HTML] || '' : ''; 17110 var serverHTML = domElement.innerHTML; 17111 var expectedHTML = normalizeHTML(domElement, rawHtml); 17112 if (expectedHTML !== serverHTML) { 17113 warnForPropDifference(propKey, serverHTML, expectedHTML); 17114 } 17115 } else if (propKey === STYLE) { 17116 // $FlowFixMe - Should be inferred as not undefined. 17117 extraAttributeNames['delete'](propKey); 17118 var expectedStyle = createDangerousStringForStyles(nextProp); 17119 serverValue = domElement.getAttribute('style'); 17120 if (expectedStyle !== serverValue) { 17121 warnForPropDifference(propKey, serverValue, expectedStyle); 17122 } 17123 } else if (isCustomComponentTag) { 17124 // $FlowFixMe - Should be inferred as not undefined. 17125 extraAttributeNames['delete'](propKey.toLowerCase()); 17126 serverValue = getValueForAttribute(domElement, propKey, nextProp); 17127 17128 if (nextProp !== serverValue) { 17129 warnForPropDifference(propKey, serverValue, nextProp); 17130 } 17131 } else if (shouldSetAttribute(propKey, nextProp)) { 17132 if (propertyInfo = getPropertyInfo(propKey)) { 17133 // $FlowFixMe - Should be inferred as not undefined. 17134 extraAttributeNames['delete'](propertyInfo.attributeName); 17135 serverValue = getValueForProperty(domElement, propKey, nextProp); 17136 } else { 17137 var ownNamespace = parentNamespace; 17138 if (ownNamespace === HTML_NAMESPACE) { 17139 ownNamespace = getIntrinsicNamespace(tag); 17140 } 17141 if (ownNamespace === HTML_NAMESPACE) { 17142 // $FlowFixMe - Should be inferred as not undefined. 17143 extraAttributeNames['delete'](propKey.toLowerCase()); 17144 } else { 17145 // $FlowFixMe - Should be inferred as not undefined. 17146 extraAttributeNames['delete'](propKey); 17147 } 17148 serverValue = getValueForAttribute(domElement, propKey, nextProp); 17149 } 17150 17151 if (nextProp !== serverValue) { 17152 warnForPropDifference(propKey, serverValue, nextProp); 17153 } 17154 } 17155 } 17156 } 17157 17158 { 17159 // $FlowFixMe - Should be inferred as not undefined. 17160 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 17161 // $FlowFixMe - Should be inferred as not undefined. 17162 warnForExtraAttributes(extraAttributeNames); 17163 } 17164 } 17165 17166 switch (tag) { 17167 case 'input': 17168 // TODO: Make sure we check if this is still unmounted or do any clean 17169 // up necessary since we never stop tracking anymore. 17170 track(domElement); 17171 postMountWrapper(domElement, rawProps); 17172 break; 17173 case 'textarea': 17174 // TODO: Make sure we check if this is still unmounted or do any clean 17175 // up necessary since we never stop tracking anymore. 17176 track(domElement); 17177 postMountWrapper$3(domElement, rawProps); 17178 break; 17179 case 'select': 17180 case 'option': 17181 // For input and textarea we current always set the value property at 17182 // post mount to force it to diverge from attributes. However, for 17183 // option and select we don't quite do the same thing and select 17184 // is not resilient to the DOM state changing so we don't do that here. 17185 // TODO: Consider not doing this for input and textarea. 17186 break; 17187 default: 17188 if (typeof rawProps.onClick === 'function') { 17189 // TODO: This cast may not be sound for SVG, MathML or custom elements. 17190 trapClickOnNonInteractiveElement(domElement); 17191 } 17192 break; 17193 } 17194 17195 return updatePayload; 17196 } 17197 17198 function diffHydratedText$1(textNode, text) { 17199 var isDifferent = textNode.nodeValue !== text; 17200 return isDifferent; 17201 } 17202 17203 function warnForUnmatchedText$1(textNode, text) { 17204 { 17205 warnForTextDifference(textNode.nodeValue, text); 17206 } 17207 } 17208 17209 function warnForDeletedHydratableElement$1(parentNode, child) { 17210 { 17211 if (didWarnInvalidHydration) { 17212 return; 17213 } 17214 didWarnInvalidHydration = true; 17215 warning(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 17216 } 17217 } 17218 17219 function warnForDeletedHydratableText$1(parentNode, child) { 17220 { 17221 if (didWarnInvalidHydration) { 17222 return; 17223 } 17224 didWarnInvalidHydration = true; 17225 warning(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 17226 } 17227 } 17228 17229 function warnForInsertedHydratedElement$1(parentNode, tag, props) { 17230 { 17231 if (didWarnInvalidHydration) { 17232 return; 17233 } 17234 didWarnInvalidHydration = true; 17235 warning(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 17236 } 17237 } 17238 17239 function warnForInsertedHydratedText$1(parentNode, text) { 17240 { 17241 if (text === '') { 17242 // We expect to insert empty text nodes since they're not represented in 17243 // the HTML. 17244 // TODO: Remove this special case if we can just avoid inserting empty 17245 // text nodes. 17246 return; 17247 } 17248 if (didWarnInvalidHydration) { 17249 return; 17250 } 17251 didWarnInvalidHydration = true; 17252 warning(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 17253 } 17254 } 17255 17256 function restoreControlledState(domElement, tag, props) { 17257 switch (tag) { 17258 case 'input': 17259 restoreControlledState$1(domElement, props); 17260 return; 17261 case 'textarea': 17262 restoreControlledState$3(domElement, props); 17263 return; 17264 case 'select': 17265 restoreControlledState$2(domElement, props); 17266 return; 17267 } 17268 } 17269 17270 var ReactDOMFiberComponent = Object.freeze({ 17271 createElement: createElement$1, 17272 createTextNode: createTextNode$1, 17273 setInitialProperties: setInitialProperties$1, 17274 diffProperties: diffProperties$1, 17275 updateProperties: updateProperties$1, 17276 diffHydratedProperties: diffHydratedProperties$1, 17277 diffHydratedText: diffHydratedText$1, 17278 warnForUnmatchedText: warnForUnmatchedText$1, 17279 warnForDeletedHydratableElement: warnForDeletedHydratableElement$1, 17280 warnForDeletedHydratableText: warnForDeletedHydratableText$1, 17281 warnForInsertedHydratedElement: warnForInsertedHydratedElement$1, 17282 warnForInsertedHydratedText: warnForInsertedHydratedText$1, 17283 restoreControlledState: restoreControlledState 17284 }); 17285 17286 // TODO: direct imports like some-package/src/* are bad. Fix me. 17287 var getCurrentFiberStackAddendum$6 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 17288 17289 var validateDOMNesting = emptyFunction; 17290 17291 { 17292 // This validation code was written based on the HTML5 parsing spec: 17293 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 17294 // 17295 // Note: this does not catch all invalid nesting, nor does it try to (as it's 17296 // not clear what practical benefit doing so provides); instead, we warn only 17297 // for cases where the parser will give a parse tree differing from what React 17298 // intended. For example, <b><div></div></b> is invalid but we don't warn 17299 // because it still parses correctly; we do warn for other cases like nested 17300 // <p> tags where the beginning of the second element implicitly closes the 17301 // first, causing a confusing mess. 17302 17303 // https://html.spec.whatwg.org/multipage/syntax.html#special 17304 var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; 17305 17306 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 17307 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', 17308 17309 // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 17310 // TODO: Distinguish by namespace here -- for <title>, including it here 17311 // errs on the side of fewer warnings 17312 'foreignObject', 'desc', 'title']; 17313 17314 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 17315 var buttonScopeTags = inScopeTags.concat(['button']); 17316 17317 // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 17318 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 17319 17320 var emptyAncestorInfo = { 17321 current: null, 17322 17323 formTag: null, 17324 aTagInScope: null, 17325 buttonTagInScope: null, 17326 nobrTagInScope: null, 17327 pTagInButtonScope: null, 17328 17329 listItemTagAutoclosing: null, 17330 dlItemTagAutoclosing: null 17331 }; 17332 17333 var updatedAncestorInfo$1 = function (oldInfo, tag, instance) { 17334 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 17335 var info = { tag: tag, instance: instance }; 17336 17337 if (inScopeTags.indexOf(tag) !== -1) { 17338 ancestorInfo.aTagInScope = null; 17339 ancestorInfo.buttonTagInScope = null; 17340 ancestorInfo.nobrTagInScope = null; 17341 } 17342 if (buttonScopeTags.indexOf(tag) !== -1) { 17343 ancestorInfo.pTagInButtonScope = null; 17344 } 17345 17346 // See rules for 'li', 'dd', 'dt' start tags in 17347 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 17348 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 17349 ancestorInfo.listItemTagAutoclosing = null; 17350 ancestorInfo.dlItemTagAutoclosing = null; 17351 } 17352 17353 ancestorInfo.current = info; 17354 17355 if (tag === 'form') { 17356 ancestorInfo.formTag = info; 17357 } 17358 if (tag === 'a') { 17359 ancestorInfo.aTagInScope = info; 17360 } 17361 if (tag === 'button') { 17362 ancestorInfo.buttonTagInScope = info; 17363 } 17364 if (tag === 'nobr') { 17365 ancestorInfo.nobrTagInScope = info; 17366 } 17367 if (tag === 'p') { 17368 ancestorInfo.pTagInButtonScope = info; 17369 } 17370 if (tag === 'li') { 17371 ancestorInfo.listItemTagAutoclosing = info; 17372 } 17373 if (tag === 'dd' || tag === 'dt') { 17374 ancestorInfo.dlItemTagAutoclosing = info; 17375 } 17376 17377 return ancestorInfo; 17378 }; 17379 17380 /** 17381 * Returns whether 17382 */ 17383 var isTagValidWithParent = function (tag, parentTag) { 17384 // First, let's check if we're in an unusual parsing mode... 17385 switch (parentTag) { 17386 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 17387 case 'select': 17388 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 17389 case 'optgroup': 17390 return tag === 'option' || tag === '#text'; 17391 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 17392 // but 17393 case 'option': 17394 return tag === '#text'; 17395 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 17396 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 17397 // No special behavior since these rules fall back to "in body" mode for 17398 // all except special table nodes which cause bad parsing behavior anyway. 17399 17400 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 17401 case 'tr': 17402 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 17403 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 17404 case 'tbody': 17405 case 'thead': 17406 case 'tfoot': 17407 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 17408 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 17409 case 'colgroup': 17410 return tag === 'col' || tag === 'template'; 17411 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 17412 case 'table': 17413 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 17414 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 17415 case 'head': 17416 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 17417 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 17418 case 'html': 17419 return tag === 'head' || tag === 'body'; 17420 case '#document': 17421 return tag === 'html'; 17422 } 17423 17424 // Probably in the "in body" parsing mode, so we outlaw only tag combos 17425 // where the parsing rules cause implicit opens or closes to be added. 17426 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 17427 switch (tag) { 17428 case 'h1': 17429 case 'h2': 17430 case 'h3': 17431 case 'h4': 17432 case 'h5': 17433 case 'h6': 17434 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 17435 17436 case 'rp': 17437 case 'rt': 17438 return impliedEndTags.indexOf(parentTag) === -1; 17439 17440 case 'body': 17441 case 'caption': 17442 case 'col': 17443 case 'colgroup': 17444 case 'frame': 17445 case 'head': 17446 case 'html': 17447 case 'tbody': 17448 case 'td': 17449 case 'tfoot': 17450 case 'th': 17451 case 'thead': 17452 case 'tr': 17453 // These tags are only valid with a few parents that have special child 17454 // parsing rules -- if we're down here, then none of those matched and 17455 // so we allow it only if we don't know what the parent is, as all other 17456 // cases are invalid. 17457 return parentTag == null; 17458 } 17459 17460 return true; 17461 }; 17462 17463 /** 17464 * Returns whether 17465 */ 17466 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 17467 switch (tag) { 17468 case 'address': 17469 case 'article': 17470 case 'aside': 17471 case 'blockquote': 17472 case 'center': 17473 case 'details': 17474 case 'dialog': 17475 case 'dir': 17476 case 'div': 17477 case 'dl': 17478 case 'fieldset': 17479 case 'figcaption': 17480 case 'figure': 17481 case 'footer': 17482 case 'header': 17483 case 'hgroup': 17484 case 'main': 17485 case 'menu': 17486 case 'nav': 17487 case 'ol': 17488 case 'p': 17489 case 'section': 17490 case 'summary': 17491 case 'ul': 17492 case 'pre': 17493 case 'listing': 17494 case 'table': 17495 case 'hr': 17496 case 'xmp': 17497 case 'h1': 17498 case 'h2': 17499 case 'h3': 17500 case 'h4': 17501 case 'h5': 17502 case 'h6': 17503 return ancestorInfo.pTagInButtonScope; 17504 17505 case 'form': 17506 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 17507 17508 case 'li': 17509 return ancestorInfo.listItemTagAutoclosing; 17510 17511 case 'dd': 17512 case 'dt': 17513 return ancestorInfo.dlItemTagAutoclosing; 17514 17515 case 'button': 17516 return ancestorInfo.buttonTagInScope; 17517 17518 case 'a': 17519 // Spec says something about storing a list of markers, but it sounds 17520 // equivalent to this check. 17521 return ancestorInfo.aTagInScope; 17522 17523 case 'nobr': 17524 return ancestorInfo.nobrTagInScope; 17525 } 17526 17527 return null; 17528 }; 17529 17530 var didWarn = {}; 17531 17532 validateDOMNesting = function (childTag, childText, ancestorInfo) { 17533 ancestorInfo = ancestorInfo || emptyAncestorInfo; 17534 var parentInfo = ancestorInfo.current; 17535 var parentTag = parentInfo && parentInfo.tag; 17536 17537 if (childText != null) { 17538 warning(childTag == null, 'validateDOMNesting: when childText is passed, childTag should be null'); 17539 childTag = '#text'; 17540 } 17541 17542 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 17543 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 17544 var invalidParentOrAncestor = invalidParent || invalidAncestor; 17545 if (!invalidParentOrAncestor) { 17546 return; 17547 } 17548 17549 var ancestorTag = invalidParentOrAncestor.tag; 17550 var addendum = getCurrentFiberStackAddendum$6(); 17551 17552 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; 17553 if (didWarn[warnKey]) { 17554 return; 17555 } 17556 didWarn[warnKey] = true; 17557 17558 var tagDisplayName = childTag; 17559 var whitespaceInfo = ''; 17560 if (childTag === '#text') { 17561 if (/\S/.test(childText)) { 17562 tagDisplayName = 'Text nodes'; 17563 } else { 17564 tagDisplayName = 'Whitespace text nodes'; 17565 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 17566 } 17567 } else { 17568 tagDisplayName = '<' + childTag + '>'; 17569 } 17570 17571 if (invalidParent) { 17572 var info = ''; 17573 if (ancestorTag === 'table' && childTag === 'tr') { 17574 info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.'; 17575 } 17576 warning(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum); 17577 } else { 17578 warning(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum); 17579 } 17580 }; 17581 17582 // TODO: turn this into a named export 17583 validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo$1; 17584 17585 // For testing 17586 validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) { 17587 ancestorInfo = ancestorInfo || emptyAncestorInfo; 17588 var parentInfo = ancestorInfo.current; 17589 var parentTag = parentInfo && parentInfo.tag; 17590 return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo); 17591 }; 17592 } 17593 17594 var validateDOMNesting$1 = validateDOMNesting; 17595 17596 // TODO: direct imports like some-package/src/* are bad. Fix me. 17597 var createElement = createElement$1; 17598 var createTextNode = createTextNode$1; 17599 var setInitialProperties = setInitialProperties$1; 17600 var diffProperties = diffProperties$1; 17601 var updateProperties = updateProperties$1; 17602 var diffHydratedProperties = diffHydratedProperties$1; 17603 var diffHydratedText = diffHydratedText$1; 17604 var warnForUnmatchedText = warnForUnmatchedText$1; 17605 var warnForDeletedHydratableElement = warnForDeletedHydratableElement$1; 17606 var warnForDeletedHydratableText = warnForDeletedHydratableText$1; 17607 var warnForInsertedHydratedElement = warnForInsertedHydratedElement$1; 17608 var warnForInsertedHydratedText = warnForInsertedHydratedText$1; 17609 var updatedAncestorInfo = validateDOMNesting$1.updatedAncestorInfo; 17610 var precacheFiberNode = precacheFiberNode$1; 17611 var updateFiberProps = updateFiberProps$1; 17612 17613 17614 { 17615 var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 17616 if (typeof Map !== 'function' || Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 17617 warning(false, 'React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. http://fb.me/react-polyfills'); 17618 } 17619 } 17620 17621 injection$3.injectFiberControlledHostComponent(ReactDOMFiberComponent); 17622 17623 var eventsEnabled = null; 17624 var selectionInformation = null; 17625 17626 /** 17627 * True if the supplied DOM node is a valid node element. 17628 * 17629 * @param {?DOMElement} node The candidate DOM node. 17630 * @return {boolean} True if the DOM is a valid DOM node. 17631 * @internal 17632 */ 17633 function isValidContainer(node) { 17634 return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable ')); 17635 } 17636 17637 function getReactRootElementInContainer(container) { 17638 if (!container) { 17639 return null; 17640 } 17641 17642 if (container.nodeType === DOCUMENT_NODE) { 17643 return container.documentElement; 17644 } else { 17645 return container.firstChild; 17646 } 17647 } 17648 17649 function shouldHydrateDueToLegacyHeuristic(container) { 17650 var rootElement = getReactRootElementInContainer(container); 17651 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 17652 } 17653 17654 function shouldAutoFocusHostComponent(type, props) { 17655 switch (type) { 17656 case 'button': 17657 case 'input': 17658 case 'select': 17659 case 'textarea': 17660 return !!props.autoFocus; 17661 } 17662 return false; 17663 } 17664 17665 var DOMRenderer = reactReconciler({ 17666 getRootHostContext: function (rootContainerInstance) { 17667 var type = void 0; 17668 var namespace = void 0; 17669 var nodeType = rootContainerInstance.nodeType; 17670 switch (nodeType) { 17671 case DOCUMENT_NODE: 17672 case DOCUMENT_FRAGMENT_NODE: 17673 { 17674 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 17675 var root = rootContainerInstance.documentElement; 17676 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 17677 break; 17678 } 17679 default: 17680 { 17681 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 17682 var ownNamespace = container.namespaceURI || null; 17683 type = container.tagName; 17684 namespace = getChildNamespace(ownNamespace, type); 17685 break; 17686 } 17687 } 17688 { 17689 var validatedTag = type.toLowerCase(); 17690 var _ancestorInfo = updatedAncestorInfo(null, validatedTag, null); 17691 return { namespace: namespace, ancestorInfo: _ancestorInfo }; 17692 } 17693 return namespace; 17694 }, 17695 getChildHostContext: function (parentHostContext, type) { 17696 { 17697 var parentHostContextDev = parentHostContext; 17698 var _namespace = getChildNamespace(parentHostContextDev.namespace, type); 17699 var _ancestorInfo2 = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type, null); 17700 return { namespace: _namespace, ancestorInfo: _ancestorInfo2 }; 17701 } 17702 var parentNamespace = parentHostContext; 17703 return getChildNamespace(parentNamespace, type); 17704 }, 17705 getPublicInstance: function (instance) { 17706 return instance; 17707 }, 17708 prepareForCommit: function () { 17709 eventsEnabled = isEnabled(); 17710 selectionInformation = getSelectionInformation(); 17711 setEnabled(false); 17712 }, 17713 resetAfterCommit: function () { 17714 restoreSelection(selectionInformation); 17715 selectionInformation = null; 17716 setEnabled(eventsEnabled); 17717 eventsEnabled = null; 17718 }, 17719 createInstance: function (type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 17720 var parentNamespace = void 0; 17721 { 17722 // TODO: take namespace into account when validating. 17723 var hostContextDev = hostContext; 17724 validateDOMNesting$1(type, null, hostContextDev.ancestorInfo); 17725 if (typeof props.children === 'string' || typeof props.children === 'number') { 17726 var string = '' + props.children; 17727 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null); 17728 validateDOMNesting$1(null, string, ownAncestorInfo); 17729 } 17730 parentNamespace = hostContextDev.namespace; 17731 } 17732 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 17733 precacheFiberNode(internalInstanceHandle, domElement); 17734 updateFiberProps(domElement, props); 17735 return domElement; 17736 }, 17737 appendInitialChild: function (parentInstance, child) { 17738 parentInstance.appendChild(child); 17739 }, 17740 finalizeInitialChildren: function (domElement, type, props, rootContainerInstance) { 17741 setInitialProperties(domElement, type, props, rootContainerInstance); 17742 return shouldAutoFocusHostComponent(type, props); 17743 }, 17744 prepareUpdate: function (domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 17745 { 17746 var hostContextDev = hostContext; 17747 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 17748 var string = '' + newProps.children; 17749 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null); 17750 validateDOMNesting$1(null, string, ownAncestorInfo); 17751 } 17752 } 17753 return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance); 17754 }, 17755 shouldSetTextContent: function (type, props) { 17756 return type === 'textarea' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && typeof props.dangerouslySetInnerHTML.__html === 'string'; 17757 }, 17758 shouldDeprioritizeSubtree: function (type, props) { 17759 return !!props.hidden; 17760 }, 17761 createTextInstance: function (text, rootContainerInstance, hostContext, internalInstanceHandle) { 17762 { 17763 var hostContextDev = hostContext; 17764 validateDOMNesting$1(null, text, hostContextDev.ancestorInfo); 17765 } 17766 var textNode = createTextNode(text, rootContainerInstance); 17767 precacheFiberNode(internalInstanceHandle, textNode); 17768 return textNode; 17769 }, 17770 17771 17772 now: now, 17773 17774 mutation: { 17775 commitMount: function (domElement, type, newProps, internalInstanceHandle) { 17776 domElement.focus(); 17777 }, 17778 commitUpdate: function (domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 17779 // Update the props handle so that we know which props are the ones with 17780 // with current event handlers. 17781 updateFiberProps(domElement, newProps); 17782 // Apply the diff to the DOM node. 17783 updateProperties(domElement, updatePayload, type, oldProps, newProps); 17784 }, 17785 resetTextContent: function (domElement) { 17786 domElement.textContent = ''; 17787 }, 17788 commitTextUpdate: function (textInstance, oldText, newText) { 17789 textInstance.nodeValue = newText; 17790 }, 17791 appendChild: function (parentInstance, child) { 17792 parentInstance.appendChild(child); 17793 }, 17794 appendChildToContainer: function (container, child) { 17795 if (container.nodeType === COMMENT_NODE) { 17796 container.parentNode.insertBefore(child, container); 17797 } else { 17798 container.appendChild(child); 17799 } 17800 }, 17801 insertBefore: function (parentInstance, child, beforeChild) { 17802 parentInstance.insertBefore(child, beforeChild); 17803 }, 17804 insertInContainerBefore: function (container, child, beforeChild) { 17805 if (container.nodeType === COMMENT_NODE) { 17806 container.parentNode.insertBefore(child, beforeChild); 17807 } else { 17808 container.insertBefore(child, beforeChild); 17809 } 17810 }, 17811 removeChild: function (parentInstance, child) { 17812 parentInstance.removeChild(child); 17813 }, 17814 removeChildFromContainer: function (container, child) { 17815 if (container.nodeType === COMMENT_NODE) { 17816 container.parentNode.removeChild(child); 17817 } else { 17818 container.removeChild(child); 17819 } 17820 } 17821 }, 17822 17823 hydration: { 17824 canHydrateInstance: function (instance, type, props) { 17825 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 17826 return null; 17827 } 17828 // This has now been refined to an element node. 17829 return instance; 17830 }, 17831 canHydrateTextInstance: function (instance, text) { 17832 if (text === '' || instance.nodeType !== TEXT_NODE) { 17833 // Empty strings are not parsed by HTML so there won't be a correct match here. 17834 return null; 17835 } 17836 // This has now been refined to a text node. 17837 return instance; 17838 }, 17839 getNextHydratableSibling: function (instance) { 17840 var node = instance.nextSibling; 17841 // Skip non-hydratable nodes. 17842 while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) { 17843 node = node.nextSibling; 17844 } 17845 return node; 17846 }, 17847 getFirstHydratableChild: function (parentInstance) { 17848 var next = parentInstance.firstChild; 17849 // Skip non-hydratable nodes. 17850 while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) { 17851 next = next.nextSibling; 17852 } 17853 return next; 17854 }, 17855 hydrateInstance: function (instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 17856 precacheFiberNode(internalInstanceHandle, instance); 17857 // TODO: Possibly defer this until the commit phase where all the events 17858 // get attached. 17859 updateFiberProps(instance, props); 17860 var parentNamespace = void 0; 17861 { 17862 var hostContextDev = hostContext; 17863 parentNamespace = hostContextDev.namespace; 17864 } 17865 return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance); 17866 }, 17867 hydrateTextInstance: function (textInstance, text, internalInstanceHandle) { 17868 precacheFiberNode(internalInstanceHandle, textInstance); 17869 return diffHydratedText(textInstance, text); 17870 }, 17871 didNotMatchHydratedContainerTextInstance: function (parentContainer, textInstance, text) { 17872 { 17873 warnForUnmatchedText(textInstance, text); 17874 } 17875 }, 17876 didNotMatchHydratedTextInstance: function (parentType, parentProps, parentInstance, textInstance, text) { 17877 if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 17878 warnForUnmatchedText(textInstance, text); 17879 } 17880 }, 17881 didNotHydrateContainerInstance: function (parentContainer, instance) { 17882 { 17883 if (instance.nodeType === 1) { 17884 warnForDeletedHydratableElement(parentContainer, instance); 17885 } else { 17886 warnForDeletedHydratableText(parentContainer, instance); 17887 } 17888 } 17889 }, 17890 didNotHydrateInstance: function (parentType, parentProps, parentInstance, instance) { 17891 if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 17892 if (instance.nodeType === 1) { 17893 warnForDeletedHydratableElement(parentInstance, instance); 17894 } else { 17895 warnForDeletedHydratableText(parentInstance, instance); 17896 } 17897 } 17898 }, 17899 didNotFindHydratableContainerInstance: function (parentContainer, type, props) { 17900 { 17901 warnForInsertedHydratedElement(parentContainer, type, props); 17902 } 17903 }, 17904 didNotFindHydratableContainerTextInstance: function (parentContainer, text) { 17905 { 17906 warnForInsertedHydratedText(parentContainer, text); 17907 } 17908 }, 17909 didNotFindHydratableInstance: function (parentType, parentProps, parentInstance, type, props) { 17910 if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 17911 warnForInsertedHydratedElement(parentInstance, type, props); 17912 } 17913 }, 17914 didNotFindHydratableTextInstance: function (parentType, parentProps, parentInstance, text) { 17915 if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 17916 warnForInsertedHydratedText(parentInstance, text); 17917 } 17918 } 17919 }, 17920 17921 scheduleDeferredCallback: rIC, 17922 cancelDeferredCallback: cIC, 17923 17924 useSyncScheduling: !enableAsyncSchedulingByDefaultInReactDOM 17925 }); 17926 17927 injection$4.injectFiberBatchedUpdates(DOMRenderer.batchedUpdates); 17928 17929 var warnedAboutHydrateAPI = false; 17930 17931 function renderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 17932 !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0; 17933 17934 { 17935 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 17936 var hostInstance = DOMRenderer.findHostInstanceWithNoPortals(container._reactRootContainer.current); 17937 if (hostInstance) { 17938 warning(hostInstance.parentNode === container, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.'); 17939 } 17940 } 17941 17942 var isRootRenderedBySomeReact = !!container._reactRootContainer; 17943 var rootEl = getReactRootElementInContainer(container); 17944 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl)); 17945 17946 warning(!hasNonRootReactChild || isRootRenderedBySomeReact, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.'); 17947 17948 warning(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.'); 17949 } 17950 17951 var root = container._reactRootContainer; 17952 if (!root) { 17953 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); 17954 // First clear any existing content. 17955 if (!shouldHydrate) { 17956 var warned = false; 17957 var rootSibling = void 0; 17958 while (rootSibling = container.lastChild) { 17959 { 17960 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 17961 warned = true; 17962 warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.'); 17963 } 17964 } 17965 container.removeChild(rootSibling); 17966 } 17967 } 17968 { 17969 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 17970 warnedAboutHydrateAPI = true; 17971 lowPriorityWarning$1(false, 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.'); 17972 } 17973 } 17974 var newRoot = DOMRenderer.createContainer(container, shouldHydrate); 17975 root = container._reactRootContainer = newRoot; 17976 // Initial mount should not be batched. 17977 DOMRenderer.unbatchedUpdates(function () { 17978 DOMRenderer.updateContainer(children, newRoot, parentComponent, callback); 17979 }); 17980 } else { 17981 DOMRenderer.updateContainer(children, root, parentComponent, callback); 17982 } 17983 return DOMRenderer.getPublicRootInstance(root); 17984 } 17985 17986 function createPortal(children, container) { 17987 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 17988 17989 !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0; 17990 // TODO: pass ReactDOM portal implementation as third argument 17991 return createPortal$1(children, container, null, key); 17992 } 17993 17994 function ReactRoot(container, hydrate) { 17995 var root = DOMRenderer.createContainer(container, hydrate); 17996 this._reactRootContainer = root; 17997 } 17998 ReactRoot.prototype.render = function (children, callback) { 17999 var root = this._reactRootContainer; 18000 DOMRenderer.updateContainer(children, root, null, callback); 18001 }; 18002 ReactRoot.prototype.unmount = function (callback) { 18003 var root = this._reactRootContainer; 18004 DOMRenderer.updateContainer(null, root, null, callback); 18005 }; 18006 18007 var ReactDOM = { 18008 createPortal: createPortal, 18009 18010 findDOMNode: function (componentOrElement) { 18011 { 18012 var owner = ReactCurrentOwner.current; 18013 if (owner !== null) { 18014 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 18015 warning(warnedAboutRefsInRender, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner) || 'A component'); 18016 owner.stateNode._warnedAboutRefsInRender = true; 18017 } 18018 } 18019 if (componentOrElement == null) { 18020 return null; 18021 } 18022 if (componentOrElement.nodeType === ELEMENT_NODE) { 18023 return componentOrElement; 18024 } 18025 18026 var inst = get(componentOrElement); 18027 if (inst) { 18028 return DOMRenderer.findHostInstance(inst); 18029 } 18030 18031 if (typeof componentOrElement.render === 'function') { 18032 invariant(false, 'Unable to find node on an unmounted component.'); 18033 } else { 18034 invariant(false, 'Element appears to be neither ReactComponent nor DOMNode. Keys: %s', Object.keys(componentOrElement)); 18035 } 18036 }, 18037 hydrate: function (element, container, callback) { 18038 // TODO: throw or warn if we couldn't hydrate? 18039 return renderSubtreeIntoContainer(null, element, container, true, callback); 18040 }, 18041 render: function (element, container, callback) { 18042 return renderSubtreeIntoContainer(null, element, container, false, callback); 18043 }, 18044 unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) { 18045 !(parentComponent != null && has(parentComponent)) ? invariant(false, 'parentComponent must be a valid React Component') : void 0; 18046 return renderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 18047 }, 18048 unmountComponentAtNode: function (container) { 18049 !isValidContainer(container) ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : void 0; 18050 18051 if (container._reactRootContainer) { 18052 { 18053 var rootEl = getReactRootElementInContainer(container); 18054 var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl); 18055 warning(!renderedByDifferentReact, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); 18056 } 18057 18058 // Unmount should not be batched. 18059 DOMRenderer.unbatchedUpdates(function () { 18060 renderSubtreeIntoContainer(null, null, container, false, function () { 18061 container._reactRootContainer = null; 18062 }); 18063 }); 18064 // If you call unmountComponentAtNode twice in quick succession, you'll 18065 // get `true` twice. That's probably fine? 18066 return true; 18067 } else { 18068 { 18069 var _rootEl = getReactRootElementInContainer(container); 18070 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); 18071 18072 // Check if the container itself is a React root node. 18073 var isContainerReactRoot = container.nodeType === 1 && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 18074 18075 warning(!hasNonRootReactChild, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.'); 18076 } 18077 18078 return false; 18079 } 18080 }, 18081 18082 18083 // Temporary alias since we already shipped React 16 RC with it. 18084 // TODO: remove in React 17. 18085 unstable_createPortal: createPortal, 18086 18087 unstable_batchedUpdates: batchedUpdates, 18088 18089 unstable_deferredUpdates: DOMRenderer.deferredUpdates, 18090 18091 flushSync: DOMRenderer.flushSync, 18092 18093 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { 18094 // For TapEventPlugin which is popular in open source 18095 EventPluginHub: EventPluginHub, 18096 // Used by test-utils 18097 EventPluginRegistry: EventPluginRegistry, 18098 EventPropagators: EventPropagators, 18099 ReactControlledComponent: ReactControlledComponent, 18100 ReactDOMComponentTree: ReactDOMComponentTree, 18101 ReactDOMEventListener: ReactDOMEventListener 18102 } 18103 }; 18104 18105 if (enableCreateRoot) { 18106 ReactDOM.createRoot = function createRoot(container, options) { 18107 var hydrate = options != null && options.hydrate === true; 18108 return new ReactRoot(container, hydrate); 18109 }; 18110 } 18111 18112 var foundDevTools = DOMRenderer.injectIntoDevTools({ 18113 findFiberByHostInstance: getClosestInstanceFromNode, 18114 bundleType: 1, 18115 version: ReactVersion, 18116 rendererPackageName: 'react-dom' 18117 }); 18118 18119 { 18120 if (!foundDevTools && ExecutionEnvironment.canUseDOM && window.top === window.self) { 18121 // If we're in Chrome or Firefox, provide a download link if not installed. 18122 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 18123 var protocol = window.location.protocol; 18124 // Don't warn in exotic cases like chrome-extension://. 18125 if (/^(https?|file):$/.test(protocol)) { 18126 console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://fb.me/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://fb.me/react-devtools-faq' : ''), 'font-weight:bold'); 18127 } 18128 } 18129 } 18130 } 18131 18132 18133 18134 var ReactDOM$2 = Object.freeze({ 18135 default: ReactDOM 18136 }); 18137 18138 var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2; 18139 18140 // TODO: decide on the top-level export form. 18141 // This is hacky but makes it work with both Rollup and Jest. 18142 var reactDom = ReactDOM$3['default'] ? ReactDOM$3['default'] : ReactDOM$3; 18143 18144 module.exports = reactDom; 18145 })(); 18146 } 18147 18148 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 18149 18150 /***/ }), 18151 /* 25 */ 18152 /***/ (function(module, exports, __webpack_require__) { 18153 18154 "use strict"; 18155 /** 18156 * Copyright (c) 2013-present, Facebook, Inc. 18157 * 18158 * This source code is licensed under the MIT license found in the 18159 * LICENSE file in the root directory of this source tree. 18160 * 18161 * @typechecks 18162 */ 18163 18164 18165 18166 var hyphenate = __webpack_require__(26); 18167 18168 var msPattern = /^ms-/; 18169 18170 /** 18171 * Hyphenates a camelcased CSS property name, for example: 18172 * 18173 * > hyphenateStyleName('backgroundColor') 18174 * < "background-color" 18175 * > hyphenateStyleName('MozTransition') 18176 * < "-moz-transition" 18177 * > hyphenateStyleName('msTransition') 18178 * < "-ms-transition" 18179 * 18180 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 18181 * is converted to `-ms-`. 18182 * 18183 * @param {string} string 18184 * @return {string} 18185 */ 18186 function hyphenateStyleName(string) { 18187 return hyphenate(string).replace(msPattern, '-ms-'); 18188 } 18189 18190 module.exports = hyphenateStyleName; 18191 18192 /***/ }), 18193 /* 26 */ 18194 /***/ (function(module, exports, __webpack_require__) { 18195 18196 "use strict"; 18197 18198 18199 /** 18200 * Copyright (c) 2013-present, Facebook, Inc. 18201 * 18202 * This source code is licensed under the MIT license found in the 18203 * LICENSE file in the root directory of this source tree. 18204 * 18205 * @typechecks 18206 */ 18207 18208 var _uppercasePattern = /([A-Z])/g; 18209 18210 /** 18211 * Hyphenates a camelcased string, for example: 18212 * 18213 * > hyphenate('backgroundColor') 18214 * < "background-color" 18215 * 18216 * For CSS style names, use `hyphenateStyleName` instead which works properly 18217 * with all vendor prefixes, including `ms`. 18218 * 18219 * @param {string} string 18220 * @return {string} 18221 */ 18222 function hyphenate(string) { 18223 return string.replace(_uppercasePattern, '-$1').toLowerCase(); 18224 } 18225 18226 module.exports = hyphenate; 18227 18228 /***/ }), 18229 /* 27 */ 18230 /***/ (function(module, exports, __webpack_require__) { 18231 18232 "use strict"; 18233 /** 18234 * Copyright (c) 2013-present, Facebook, Inc. 18235 * 18236 * This source code is licensed under the MIT license found in the 18237 * LICENSE file in the root directory of this source tree. 18238 * 18239 * @typechecks 18240 */ 18241 18242 18243 18244 var camelize = __webpack_require__(28); 18245 18246 var msPattern = /^-ms-/; 18247 18248 /** 18249 * Camelcases a hyphenated CSS property name, for example: 18250 * 18251 * > camelizeStyleName('background-color') 18252 * < "backgroundColor" 18253 * > camelizeStyleName('-moz-transition') 18254 * < "MozTransition" 18255 * > camelizeStyleName('-ms-transition') 18256 * < "msTransition" 18257 * 18258 * As Andi Smith suggests 18259 * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 18260 * is converted to lowercase `ms`. 18261 * 18262 * @param {string} string 18263 * @return {string} 18264 */ 18265 function camelizeStyleName(string) { 18266 return camelize(string.replace(msPattern, 'ms-')); 18267 } 18268 18269 module.exports = camelizeStyleName; 18270 18271 /***/ }), 18272 /* 28 */ 18273 /***/ (function(module, exports, __webpack_require__) { 18274 18275 "use strict"; 18276 18277 18278 /** 18279 * Copyright (c) 2013-present, Facebook, Inc. 18280 * 18281 * This source code is licensed under the MIT license found in the 18282 * LICENSE file in the root directory of this source tree. 18283 * 18284 * @typechecks 18285 */ 18286 18287 var _hyphenPattern = /-(.)/g; 18288 18289 /** 18290 * Camelcases a hyphenated string, for example: 18291 * 18292 * > camelize('background-color') 18293 * < "backgroundColor" 18294 * 18295 * @param {string} string 18296 * @return {string} 18297 */ 18298 function camelize(string) { 18299 return string.replace(_hyphenPattern, function (_, character) { 18300 return character.toUpperCase(); 18301 }); 18302 } 18303 18304 module.exports = camelize; 18305 18306 /***/ }), 18307 /* 29 */ 18308 /***/ (function(module, exports, __webpack_require__) { 18309 18310 "use strict"; 18311 /* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.2.0 18312 * react-dom-test-utils.development.js 18313 * 18314 * Copyright (c) 2013-present, Facebook, Inc. 18315 * 18316 * This source code is licensed under the MIT license found in the 18317 * LICENSE file in the root directory of this source tree. 18318 */ 18319 18320 18321 18322 18323 18324 if (process.env.NODE_ENV !== "production") { 18325 (function() { 18326 'use strict'; 18327 18328 var _assign = __webpack_require__(2); 18329 var React = __webpack_require__(3); 18330 var ReactDOM = __webpack_require__(9); 18331 var invariant = __webpack_require__(5); 18332 var warning = __webpack_require__(6); 18333 var emptyFunction = __webpack_require__(1); 18334 var ExecutionEnvironment = __webpack_require__(7); 18335 18336 /** 18337 * WARNING: DO NOT manually require this module. 18338 * This is a replacement for `invariant(...)` used by the error code system 18339 * and will _only_ be required by the corresponding babel pass. 18340 * It always throws. 18341 */ 18342 18343 /** 18344 * `ReactInstanceMap` maintains a mapping from a public facing stateful 18345 * instance (key) and the internal representation (value). This allows public 18346 * methods to accept the user facing instance as an argument and map them back 18347 * to internal methods. 18348 * 18349 * Note that this module is currently shared and assumed to be stateless. 18350 * If this becomes an actual Map, that will break. 18351 */ 18352 18353 /** 18354 * This API should be called `delete` but we'd have to make sure to always 18355 * transform these to strings for IE support. When this transform is fully 18356 * supported we can rename it. 18357 */ 18358 18359 18360 function get(key) { 18361 return key._reactInternalFiber; 18362 } 18363 18364 var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 18365 18366 var ReactCurrentOwner = ReactInternals.ReactCurrentOwner; 18367 var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame; 18368 18369 // Before we know whether it is functional or class 18370 var FunctionalComponent = 1; 18371 var ClassComponent = 2; 18372 var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 18373 // A subtree. Could be an entry point to a different renderer. 18374 var HostComponent = 5; 18375 var HostText = 6; 18376 18377 // Don't change these two values: 18378 var NoEffect = 0; // 0b00000000 18379 // 0b00000001 18380 18381 // You can change the rest (and add more). 18382 var Placement = 2; // 0b00000010 18383 // 0b00000100 18384 // 0b00000110 18385 // 0b00001000 18386 // 0b00010000 18387 // 0b00100000 18388 // 0b01000000 18389 // 0b10000000 18390 18391 var MOUNTING = 1; 18392 var MOUNTED = 2; 18393 var UNMOUNTED = 3; 18394 18395 function isFiberMountedImpl(fiber) { 18396 var node = fiber; 18397 if (!fiber.alternate) { 18398 // If there is no alternate, this might be a new tree that isn't inserted 18399 // yet. If it is, then it will have a pending insertion effect on it. 18400 if ((node.effectTag & Placement) !== NoEffect) { 18401 return MOUNTING; 18402 } 18403 while (node['return']) { 18404 node = node['return']; 18405 if ((node.effectTag & Placement) !== NoEffect) { 18406 return MOUNTING; 18407 } 18408 } 18409 } else { 18410 while (node['return']) { 18411 node = node['return']; 18412 } 18413 } 18414 if (node.tag === HostRoot) { 18415 // TODO: Check if this was a nested HostRoot when used with 18416 // renderContainerIntoSubtree. 18417 return MOUNTED; 18418 } 18419 // If we didn't hit the root, that means that we're in an disconnected tree 18420 // that has been unmounted. 18421 return UNMOUNTED; 18422 } 18423 18424 18425 18426 18427 18428 function assertIsMounted(fiber) { 18429 !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 18430 } 18431 18432 function findCurrentFiberUsingSlowPath(fiber) { 18433 var alternate = fiber.alternate; 18434 if (!alternate) { 18435 // If there is no alternate, then we only need to check if it is mounted. 18436 var state = isFiberMountedImpl(fiber); 18437 !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 18438 if (state === MOUNTING) { 18439 return null; 18440 } 18441 return fiber; 18442 } 18443 // If we have two possible branches, we'll walk backwards up to the root 18444 // to see what path the root points to. On the way we may hit one of the 18445 // special cases and we'll deal with them. 18446 var a = fiber; 18447 var b = alternate; 18448 while (true) { 18449 var parentA = a['return']; 18450 var parentB = parentA ? parentA.alternate : null; 18451 if (!parentA || !parentB) { 18452 // We're at the root. 18453 break; 18454 } 18455 18456 // If both copies of the parent fiber point to the same child, we can 18457 // assume that the child is current. This happens when we bailout on low 18458 // priority: the bailed out fiber's child reuses the current child. 18459 if (parentA.child === parentB.child) { 18460 var child = parentA.child; 18461 while (child) { 18462 if (child === a) { 18463 // We've determined that A is the current branch. 18464 assertIsMounted(parentA); 18465 return fiber; 18466 } 18467 if (child === b) { 18468 // We've determined that B is the current branch. 18469 assertIsMounted(parentA); 18470 return alternate; 18471 } 18472 child = child.sibling; 18473 } 18474 // We should never have an alternate for any mounting node. So the only 18475 // way this could possibly happen is if this was unmounted, if at all. 18476 invariant(false, 'Unable to find node on an unmounted component.'); 18477 } 18478 18479 if (a['return'] !== b['return']) { 18480 // The return pointer of A and the return pointer of B point to different 18481 // fibers. We assume that return pointers never criss-cross, so A must 18482 // belong to the child set of A.return, and B must belong to the child 18483 // set of B.return. 18484 a = parentA; 18485 b = parentB; 18486 } else { 18487 // The return pointers point to the same fiber. We'll have to use the 18488 // default, slow path: scan the child sets of each parent alternate to see 18489 // which child belongs to which set. 18490 // 18491 // Search parent A's child set 18492 var didFindChild = false; 18493 var _child = parentA.child; 18494 while (_child) { 18495 if (_child === a) { 18496 didFindChild = true; 18497 a = parentA; 18498 b = parentB; 18499 break; 18500 } 18501 if (_child === b) { 18502 didFindChild = true; 18503 b = parentA; 18504 a = parentB; 18505 break; 18506 } 18507 _child = _child.sibling; 18508 } 18509 if (!didFindChild) { 18510 // Search parent B's child set 18511 _child = parentB.child; 18512 while (_child) { 18513 if (_child === a) { 18514 didFindChild = true; 18515 a = parentB; 18516 b = parentA; 18517 break; 18518 } 18519 if (_child === b) { 18520 didFindChild = true; 18521 b = parentB; 18522 a = parentA; 18523 break; 18524 } 18525 _child = _child.sibling; 18526 } 18527 !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0; 18528 } 18529 } 18530 18531 !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0; 18532 } 18533 // If the root is not a host container, we're in a disconnected tree. I.e. 18534 // unmounted. 18535 !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 18536 if (a.stateNode.current === a) { 18537 // We've determined that A is the current branch. 18538 return fiber; 18539 } 18540 // Otherwise B has to be current branch. 18541 return alternate; 18542 } 18543 18544 /* eslint valid-typeof: 0 */ 18545 18546 var didWarnForAddedNewProperty = false; 18547 var isProxySupported = typeof Proxy === 'function'; 18548 var EVENT_POOL_SIZE = 10; 18549 18550 var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; 18551 18552 /** 18553 * @interface Event 18554 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 18555 */ 18556 var EventInterface = { 18557 type: null, 18558 target: null, 18559 // currentTarget is set when dispatching; no use in copying it here 18560 currentTarget: emptyFunction.thatReturnsNull, 18561 eventPhase: null, 18562 bubbles: null, 18563 cancelable: null, 18564 timeStamp: function (event) { 18565 return event.timeStamp || Date.now(); 18566 }, 18567 defaultPrevented: null, 18568 isTrusted: null 18569 }; 18570 18571 /** 18572 * Synthetic events are dispatched by event plugins, typically in response to a 18573 * top-level event delegation handler. 18574 * 18575 * These systems should generally use pooling to reduce the frequency of garbage 18576 * collection. The system should check `isPersistent` to determine whether the 18577 * event should be released into the pool after being dispatched. Users that 18578 * need a persisted event should invoke `persist`. 18579 * 18580 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 18581 * normalizing browser quirks. Subclasses do not necessarily have to implement a 18582 * DOM interface; custom application-specific events can also subclass this. 18583 * 18584 * @param {object} dispatchConfig Configuration used to dispatch this event. 18585 * @param {*} targetInst Marker identifying the event target. 18586 * @param {object} nativeEvent Native browser event. 18587 * @param {DOMEventTarget} nativeEventTarget Target node. 18588 */ 18589 function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { 18590 { 18591 // these have a getter/setter for warnings 18592 delete this.nativeEvent; 18593 delete this.preventDefault; 18594 delete this.stopPropagation; 18595 } 18596 18597 this.dispatchConfig = dispatchConfig; 18598 this._targetInst = targetInst; 18599 this.nativeEvent = nativeEvent; 18600 18601 var Interface = this.constructor.Interface; 18602 for (var propName in Interface) { 18603 if (!Interface.hasOwnProperty(propName)) { 18604 continue; 18605 } 18606 { 18607 delete this[propName]; // this has a getter/setter for warnings 18608 } 18609 var normalize = Interface[propName]; 18610 if (normalize) { 18611 this[propName] = normalize(nativeEvent); 18612 } else { 18613 if (propName === 'target') { 18614 this.target = nativeEventTarget; 18615 } else { 18616 this[propName] = nativeEvent[propName]; 18617 } 18618 } 18619 } 18620 18621 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 18622 if (defaultPrevented) { 18623 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 18624 } else { 18625 this.isDefaultPrevented = emptyFunction.thatReturnsFalse; 18626 } 18627 this.isPropagationStopped = emptyFunction.thatReturnsFalse; 18628 return this; 18629 } 18630 18631 _assign(SyntheticEvent.prototype, { 18632 preventDefault: function () { 18633 this.defaultPrevented = true; 18634 var event = this.nativeEvent; 18635 if (!event) { 18636 return; 18637 } 18638 18639 if (event.preventDefault) { 18640 event.preventDefault(); 18641 } else if (typeof event.returnValue !== 'unknown') { 18642 event.returnValue = false; 18643 } 18644 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 18645 }, 18646 18647 stopPropagation: function () { 18648 var event = this.nativeEvent; 18649 if (!event) { 18650 return; 18651 } 18652 18653 if (event.stopPropagation) { 18654 event.stopPropagation(); 18655 } else if (typeof event.cancelBubble !== 'unknown') { 18656 // The ChangeEventPlugin registers a "propertychange" event for 18657 // IE. This event does not support bubbling or cancelling, and 18658 // any references to cancelBubble throw "Member not found". A 18659 // typeof check of "unknown" circumvents this issue (and is also 18660 // IE specific). 18661 event.cancelBubble = true; 18662 } 18663 18664 this.isPropagationStopped = emptyFunction.thatReturnsTrue; 18665 }, 18666 18667 /** 18668 * We release all dispatched `SyntheticEvent`s after each event loop, adding 18669 * them back into the pool. This allows a way to hold onto a reference that 18670 * won't be added back into the pool. 18671 */ 18672 persist: function () { 18673 this.isPersistent = emptyFunction.thatReturnsTrue; 18674 }, 18675 18676 /** 18677 * Checks if this event should be released back into the pool. 18678 * 18679 * @return {boolean} True if this should not be released, false otherwise. 18680 */ 18681 isPersistent: emptyFunction.thatReturnsFalse, 18682 18683 /** 18684 * `PooledClass` looks for `destructor` on each instance it releases. 18685 */ 18686 destructor: function () { 18687 var Interface = this.constructor.Interface; 18688 for (var propName in Interface) { 18689 { 18690 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); 18691 } 18692 } 18693 for (var i = 0; i < shouldBeReleasedProperties.length; i++) { 18694 this[shouldBeReleasedProperties[i]] = null; 18695 } 18696 { 18697 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); 18698 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction)); 18699 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction)); 18700 } 18701 } 18702 }); 18703 18704 SyntheticEvent.Interface = EventInterface; 18705 18706 /** 18707 * Helper to reduce boilerplate when creating subclasses. 18708 * 18709 * @param {function} Class 18710 * @param {?object} Interface 18711 */ 18712 SyntheticEvent.augmentClass = function (Class, Interface) { 18713 var Super = this; 18714 18715 var E = function () {}; 18716 E.prototype = Super.prototype; 18717 var prototype = new E(); 18718 18719 _assign(prototype, Class.prototype); 18720 Class.prototype = prototype; 18721 Class.prototype.constructor = Class; 18722 18723 Class.Interface = _assign({}, Super.Interface, Interface); 18724 Class.augmentClass = Super.augmentClass; 18725 addEventPoolingTo(Class); 18726 }; 18727 18728 /** Proxying after everything set on SyntheticEvent 18729 * to resolve Proxy issue on some WebKit browsers 18730 * in which some Event properties are set to undefined (GH#10010) 18731 */ 18732 { 18733 if (isProxySupported) { 18734 /*eslint-disable no-func-assign */ 18735 SyntheticEvent = new Proxy(SyntheticEvent, { 18736 construct: function (target, args) { 18737 return this.apply(target, Object.create(target.prototype), args); 18738 }, 18739 apply: function (constructor, that, args) { 18740 return new Proxy(constructor.apply(that, args), { 18741 set: function (target, prop, value) { 18742 if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { 18743 warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); 18744 didWarnForAddedNewProperty = true; 18745 } 18746 target[prop] = value; 18747 return true; 18748 } 18749 }); 18750 } 18751 }); 18752 /*eslint-enable no-func-assign */ 18753 } 18754 } 18755 18756 addEventPoolingTo(SyntheticEvent); 18757 18758 /** 18759 * Helper to nullify syntheticEvent instance properties when destructing 18760 * 18761 * @param {String} propName 18762 * @param {?object} getVal 18763 * @return {object} defineProperty object 18764 */ 18765 function getPooledWarningPropertyDefinition(propName, getVal) { 18766 var isFunction = typeof getVal === 'function'; 18767 return { 18768 configurable: true, 18769 set: set, 18770 get: get 18771 }; 18772 18773 function set(val) { 18774 var action = isFunction ? 'setting the method' : 'setting the property'; 18775 warn(action, 'This is effectively a no-op'); 18776 return val; 18777 } 18778 18779 function get() { 18780 var action = isFunction ? 'accessing the method' : 'accessing the property'; 18781 var result = isFunction ? 'This is a no-op function' : 'This is set to null'; 18782 warn(action, result); 18783 return getVal; 18784 } 18785 18786 function warn(action, result) { 18787 var warningCondition = false; 18788 warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); 18789 } 18790 } 18791 18792 function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { 18793 var EventConstructor = this; 18794 if (EventConstructor.eventPool.length) { 18795 var instance = EventConstructor.eventPool.pop(); 18796 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); 18797 return instance; 18798 } 18799 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); 18800 } 18801 18802 function releasePooledEvent(event) { 18803 var EventConstructor = this; 18804 !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0; 18805 event.destructor(); 18806 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { 18807 EventConstructor.eventPool.push(event); 18808 } 18809 } 18810 18811 function addEventPoolingTo(EventConstructor) { 18812 EventConstructor.eventPool = []; 18813 EventConstructor.getPooled = getPooledEvent; 18814 EventConstructor.release = releasePooledEvent; 18815 } 18816 18817 var SyntheticEvent$1 = SyntheticEvent; 18818 18819 /** 18820 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 18821 * 18822 * @param {string} styleProp 18823 * @param {string} eventName 18824 * @returns {object} 18825 */ 18826 function makePrefixMap(styleProp, eventName) { 18827 var prefixes = {}; 18828 18829 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 18830 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 18831 prefixes['Moz' + styleProp] = 'moz' + eventName; 18832 prefixes['ms' + styleProp] = 'MS' + eventName; 18833 prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); 18834 18835 return prefixes; 18836 } 18837 18838 /** 18839 * A list of event names to a configurable list of vendor prefixes. 18840 */ 18841 var vendorPrefixes = { 18842 animationend: makePrefixMap('Animation', 'AnimationEnd'), 18843 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 18844 animationstart: makePrefixMap('Animation', 'AnimationStart'), 18845 transitionend: makePrefixMap('Transition', 'TransitionEnd') 18846 }; 18847 18848 /** 18849 * Event names that have already been detected and prefixed (if applicable). 18850 */ 18851 var prefixedEventNames = {}; 18852 18853 /** 18854 * Element to check for prefixes on. 18855 */ 18856 var style = {}; 18857 18858 /** 18859 * Bootstrap if a DOM exists. 18860 */ 18861 if (ExecutionEnvironment.canUseDOM) { 18862 style = document.createElement('div').style; 18863 18864 // On some platforms, in particular some releases of Android 4.x, 18865 // the un-prefixed "animation" and "transition" properties are defined on the 18866 // style object but the events that fire will still be prefixed, so we need 18867 // to check if the un-prefixed events are usable, and if not remove them from the map. 18868 if (!('AnimationEvent' in window)) { 18869 delete vendorPrefixes.animationend.animation; 18870 delete vendorPrefixes.animationiteration.animation; 18871 delete vendorPrefixes.animationstart.animation; 18872 } 18873 18874 // Same as above 18875 if (!('TransitionEvent' in window)) { 18876 delete vendorPrefixes.transitionend.transition; 18877 } 18878 } 18879 18880 /** 18881 * Attempts to determine the correct vendor prefixed event name. 18882 * 18883 * @param {string} eventName 18884 * @returns {string} 18885 */ 18886 function getVendorPrefixedEventName(eventName) { 18887 if (prefixedEventNames[eventName]) { 18888 return prefixedEventNames[eventName]; 18889 } else if (!vendorPrefixes[eventName]) { 18890 return eventName; 18891 } 18892 18893 var prefixMap = vendorPrefixes[eventName]; 18894 18895 for (var styleProp in prefixMap) { 18896 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 18897 return prefixedEventNames[eventName] = prefixMap[styleProp]; 18898 } 18899 } 18900 18901 return ''; 18902 } 18903 18904 /** 18905 * Types of raw signals from the browser caught at the top level. 18906 * 18907 * For events like 'submit' which don't consistently bubble (which we 18908 * trap at a lower node than `document`), binding at `document` would 18909 * cause duplicate events so we don't include them here. 18910 */ 18911 var topLevelTypes$1 = { 18912 topAbort: 'abort', 18913 topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend', 18914 topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration', 18915 topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart', 18916 topBlur: 'blur', 18917 topCancel: 'cancel', 18918 topCanPlay: 'canplay', 18919 topCanPlayThrough: 'canplaythrough', 18920 topChange: 'change', 18921 topClick: 'click', 18922 topClose: 'close', 18923 topCompositionEnd: 'compositionend', 18924 topCompositionStart: 'compositionstart', 18925 topCompositionUpdate: 'compositionupdate', 18926 topContextMenu: 'contextmenu', 18927 topCopy: 'copy', 18928 topCut: 'cut', 18929 topDoubleClick: 'dblclick', 18930 topDrag: 'drag', 18931 topDragEnd: 'dragend', 18932 topDragEnter: 'dragenter', 18933 topDragExit: 'dragexit', 18934 topDragLeave: 'dragleave', 18935 topDragOver: 'dragover', 18936 topDragStart: 'dragstart', 18937 topDrop: 'drop', 18938 topDurationChange: 'durationchange', 18939 topEmptied: 'emptied', 18940 topEncrypted: 'encrypted', 18941 topEnded: 'ended', 18942 topError: 'error', 18943 topFocus: 'focus', 18944 topInput: 'input', 18945 topKeyDown: 'keydown', 18946 topKeyPress: 'keypress', 18947 topKeyUp: 'keyup', 18948 topLoadedData: 'loadeddata', 18949 topLoad: 'load', 18950 topLoadedMetadata: 'loadedmetadata', 18951 topLoadStart: 'loadstart', 18952 topMouseDown: 'mousedown', 18953 topMouseMove: 'mousemove', 18954 topMouseOut: 'mouseout', 18955 topMouseOver: 'mouseover', 18956 topMouseUp: 'mouseup', 18957 topPaste: 'paste', 18958 topPause: 'pause', 18959 topPlay: 'play', 18960 topPlaying: 'playing', 18961 topProgress: 'progress', 18962 topRateChange: 'ratechange', 18963 topScroll: 'scroll', 18964 topSeeked: 'seeked', 18965 topSeeking: 'seeking', 18966 topSelectionChange: 'selectionchange', 18967 topStalled: 'stalled', 18968 topSuspend: 'suspend', 18969 topTextInput: 'textInput', 18970 topTimeUpdate: 'timeupdate', 18971 topToggle: 'toggle', 18972 topTouchCancel: 'touchcancel', 18973 topTouchEnd: 'touchend', 18974 topTouchMove: 'touchmove', 18975 topTouchStart: 'touchstart', 18976 topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend', 18977 topVolumeChange: 'volumechange', 18978 topWaiting: 'waiting', 18979 topWheel: 'wheel' 18980 }; 18981 18982 var BrowserEventConstants = { 18983 topLevelTypes: topLevelTypes$1 18984 }; 18985 18986 var findDOMNode = ReactDOM.findDOMNode; 18987 var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 18988 var EventPluginHub = _ReactDOM$__SECRET_IN.EventPluginHub; 18989 var EventPluginRegistry = _ReactDOM$__SECRET_IN.EventPluginRegistry; 18990 var EventPropagators = _ReactDOM$__SECRET_IN.EventPropagators; 18991 var ReactControlledComponent = _ReactDOM$__SECRET_IN.ReactControlledComponent; 18992 var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree; 18993 var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener; 18994 18995 18996 var topLevelTypes = BrowserEventConstants.topLevelTypes; 18997 18998 function Event(suffix) {} 18999 19000 /** 19001 * @class ReactTestUtils 19002 */ 19003 19004 function findAllInRenderedFiberTreeInternal(fiber, test) { 19005 if (!fiber) { 19006 return []; 19007 } 19008 var currentParent = findCurrentFiberUsingSlowPath(fiber); 19009 if (!currentParent) { 19010 return []; 19011 } 19012 var node = currentParent; 19013 var ret = []; 19014 while (true) { 19015 if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionalComponent) { 19016 var publicInst = node.stateNode; 19017 if (test(publicInst)) { 19018 ret.push(publicInst); 19019 } 19020 } 19021 if (node.child) { 19022 node.child['return'] = node; 19023 node = node.child; 19024 continue; 19025 } 19026 if (node === currentParent) { 19027 return ret; 19028 } 19029 while (!node.sibling) { 19030 if (!node['return'] || node['return'] === currentParent) { 19031 return ret; 19032 } 19033 node = node['return']; 19034 } 19035 node.sibling['return'] = node['return']; 19036 node = node.sibling; 19037 } 19038 } 19039 19040 /** 19041 * Utilities for making it easy to test React components. 19042 * 19043 * See https://reactjs.org/docs/test-utils.html 19044 * 19045 * Todo: Support the entire DOM.scry query syntax. For now, these simple 19046 * utilities will suffice for testing purposes. 19047 * @lends ReactTestUtils 19048 */ 19049 var ReactTestUtils = { 19050 renderIntoDocument: function (element) { 19051 var div = document.createElement('div'); 19052 // None of our tests actually require attaching the container to the 19053 // DOM, and doing so creates a mess that we rely on test isolation to 19054 // clean up, so we're going to stop honoring the name of this method 19055 // (and probably rename it eventually) if no problems arise. 19056 // document.documentElement.appendChild(div); 19057 return ReactDOM.render(element, div); 19058 }, 19059 19060 isElement: function (element) { 19061 return React.isValidElement(element); 19062 }, 19063 19064 isElementOfType: function (inst, convenienceConstructor) { 19065 return React.isValidElement(inst) && inst.type === convenienceConstructor; 19066 }, 19067 19068 isDOMComponent: function (inst) { 19069 return !!(inst && inst.nodeType === 1 && inst.tagName); 19070 }, 19071 19072 isDOMComponentElement: function (inst) { 19073 return !!(inst && React.isValidElement(inst) && !!inst.tagName); 19074 }, 19075 19076 isCompositeComponent: function (inst) { 19077 if (ReactTestUtils.isDOMComponent(inst)) { 19078 // Accessing inst.setState warns; just return false as that'll be what 19079 // this returns when we have DOM nodes as refs directly 19080 return false; 19081 } 19082 return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function'; 19083 }, 19084 19085 isCompositeComponentWithType: function (inst, type) { 19086 if (!ReactTestUtils.isCompositeComponent(inst)) { 19087 return false; 19088 } 19089 var internalInstance = get(inst); 19090 var constructor = internalInstance.type; 19091 return constructor === type; 19092 }, 19093 19094 findAllInRenderedTree: function (inst, test) { 19095 if (!inst) { 19096 return []; 19097 } 19098 !ReactTestUtils.isCompositeComponent(inst) ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : void 0; 19099 var internalInstance = get(inst); 19100 return findAllInRenderedFiberTreeInternal(internalInstance, test); 19101 }, 19102 19103 /** 19104 * Finds all instance of components in the rendered tree that are DOM 19105 * components with the class name matching `className`. 19106 * @return {array} an array of all the matches. 19107 */ 19108 scryRenderedDOMComponentsWithClass: function (root, classNames) { 19109 return ReactTestUtils.findAllInRenderedTree(root, function (inst) { 19110 if (ReactTestUtils.isDOMComponent(inst)) { 19111 var className = inst.className; 19112 if (typeof className !== 'string') { 19113 // SVG, probably. 19114 className = inst.getAttribute('class') || ''; 19115 } 19116 var classList = className.split(/\s+/); 19117 19118 if (!Array.isArray(classNames)) { 19119 !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0; 19120 classNames = classNames.split(/\s+/); 19121 } 19122 return classNames.every(function (name) { 19123 return classList.indexOf(name) !== -1; 19124 }); 19125 } 19126 return false; 19127 }); 19128 }, 19129 19130 /** 19131 * Like scryRenderedDOMComponentsWithClass but expects there to be one result, 19132 * and returns that one result, or throws exception if there is any other 19133 * number of matches besides one. 19134 * @return {!ReactDOMComponent} The one match. 19135 */ 19136 findRenderedDOMComponentWithClass: function (root, className) { 19137 var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className); 19138 if (all.length !== 1) { 19139 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className); 19140 } 19141 return all[0]; 19142 }, 19143 19144 /** 19145 * Finds all instance of components in the rendered tree that are DOM 19146 * components with the tag name matching `tagName`. 19147 * @return {array} an array of all the matches. 19148 */ 19149 scryRenderedDOMComponentsWithTag: function (root, tagName) { 19150 return ReactTestUtils.findAllInRenderedTree(root, function (inst) { 19151 return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase(); 19152 }); 19153 }, 19154 19155 /** 19156 * Like scryRenderedDOMComponentsWithTag but expects there to be one result, 19157 * and returns that one result, or throws exception if there is any other 19158 * number of matches besides one. 19159 * @return {!ReactDOMComponent} The one match. 19160 */ 19161 findRenderedDOMComponentWithTag: function (root, tagName) { 19162 var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName); 19163 if (all.length !== 1) { 19164 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName); 19165 } 19166 return all[0]; 19167 }, 19168 19169 /** 19170 * Finds all instances of components with type equal to `componentType`. 19171 * @return {array} an array of all the matches. 19172 */ 19173 scryRenderedComponentsWithType: function (root, componentType) { 19174 return ReactTestUtils.findAllInRenderedTree(root, function (inst) { 19175 return ReactTestUtils.isCompositeComponentWithType(inst, componentType); 19176 }); 19177 }, 19178 19179 /** 19180 * Same as `scryRenderedComponentsWithType` but expects there to be one result 19181 * and returns that one result, or throws exception if there is any other 19182 * number of matches besides one. 19183 * @return {!ReactComponent} The one match. 19184 */ 19185 findRenderedComponentWithType: function (root, componentType) { 19186 var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType); 19187 if (all.length !== 1) { 19188 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType); 19189 } 19190 return all[0]; 19191 }, 19192 19193 /** 19194 * Pass a mocked component module to this method to augment it with 19195 * useful methods that allow it to be used as a dummy React component. 19196 * Instead of rendering as usual, the component will become a simple 19197 * <div> containing any provided children. 19198 * 19199 * @param {object} module the mock function object exported from a 19200 * module that defines the component to be mocked 19201 * @param {?string} mockTagName optional dummy root tag name to return 19202 * from render method (overrides 19203 * module.mockTagName if provided) 19204 * @return {object} the ReactTestUtils object (for chaining) 19205 */ 19206 mockComponent: function (module, mockTagName) { 19207 mockTagName = mockTagName || module.mockTagName || 'div'; 19208 19209 module.prototype.render.mockImplementation(function () { 19210 return React.createElement(mockTagName, null, this.props.children); 19211 }); 19212 19213 return this; 19214 }, 19215 19216 /** 19217 * Simulates a top level event being dispatched from a raw event that occurred 19218 * on an `Element` node. 19219 * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes` 19220 * @param {!Element} node The dom to simulate an event occurring on. 19221 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. 19222 */ 19223 simulateNativeEventOnNode: function (topLevelType, node, fakeNativeEvent) { 19224 fakeNativeEvent.target = node; 19225 ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent); 19226 }, 19227 19228 /** 19229 * Simulates a top level event being dispatched from a raw event that occurred 19230 * on the `ReactDOMComponent` `comp`. 19231 * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`. 19232 * @param {!ReactDOMComponent} comp 19233 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. 19234 */ 19235 simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) { 19236 ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent); 19237 }, 19238 19239 nativeTouchData: function (x, y) { 19240 return { 19241 touches: [{ pageX: x, pageY: y }] 19242 }; 19243 }, 19244 19245 Simulate: null, 19246 SimulateNative: {} 19247 }; 19248 19249 /** 19250 * Exports: 19251 * 19252 * - `ReactTestUtils.Simulate.click(Element)` 19253 * - `ReactTestUtils.Simulate.mouseMove(Element)` 19254 * - `ReactTestUtils.Simulate.change(Element)` 19255 * - ... (All keys from event plugin `eventTypes` objects) 19256 */ 19257 function makeSimulator(eventType) { 19258 return function (domNode, eventData) { 19259 !!React.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0; 19260 !!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead.') : void 0; 19261 19262 var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType]; 19263 19264 var fakeNativeEvent = new Event(); 19265 fakeNativeEvent.target = domNode; 19266 fakeNativeEvent.type = eventType.toLowerCase(); 19267 19268 // We don't use SyntheticEvent.getPooled in order to not have to worry about 19269 // properly destroying any properties assigned from `eventData` upon release 19270 var targetInst = ReactDOMComponentTree.getInstanceFromNode(domNode); 19271 var event = new SyntheticEvent$1(dispatchConfig, targetInst, fakeNativeEvent, domNode); 19272 19273 // Since we aren't using pooling, always persist the event. This will make 19274 // sure it's marked and won't warn when setting additional properties. 19275 event.persist(); 19276 _assign(event, eventData); 19277 19278 if (dispatchConfig.phasedRegistrationNames) { 19279 EventPropagators.accumulateTwoPhaseDispatches(event); 19280 } else { 19281 EventPropagators.accumulateDirectDispatches(event); 19282 } 19283 19284 ReactDOM.unstable_batchedUpdates(function () { 19285 // Normally extractEvent enqueues a state restore, but we'll just always 19286 // do that since we we're by-passing it here. 19287 ReactControlledComponent.enqueueStateRestore(domNode); 19288 19289 EventPluginHub.enqueueEvents(event); 19290 EventPluginHub.processEventQueue(true); 19291 }); 19292 }; 19293 } 19294 19295 function buildSimulators() { 19296 ReactTestUtils.Simulate = {}; 19297 19298 var eventType; 19299 for (eventType in EventPluginRegistry.eventNameDispatchConfigs) { 19300 /** 19301 * @param {!Element|ReactDOMComponent} domComponentOrNode 19302 * @param {?object} eventData Fake event data to use in SyntheticEvent. 19303 */ 19304 ReactTestUtils.Simulate[eventType] = makeSimulator(eventType); 19305 } 19306 } 19307 19308 // Rebuild ReactTestUtils.Simulate whenever event plugins are injected 19309 var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder; 19310 EventPluginHub.injection.injectEventPluginOrder = function () { 19311 oldInjectEventPluginOrder.apply(this, arguments); 19312 buildSimulators(); 19313 }; 19314 var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName; 19315 EventPluginHub.injection.injectEventPluginsByName = function () { 19316 oldInjectEventPlugins.apply(this, arguments); 19317 buildSimulators(); 19318 }; 19319 19320 buildSimulators(); 19321 19322 /** 19323 * Exports: 19324 * 19325 * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)` 19326 * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)` 19327 * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)` 19328 * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)` 19329 * - ... (All keys from `BrowserEventConstants.topLevelTypes`) 19330 * 19331 * Note: Top level event types are a subset of the entire set of handler types 19332 * (which include a broader set of "synthetic" events). For example, onDragDone 19333 * is a synthetic event. Except when testing an event plugin or React's event 19334 * handling code specifically, you probably want to use ReactTestUtils.Simulate 19335 * to dispatch synthetic events. 19336 */ 19337 19338 function makeNativeSimulator(eventType) { 19339 return function (domComponentOrNode, nativeEventData) { 19340 var fakeNativeEvent = new Event(eventType); 19341 _assign(fakeNativeEvent, nativeEventData); 19342 if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { 19343 ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent); 19344 } else if (domComponentOrNode.tagName) { 19345 // Will allow on actual dom nodes. 19346 ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent); 19347 } 19348 }; 19349 } 19350 19351 Object.keys(topLevelTypes).forEach(function (eventType) { 19352 // Event type is stored as 'topClick' - we transform that to 'click' 19353 var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType; 19354 /** 19355 * @param {!Element|ReactDOMComponent} domComponentOrNode 19356 * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. 19357 */ 19358 ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType); 19359 }); 19360 19361 19362 19363 var ReactTestUtils$2 = Object.freeze({ 19364 default: ReactTestUtils 19365 }); 19366 19367 var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2; 19368 19369 // TODO: decide on the top-level export form. 19370 // This is hacky but makes it work with both Rollup and Jest. 19371 var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3; 19372 19373 module.exports = testUtils; 19374 })(); 19375 } 19376 19377 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) 19378 19379 /***/ }) 19380 /******/ ])));