vendor: 3,594 bytes, lines 1-88
1/******/ (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, { enumerable: true, get: getter }); 40/******/ } 41/******/ }; 42/******/ 43/******/ // define __esModule on exports 44/******/ __webpack_require__.r = function(exports) { 45/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47/******/ } 48/******/ Object.defineProperty(exports, '__esModule', { value: true }); 49/******/ }; 50/******/ 51/******/ // create a fake namespace object 52/******/ // mode & 1: value is a module id, require it 53/******/ // mode & 2: merge all properties of value into the ns 54/******/ // mode & 4: return value when already ns object 55/******/ // mode & 8|1: behave like require 56/******/ __webpack_require__.t = function(value, mode) { 57/******/ if(mode & 1) value = __webpack_require__(value); 58/******/ if(mode & 8) return value; 59/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60/******/ var ns = Object.create(null); 61/******/ __webpack_require__.r(ns); 62/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64/******/ return ns; 65/******/ }; 66/******/ 67/******/ // getDefaultExport function for compatibility with non-harmony modules 68/******/ __webpack_require__.n = function(module) { 69/******/ var getter = module && module.__esModule ? 70/******/ function getDefault() { return module['default']; } : 71/******/ function getModuleExports() { return module; }; 72/******/ __webpack_require__.d(getter, 'a', getter); 73/******/ return getter; 74/******/ }; 75/******/ 76/******/ // Object.prototype.hasOwnProperty.call 77/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78/******/ 79/******/ // __webpack_public_path__ 80/******/ __webpack_require__.p = ""; 81/******/ 82/******/ 83/******/ // Load entry module and return exports 84/******/ return __webpack_require__(__webpack_require__.s = 0); 85/******/ }) 86/************************************************************************/ 87/******/ ({ 88
89/***/ "../../../../plugins/upup-baseline-plugin/js/src/contextual-nav.js": 90/*!****************************************************************************************************************************!*\ 91 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/plugins/upup-baseline-plugin/js/src/contextual-nav.js ***! 92 \****************************************************************************************************************************/ 93/*! exports provided: default */ 94/***/ (function(module, __webpack_exports__, __webpack_require__) { 95 96"use strict"; 97__webpack_require__.r(__webpack_exports__); 98/* harmony import */ var _menu_button_menu_button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./menu-button/menu-button */ "../../../../plugins/upup-baseline-plugin/js/src/menu-button/menu-button.js"); 99function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 100 101function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 102 103 104 105var ContextualNavigationManager = function ContextualNavigationManager() { 106 _classCallCheck(this, ContextualNavigationManager); 107 108 var navigationButtons = Array.from(document.querySelectorAll('.contextual-nav__menu-button')); 109 navigationButtons.forEach(function (container) { 110 return new ContextualNavigation(container); 111 }); 112}; 113 114var ContextualNavigation = function ContextualNavigation(navigationButton) { 115 var _this = this; 116 117 _classCallCheck(this, ContextualNavigation); 118 119 _defineProperty(this, "handleActivate", function () { 120 _this.button.classList.add('is-active'); 121 }); 122 123 _defineProperty(this, "handleDeactivate", function () { 124 _this.button.classList.remove('is-active'); 125 }); 126 127 // look for the sidebar menu and accompanying button 128 var sidebarMenu = navigationButton.querySelector('.contextual-nav__list'), 129 sidebarMenuButton = navigationButton.querySelector('.contextual-nav__button'); 130 this.button = navigationButton; 131 132 if (sidebarMenu && sidebarMenuButton) { 133 new _menu_button_menu_button__WEBPACK_IMPORTED_MODULE_0__["default"](sidebarMenuButton, sidebarMenu, { 134 animate: true, 135 closeOnOutsideClick: false, 136 closeOnOutsideFocus: false, 137 onActivate: this.handleActivate, 138 onDeactivate: this.handleDeactivate 139 }); 140 } 141}; 142 143/* harmony default export */ __webpack_exports__["default"] = (ContextualNavigationManager); 144 145/***/ }), 146
vendor: 2,567 bytes, lines 147-176
147/***/ "../../../../plugins/upup-baseline-plugin/js/src/menu-button/menu-button.js": 148/*!*************************************************************************************************************************************!*\ 149 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/plugins/upup-baseline-plugin/js/src/menu-button/menu-button.js ***! 150 \*************************************************************************************************************************************/ 151/*! exports provided: default */ 152/***/ (function(module, __webpack_exports__, __webpack_require__) { 153 154"use strict"; 155__webpack_require__.r(__webpack_exports__); 156/* harmony import */ var velocity_animate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! velocity-animate */ "../../../../plugins/upup-baseline-plugin/node_modules/velocity-animate/velocity.js"); 157/* harmony import */ var velocity_animate__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(velocity_animate__WEBPACK_IMPORTED_MODULE_0__); 158/* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utility */ "../../../../plugins/upup-baseline-plugin/js/src/utility.js"); 159function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 160 161function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 162 163function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 164 165function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 166 167 168/** 169 * Menu button is intended to follow the pattern recommended by W3C for a menu button control 170 * https://www.w3.org/TR/wai-aria-practices-1.1/examples/menu-button/menu-button-links.html 171 * 172 * To do this, the constructor receives the button and the menu 173 * It then applies the correct key handling 174 * 175 * Proper labelling is assumed (aria labels) 176 * It is also assumed that the menu is comprised of links and is one level (or that all items are visible - no collapsed
176subsections) 177 * This works well in conjunction with a custom Walker that outputs nav in the proper format w/ proper attributes 178 */ 179 180 181 182var MenuButton = /*#__PURE__*/function () { 183 function MenuButton(button, menu, settings) { 184 var _this = this; 185 186 _classCallCheck(this, MenuButton); 187 188 _defineProperty(this, "handleButtonKeyDown", function (e) { 189 switch (e.key) { 190 case 'Enter': 191 case 'Spacebar': 192 case 'Space': 193 case ' ': 194 _this.toggleMenu(); 195 196 e.preventDefault(); 197 break; 198 199 case 'Down': 200 case 'ArrowDown': 201 if (!_this.isActive) { 202 _this.toggleMenu('down'); 203 } 204 205 e.preventDefault(); 206 break; 207 208 case 'Up': 209 case 'ArrowUp': 210 if (!_this.isActive) { 211 _this.toggleMenu('up'); 212 } 213 214 _this.focusLastItem(); 215 216 e.preventDefault(); 217 break; 218 219 case 'Escape': 220 case 'Esc': 221 if (_this.isActive) { 222 _this.toggleMenu(); 223 224 e.stopPropagation(); 225 } 226 227 break; 228 } 229 }); 230 231 _defineProperty(this, "handleButtonClick", function () { 232 _this.toggleMenu(); 233 }); 234 235 _defineProperty(this, "handleMenuItemKeyDown", function (e) { 236 switch (e.key) { 237 case 'ArrowDown': 238 case 'Down': 239 _this.focusNextItem(e.target); 240 241 e.preventDefault(); 242 break; 243 244 case 'ArrowUp': 245 case 'Up': 246 _this.focusPreviousItem(e.target); 247 248 e.preventDefault(); 249 break; 250 251 case 'Enter': 252 case 'Spacebar': 253 case 'Space': 254 case ' ': 255 if (_this.settings.onItemClick) { 256 _this.settings.onItemClick.call(_this, e.target); 257 } 258 259 break; 260 261 case 'Escape': 262 case 'Esc': 263 _this.toggleMenu(); 264 265 e.stopPropagation(); 266 267 _this.refs.button.focus(); 268 269 } 270 }); 271 272 _defineProperty(this, "openMenu", function () { 273 // already active, but still animating open 274 if (_this.isAnimating) { 275 return; 276 } 277 278 _this.refs.button.setAttribute('aria-expanded', 'true'); 279 280 _this.refs.menu.classList.add('active'); 281 282 _this.refs.menuItems.forEach(function (item, idx) { 283 if (idx === 0) { 284 item.setAttribute('tabindex', 0); 285 } else { 286 item.setAttribute('tabindex', -1); 287 } 288 }); 289 290 _this.isActive = true; 291 292 _this.focusFirstItem(); // check to see if there is an attached callback for activating the menu 293 294 295 if (_this.settings.onActivate) { 296 _this.settings.onActivate.call(); 297 } 298 }); 299 300 _defineProperty(this, "closeMenu", function () { 301 // already inactive, but still animating closed 302 if (_this.isAnimating) { 303 return; 304 } 305 306 _this.refs.button.setAttribute('aria-expanded', 'false'); 307 308 _this.refs.menu.classList.remove('active'); 309 310 _this.refs.menu.removeAttribute('aria-activedescendant'); 311 312 _this.refs.menuItems.forEach(function (item) { 313 item.setAttribute('tabindex', -1); 314 }); 315 316 _this.isActive = false; // check to see if there is an attached callback for deactivating the menu 317 318 if (_this.settings.onDeactivate) { 319 _this.settings.onDeactivate.call(); 320 } 321 }); 322 323 var menuItems = Array.from(menu.querySelectorAll('a, button')); // we will assume all of our menu items are links or buttons 324 // expected structure of settings 325 326 this.settings = {}; 327 this.defaults = { 328 animate: false, 329 // should the menu open/ close action be animated? 330 closeOnOutsideFocus: true, 331 closeOnOutsideClick: true, 332 onActivate: function onActivate() {}, 333 // potential callback when button activates 334 onDeactivate: function onDeactivate() {}, 335 // potential callback when button deactivates 336 onItemClick: function onItemClick() {} // when an individual item is clicked/ selected 337 338 }; 339 Object.assign(this.settings, this.defaults, settings); 340 this.isAnimating = false; // optional 341 342 this.isActive = false; // is the menu active/ showing? 343 344 this.refs = { 345 menuParent: menu.parentNode, 346 // assuming that the button and menu have the same parent 347 button: button, 348 menu: menu, 349 menuItems: menuItems 350 }; 351 this.listen(); 352 } 353 /** 354 * Keyboard on the button 355 * Enter/ Spacebar function as a click and toggle the menu 356 * Arrow down opens the menu and focuses first item 357 */ 358 359 360 _createClass(MenuButton, [{ 361 key: "listen", 362 value: function listen() { 363 var _this2 = this; 364 365 this.refs.button.addEventListener('keydown', this.handleButtonKeyDown); 366 this.refs.button.addEventListener('click', this.handleButtonClick);
367 this.refs.menuItems.forEach(function (item) { 368 item.addEventListener('keydown', _this2.handleMenuItemKeyDown); 369 }); // focus outside 370 371 window.addEventListener('focusin', function (e) { 372 if (_this2.settings.closeOnOutsideFocus && _this2.isActive && !Object(_utility__WEBPACK_IMPORTED_MODULE_1__["eventFromInside"])(e, _this2.refs.menuParent)) { 373 _this2.closeMenu(); 374 } 375 }); // click outside 376 377 window.addEventListener('click', function (e) { 378 if (_this2.settings.closeOnOutsideClick && _this2.isActive && !Object(_utility__WEBPACK_IMPORTED_MODULE_1__["eventFromInside"])(e, _this2.refs.menuParent)) { 379 _this2.closeMenu(); 380 } 381 }); 382 } 383 }, { 384 key: "toggleMenu", 385 value: function toggleMenu(direction) { 386 var _this3 = this; 387 388 if (this.isActive) { 389 this.closeMenu(); 390 391 if (this.settings.animate && !this.isAnimating) { 392 this.isAnimating = true; 393 velocity_animate__WEBPACK_IMPORTED_MODULE_0___default.a.animate(this.refs.menu, 'slideUp', { 394 duration: 250 395 }).then(function () { 396 _this3.isAnimating = false; 397 }); 398 } 399 } else { 400 this.openMenu(); 401 402 if (this.settings.animate && !this.isAnimating) { 403 this.isAnimating = true; 404 velocity_animate__WEBPACK_IMPORTED_MODULE_0___default.a.animate(this.refs.menu, 'slideDown', { 405 duration: 250 406 }).then(function () { 407 _this3.isAnimating = false; // focus after animating 408 409 if (direction === 'up') { 410 _this3.focusLastItem(); 411 } else { 412 _this3.focusFirstItem(); 413 } 414 }); 415 } 416 } 417 } 418 /** 419 * All the things that happen when menu opens 420 * Need to change attributes on button, menu and menu items 421 */ 422 423 }, { 424 key: "focusFirstItem", 425 value: function focusFirstItem() { 426 var menuItem = this.refs.menuItems[0]; 427 menuItem.focus(); 428 this.refs.menu.setAttribute('aria-activedescendant', menuItem.id); 429 } 430 }, { 431 key: "focusLastItem", 432 value: function focusLastItem() { 433 var menuItem = this.refs.menuItems[this.refs.menuItems.length - 1]; 434 menuItem.focus(); 435 this.refs.menu.setAttribute('aria-activedescendant', menuItem.id); 436 } 437 }, { 438 key: "focusNextItem", 439 value: function focusNextItem(currentItem) { 440 var currentIndex = this.refs.menuItems.findIndex(function (element) { 441 return element === currentItem; 442 }), 443 nextItem = null; // allow the next item to be focused 444 445 if (!(nextItem = this.refs.menuItems[currentIndex + 1])) { 446 nextItem = this.refs.menuItems[0]; 447 } 448 449 currentItem.setAttribute('tabindex', -1); 450 nextItem.setAttribute('tabindex', 0); 451 nextItem.focus(); 452 this.refs.menu.setAttribute('aria-activedescendant', nextItem.id); 453 } 454 }, { 455 key: "focusPreviousItem", 456 value: function focusPreviousItem(currentItem) { 457 var currentIndex = this.refs.menuItems.findIndex(function (element) { 458 return element === currentItem; 459 }), 460 nextItem = null; 461 462 if (currentIndex === 0) { 463 nextItem = this.refs.menuItems[this.refs.menuItems.length - 1]; 464 } else { 465 nextItem = this.refs.menuItems[currentIndex - 1]; 466 } 467 468 currentItem.setAttribute('tabindex', -1); 469 nextItem.setAttribute('tabindex', 0); 470 nextItem.focus(); 471 this.refs.menu.setAttribute('aria-activedescendant', nextItem.id); 472 } 473 }]); 474 475 return MenuButton; 476}(); 477 478/* harmony default export */ __webpack_exports__["default"] = (MenuButton); 479 480/***/ }), 481
482/***/ "../../../../plugins/upup-baseline-plugin/js/src/navigation-button/navigation-button.js": 483/*!*************************************************************************************************************************************************!*\ 484 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/plugins/upup-baseline-plugin/js/src/navigation-button/navigation-button.js ***! 485 \*************************************************************************************************************************************************/ 486/*! exports provided: default */ 487/***/ (function(module, __webpack_exports__, __webpack_require__) { 488 489"use strict"; 490__webpack_require__.r(__webpack_exports__); 491/* harmony import */ var _menu_button_menu_button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../menu-button/menu-button */ "../../../../plugins/upup-baseline-plugin/js/src/menu-button/menu-button.js"); 492function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 493 494 495/** 496 * find and set up navigation buttons 497 */ 498 499var NavigationButtonManager = function NavigationButtonManager() { 500 _classCallCheck(this, NavigationButtonManager); 501 502 var navButtons = Array.from(document.querySelectorAll('.navigation-button')); 503 navButtons.forEach(function (buttonContainer) { 504 new NavigationButton(buttonContainer); 505 }); 506}; 507/** 508 * manage one navigation button instance 509 * handle mouse and keyboard interactions 510 */ 511 512 513var NavigationButton = function NavigationButton(buttonContainer) { 514 _classCallCheck(this, NavigationButton); 515 516 var button = buttonContainer.querySelector('.navigation-button__button'), 517 menu = buttonContainer.querySelector('.navigation-button__menu'); // these are set up as menu buttons 518 519 if (button && menu) { 520 new _menu_button_menu_button__WEBPACK_IMPORTED_MODULE_0__["default"](button, menu); 521 } 522}; 523 524/* harmony default export */ __webpack_exports__["default"] = (NavigationButtonManager); 525 526/***/ }), 527
528/***/ "../../../../plugins/upup-baseline-plugin/js/src/utility.js": 529/*!*********************************************************************************************************************!*\ 530 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/plugins/upup-baseline-plugin/js/src/utility.js ***! 531 \*********************************************************************************************************************/ 532/*! exports provided: setPageHeight, setHeaderHeight, trackHeaderBottom, closestPolyfill, debounce, throttle, containScroll, eventFromInside, getEventPath, preventClickOnDrag, css, getAttributeStyles, merge, manageClipboardLinks, copyToClipboard */ 533/***/ (function(module, __webpack_exports__, __webpack_require__) { 534 535"use strict"; 536__webpack_require__.r(__webpack_exports__); 537/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setPageHeight", function() { return setPageHeight; }); 538/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setHeaderHeight", function() { return setHeaderHeight; }); 539/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trackHeaderBottom", function() { return trackHeaderBottom; }); 540/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "closestPolyfill", function() { return closestPolyfill; }); 541/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return debounce; }); 542/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return throttle; }); 543/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "containScroll", function() { return containScroll; }); 544/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eventFromInside", function() { return eventFromInside; }); 545/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getEventPath", function() { return getEventPath; }); 546/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "preventClickOnDrag", function() { return preventClickOnDrag; }); 547/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "css", function() { return css; }); 548/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAttributeStyles", function() { return getAttributeStyles; }); 549/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return merge; }); 550/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "manageClipboardLinks", function() { return manageClipboardLinks; }); 551/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return copyToClipboard; }); 552function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 553 554function setPageHeight() { 555 var vh = window.innerHeight * 0.01; // Then we set the value in the --vh custom property to the root of the document 556 557 document.documentElement.style.setProperty('--vh', vh + 'px'); 558} 559/** 560 * Set a variable to reflect the height of the header 561 */ 562 563function setHeaderHeight() { 564 var header = document.getElementById('site-header'), 565 headerHeight = header.offsetHeight, 566 originalHeight = header.dataset.originalHeight; 567 568 if (originalHeight) { 569 headerHeight = originalHeight; 570 } 571 572 document.documentElement.style.setProperty('--headerHeight', headerHeight + 'px'); 573} 574/** 575 * Track the bottom of the header offset from the window 576 */ 577 578function trackHeaderBottom() { 579 var header = document.getElementById('site-header'), 580 headerWrap = header.querySelector('.site-header__wrap'), 581 headerHeight = 0, 582 headerOffset = null, 583 headerBottom; 584 585 if (headerWrap) { 586 headerHeight = headerWrap.offsetHeight; 587 headerOffset = headerWrap.getBoundingClientRect(); 588 } else { 589 headerHeight = header.offsetHeight; 590 headerOffset = header.getBoundingClientRect(); 591 } 592 593 headerBottom = headerOffset.top + headerHeight; 594 document.documentElement.style.setProperty('--headerBottom', headerBottom + 'px'); 595} 596function closestPolyfill() { 597 if (!Element.prototype.matches) { 598 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 599 } 600 601 if (!Element.prototype.closest) { 602 Element.prototype.closest = function (s) { 603 var el = this; 604 605 do { 606 if (el.matches(s)) return el; 607 el = el.parentElement || el.parentNode; 608 } while (el !== null && el.nodeType === 1); 609 610 return null; 611 }; 612 } 613} 614function debounce(callback, threshold, execAsap) { 615 var timeout; 616 return function () { 617 var obj = this, 618 args = arguments; 619 620 function delayed() { 621 if (!execAsap) callback.apply(obj, args); 622 clearTimeout(timeout); 623 timeout = null; 624 } 625 626 if (timeout) clearTimeout(timeout);else if (execAsap) callback.apply(obj, args); 627 timeout = setTimeout(delayed, threshold || 100); 628 }; 629} 630function throttle(callback) { 631 var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100; 632 var fire_last = arguments.length > 2 ? arguments[2] : undefined; 633 var last = Date.now(), 634 timeout = null; 635 return function () { 636 var obj = this, 637 args = arguments, 638 now = Date.now(); 639 640 function delayed() { 641 callback.apply(obj, args); 642 timeout = null; 643 } //this event is new enough 644 645 646 if (now - last > interval) { 647 callback.apply(obj, args); 648 last = now; //can be set up to call the callback one more time at the end of the throttle 649 650 if (fire_last) { 651 clearTimeout(timeout); 652 timeout = setTimeout(delayed, interval || 100); 653 } 654 } 655 }; 656} 657/** 658 * Handle scrolling issue on iOS where background can be scrolled while menu is open 659 * @param element 660 * @param screenSize 661 */ 662 663function containScroll(element) { 664 var screenSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 665 x: function x(w) { 666 return w > 0; 667 }, 668 y: function y(h) { 669 return h > 0; 670 } 671 }; 672 673 var initialClientY = null, 674 cancelIfAtBoundary = function cancelIfAtBoundary(deltaY, e) { 675 if (element.scrollHeight - element.scrollTop <= element.clientHeight && deltaY > 0 || element.scrollTop === 0 && deltaY < 0) { 676 e.preventDefault(); 677 } 678 }, 679 680 /** 681 * Check screen size constraints 682 * @param e 683 */ 684 isScreenCorrectSize = function isScreenCorrectSize() { 685 return screenSize.x(window.innerWidth) && screenSize.y(window.innerHeight); 686 }, 687 handleTouchStart = function handleTouchStart(e) { 688 if (!isScreenCorrectSize()) { 689 return false;
690 } 691 692 if (e.targetTouches.length === 1) { 693 // detect single touch 694 initialClientY = e.targetTouches[0].clientY; 695 } 696 }, 697 handleTouchMove = function handleTouchMove(e) { 698 if (!isScreenCorrectSize()) { 699 return false; 700 } 701 702 var deltaY = e.targetTouches[0].clientY - initialClientY; 703 704 if (e.targetTouches.length !== 1) { 705 return e; 706 } // invert delat Y here for same logic to work 707 708 709 cancelIfAtBoundary(-deltaY, e); 710 e.stopPropagation(); 711 e.stopImmediatePropagation(); 712 }, 713 handleWheel = function handleWheel(e) { 714 var deltaY = e.deltaY; 715 716 if (!isScreenCorrectSize()) { 717 return false; 718 } 719 720 cancelIfAtBoundary(deltaY, e); 721 e.stopPropagation(); 722 e.stopImmediatePropagation(); 723 }; 724 725 element.addEventListener('touchstart', handleTouchStart); 726 element.addEventListener('touchmove', handleTouchMove, { 727 passive: false 728 }); 729 element.addEventListener('wheel', handleWheel, { 730 passive: false 731 }); 732} 733/** 734 * Test to see if a bubbling event occurred inside an element 735 * @param event 736 * @param element 737 */ 738 739function eventFromInside(event, element) { 740 var path = Array.from(event.path) || getEventPath(element); 741 return path.some(function (node) { 742 return node === element; 743 }); 744} 745/** 746 * Get the path of the event up to a stopping point 747 * @param event 748 * @param stop_at_el - where to stop in the bubble path (defaults to body) 749 * @returns {Array} 750 */ 751 752function getEventPath(event, stop_at_el) { 753 var path = [], 754 node = event.target, 755 stop = stop_at_el || document.body; 756 757 while (node !== stop) { 758 path.push(node); 759 node = node.parentNode; 760 } 761 762 return path; 763} 764/** 765 * Prevent a click event on drag 766 */ 767 768function preventClickOnDrag(element) { 769 var downX = 0, 770 downY = 0; 771 772 function handleDown(e) { 773 downX = e.screenX; 774 downY = e.screenY; 775 } 776 777 function handleUp(e) { 778 var releaseX = e.screenX, 779 releaseY = e.screenY, 780 dist = Math.sqrt(Math.pow(releaseX - downX, 2) + Math.pow(releaseY - downY, 2)); 781 782 if (dist > 10) { 783 e.preventDefault(); 784 e.stopPropagation(); 785 } 786 } 787 788 element.addEventListener('mousedown', handleDown); 789 element.addEventListener('mouseup', handleUp); 790 element.addEventListener('click', handleUp); 791} 792/** 793 * Set the CSS style attribute of an element 794 * @param el - the element to manipulate 795 * @param props_to - the properties and values to set 796 */ 797 798function css(el, props_to) { 799 var styles = getAttributeStyles(el), 800 updated = merge(styles, props_to), 801 style_string = ''; 802 803 for (var prop in updated) { 804 if (updated[prop] === null || updated[prop] === '') continue; 805 style_string += prop + ':' + updated[prop] + '; '; 806 } 807 808 style_string = style_string.replace(/;\s?$/, ''); 809 el.setAttribute('style', style_string); 810} 811function getAttributeStyles(el) { 812 var string = el.getAttribute('style'), 813 pairs = string ? string.split(';') : [], 814 _tmp, 815 styles = {}; 816 817 if (pairs.length <= 0) return styles; 818 819 for (var i = 0, il = pairs.length; i < il; i++) { 820 _tmp = pairs[i].trim().split(/:(.+)?/); //split on first occuence 821 822 if (_tmp[0] == '') continue; 823 styles[_tmp[0].trim()] = _tmp[1].trim(); 824 } 825 826 return styles; 827} 828function merge(o1, o2, flat) { 829 var o3 = {}; 830 flat = flat === true; 831 832 for (var prop in o1) { 833 if (!o1.hasOwnProperty(prop)) continue; 834 o3[prop] = o1[prop]; 835 } 836 837 for (prop in o2) { 838 if (!o2.hasOwnProperty(prop)) continue; 839 840 if (_typeof(o2[prop]) == 'object' && _typeof(o3[prop]) == 'object') { 841 if (!flat) { 842 o3[prop] = merge(o3[prop], o2[prop]); 843 } else { 844 o3[prop] = o2[prop]; 845 } 846 } else { 847 o3[prop] = o2[prop]; 848 } 849 } 850 851 return o3; 852} 853/** 854 * Find and manage links/ buttons that allow text to be copied to the clipboard 855 */ 856 857function manageClipboardLinks() { 858 var clipboardLinks = document.querySelectorAll('.js-clipboard-copy'); 859 clipboardLinks.forEach(function (link) { 860 link.addEventListener('click', copyToClipboard); 861 }); 862} 863/** 864 * Copy some text to the clipboard 865 * The target needs to carry the specific text as a data attribute 866 */ 867 868function copyToClipboard(e) { 869 var target = e.target, 870 copyable = target.getAttribute('data-copy'); 871 872 if (!navigator || !navigator.clipboard) { 873 console.error("Could not copy - navigator object not available"); 874 return false;
875 } 876 877 navigator.clipboard.writeText(copyable).then(function () { 878 target.classList.add('copied'); 879 setTimeout(function () { 880 target.classList.remove('copied'); 881 }, 2000); 882 }); 883} 884 885/***/ }), 886
vendor: 207,379 bytes, lines 887-5672
887/***/ "../../../../plugins/upup-baseline-plugin/node_modules/velocity-animate/velocity.js": 888/*!*********************************************************************************************************************************************!*\ 889 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/plugins/upup-baseline-plugin/node_modules/velocity-animate/velocity.js ***! 890 \*********************************************************************************************************************************************/ 891/*! no static exports found */ 892/***/ (function(module, exports, __webpack_require__) { 893 894var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! VelocityJS.org (1.5.2). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ 895 896/************************* 897 Velocity jQuery Shim 898 *************************/ 899 900/*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ 901 902/* This file contains the jQuery functions that Velocity relies on, thereby removing Velocity's dependency on a full copy of jQuery, and allowing it to work in any environment. */ 903/* These shimmed functions are only used if jQuery isn't present. If both this shim and jQuery are loaded, Velocity defaults to jQuery proper. */ 904/* Browser support: Using this shim instead of jQuery proper removes support for IE8. */ 905 906(function(window) { 907 "use strict"; 908 /*************** 909 Setup 910 ***************/ 911 912 /* If jQuery is already loaded, there's no point in loading this shim. */ 913 if (window.jQuery) { 914 return; 915 } 916 917 /* jQuery base. */ 918 var $ = function(selector, context) { 919 return new $.fn.init(selector, context); 920 }; 921 922 /******************** 923 Private Methods 924 ********************/ 925 926 /* jQuery */ 927 $.isWindow = function(obj) { 928 /* jshint eqeqeq: false */ 929 return obj && obj === obj.window; 930 }; 931 932 /* jQuery */ 933 $.type = function(obj) { 934 if (!obj) { 935 return obj + ""; 936 } 937 938 return typeof obj === "object" || typeof obj === "function" ? 939 class2type[toString.call(obj)] || "object" : 940 typeof obj; 941 }; 942 943 /* jQuery */ 944 $.isArray = Array.isArray || function(obj) { 945 return $.type(obj) === "array"; 946 }; 947 948 /* jQuery */ 949 function isArraylike(obj) { 950 var length = obj.length, 951 type = $.type(obj); 952 953 if (type === "function" || $.isWindow(obj)) { 954 return false; 955 } 956 957 if (obj.nodeType === 1 && length) { 958 return true; 959 } 960 961 return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj; 962 } 963 964 /*************** 965 $ Methods 966 ***************/ 967 968 /* jQuery: Support removed for IE<9. */ 969 $.isPlainObject = function(obj) { 970 var key; 971 972 if (!obj || $.type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) { 973 return false; 974 } 975 976 try { 977 if (obj.constructor && 978 !hasOwn.call(obj, "constructor") && 979 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { 980 return false; 981 } 982 } catch (e) { 983 return false; 984 } 985 986 for (key in obj) { 987 } 988 989 return key === undefined || hasOwn.call(obj, key); 990 }; 991 992 /* jQuery */ 993 $.each = function(obj, callback, args) { 994 var value, 995 i = 0, 996 length = obj.length, 997 isArray = isArraylike(obj); 998 999 if (args) { 1000 if (isArray) { 1001 for (; i < length; i++) { 1002 value = callback.apply(obj[i], args); 1003 1004 if (value === false) { 1005 break; 1006 } 1007 } 1008 } else { 1009 for (i in obj) { 1010 if (!obj.hasOwnProperty(i)) { 1011 continue; 1012 } 1013 value = callback.apply(obj[i], args); 1014 1015 if (value === false) { 1016 break; 1017 } 1018 } 1019 } 1020 1021 } else { 1022 if (isArray) { 1023 for (; i < length; i++) { 1024 value = callback.call(obj[i], i, obj[i]); 1025 1026 if (value === false) { 1027 break; 1028 } 1029 } 1030 } else { 1031 for (i in obj) { 1032 if (!obj.hasOwnProperty(i)) { 1033 continue; 1034 } 1035 value = callback.call(obj[i], i, obj[i]); 1036 1037 if (value === false) { 1038 break; 1039 } 1040 } 1041 } 1042 } 1043 1044 return obj; 1045 }; 1046 1047 /* Custom */ 1048 $.data = function(node, key, value) { 1049 /* $.getData() */ 1050 if (value === undefined) { 1051 var getId = node[$.expando], 1052 store = getId && cache[getId]; 1053 1054 if (key === undefined) { 1055 return store; 1056 } else if (store) { 1057 if (key in store) { 1058 return store[key]; 1059 } 1060 } 1061 /* $.setData() */ 1062 } else if (key !== undefined) { 1063 var setId = node[$.expando] || (node[$.expando] = ++$.uuid); 1064 1065 cache[setId] = cache[setId] || {}; 1066 cache[setId][key] = value; 1067 1068 return value; 1069 } 1070 }; 1071 1072 /* Custom */ 1073 $.removeData = function(node, keys) { 1074 var id = node[$.expando], 1075 store = id && cache[id]; 1076 1077 if (store) { 1078 // Cleanup the entire store if no keys are provided. 1079 if (!keys) { 1080 delete cache[id]; 1081 } else { 1082 $.each(keys, function(_, key) { 1083 delete store[key]; 1084 }); 1085 } 1086 } 1087 }; 1088 1089 /* jQuery */ 1090 $.extend = function() { 1091 var src, copyIsArray, copy, name, options, clone, 1092 target = arguments[0] || {}, 1093 i = 1, 1094 length = arguments.length, 1095 deep = false; 1096 1097 if (typeof target === "boolean") { 1098 deep = target; 1099 1100 target = arguments[i] || {}; 1101 i++; 1102 } 1103 1104 if (typeof target !== "object" && $.type(target) !== "function") { 1105 target = {}; 1106 } 1107 1108 if (i === length) { 1109 target = this; 1110 i--; 1111 } 1112 1113 for (; i < length; i++) { 1114 if ((options = arguments[i])) { 1115 for (name in options) { 1116 if (!options.hasOwnProperty(name)) { 1117 continue; 1118 } 1119 src = target[name]; 1120 copy = options[name]; 1121 1122 if (target === copy) { 1123 continue; 1124 } 1125 1126 if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) { 1127 if (copyIsArray) { 1128 copyIsArray = false; 1129 clone = src && $.isArray(src) ? src : []; 1130 1131 } else { 1132 clone = src && $.isPlainObject(src) ? src : {}; 1133 } 1134 1135 target[name] = $.extend(deep, clone, copy); 1136 1137 } else if (copy !== undefined) { 1138 target[name] = copy; 1139 } 1140 } 1141 } 1142 } 1143 1144 return target; 1145 }; 1146 1147 /* jQuery 1.4.3 */ 1148 $.queue = function(elem, type, data) { 1149 function $makeArray(arr, results) { 1150 var ret = results || []; 1151 1152 if (arr) { 1153 if (isArraylike(Object(arr))) { 1154 /* $.merge */ 1155 (function(first, second) { 1156 var len = +second.length, 1157 j = 0, 1158 i = first.length; 1159 1160 while (j < len) { 1161 first[i++] = second[j++]; 1162 } 1163 1164 if (len !== len) { 1165 while (second[j] !== undefined) { 1166 first[i++] = second[j++]; 1167 } 1168 } 1169 1170 first.length = i; 1171 1172 return first; 1173 })(ret, typeof arr === "string" ? [arr] : arr); 1174 } else { 1175 [].push.call(ret, arr); 1176 } 1177 } 1178 1179 return ret; 1180 } 1181 1182 if (!elem) { 1183 return; 1184 } 1185 1186 type = (type || "fx") + "queue"; 1187 1188 var q = $.data(elem, type); 1189 1190 if (!data) { 1191 return q || []; 1192 } 1193 1194 if (!q || $.isArray(data)) { 1195 q = $.data(elem, type, $makeArray(data)); 1196 } else { 1197 q.push(data); 1198 } 1199 1200 return q; 1201 }; 1202 1203 /* jQuery 1.4.3 */ 1204 $.dequeue = function(elems, type) { 1205 /* Custom: Embed element iteration. */ 1206 $.each(elems.nodeType ? [elems] : elems, function(i, elem) { 1207 type = type || "fx"; 1208 1209 var queue = $.queue(elem, type), 1210 fn = queue.shift(); 1211 1212 if (fn === "inprogress") { 1213 fn = queue.shift(); 1214 } 1215 1216 if (fn) { 1217 if (type === "fx") { 1218 queue.unshift("inprogress"); 1219 } 1220 1221 fn.call(elem, function() { 1222 $.dequeue(elem, type); 1223 }); 1224 } 1225 }); 1226 }; 1227 1228 /****************** 1229 $.fn Methods 1230 ******************/ 1231 1232 /* jQuery */ 1233 $.fn = $.prototype = { 1234 init: function(selector) { 1235 /* Just return the element wrapped inside an array; don't proceed with the actual jQuery node wrapping process. */ 1236 if (selector.nodeType) { 1237 this[0] = selector; 1238 1239 return this; 1240 } else { 1241 throw new Error("Not a DOM node."); 1242 } 1243 }, 1244 offset: function() { 1245 /* jQuery altered code: Dropped disconnected DOM node checking. */ 1246 var box = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : {top: 0, left: 0}; 1247 1248 return { 1249 top: box.top + (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), 1250 left: box.left + (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) 1251 }; 1252 }, 1253 position: function() { 1254 /* jQuery */ 1255 function offsetParentFn(elem) { 1256 var offsetParent = elem.offsetParent; 1257 1258 while (offsetParent && (offsetParent.nodeName.toLowerCase() !== "html" && offsetParent.style && offsetParent.style.position.toLowerCase() === "static")) { 1259 offsetParent = offsetParent.offsetParent; 1260 } 1261 1262 return offsetParent || document; 1263 } 1264 1265 /* Zepto */ 1266 var elem = this[0], 1267 offsetParent = offsetParentFn(elem), 1268 offset = this.offset(), 1269 parentOffset = /^(?:body|html)$/i.test(offsetParent.nodeName) ? {top: 0, left: 0} : $(offsetParent).offset(); 1270 1271 offset.top -= parseFloat(elem.style.marginTop) || 0; 1272 offset.left -= parseFloat(elem.style.marginLeft) || 0; 1273 1274 if (offsetParent.style) { 1275 parentOffset.top += parseFloat(offsetParent.style.borderTopWidth) || 0; 1276 parentOffset.left += parseFloat(offsetParent.style.borderLeftWidth) || 0; 1277 } 1278 1279 return { 1280 top: offset.top - parentOffset.top, 1281 left: offset.left - parentOffset.left 1282 }; 1283 } 1284 }; 1285 1286 /********************** 1287 Private Variables 1288 **********************/ 1289 1290 /* For $.data() */ 1291 var cache = {}; 1292 $.expando = "velocity" + (new Date().getTime()); 1293 $.uuid = 0; 1294 1295 /* For $.queue() */ 1296 var class2type = {}, 1297 hasOwn = class2type.hasOwnProperty, 1298 toString = class2type.toString; 1299 1300 var types = "Boolean Number String Function Array Date RegExp Object Error".split(" "); 1301 for (var i = 0; i < types.length; i++) { 1302 class2type["[object " + types[i] + "]"] = types[i].toLowerCase(); 1303 } 1304 1305 /* Makes $(node) possible, without having to call init. */ 1306 $.fn.init.prototype = $.fn; 1307 1308 /* Globalize Velocity onto the window, and assign its Utilities property. */ 1309 window.Velocity = {Utilities: $}; 1310})(window); 1311 1312/****************** 1313 Velocity.js 1314 ******************/ 1315 1316(function(factory) { 1317 "use strict"; 1318 /* CommonJS module. */ 1319 if ( true && typeof module.exports === "object") { 1320 module.exports = factory(); 1321 /* AMD module. */ 1322 } else if (true) { 1323 !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), 1324 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? 1325 (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : 1326 __WEBPACK_AMD_DEFINE_FACTORY__), 1327 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 1328 /* Browser globals. */ 1329 } else {} 1330}(function() { 1331 "use strict"; 1332 return function(global, window, document, undefined) { 1333 1334 /*************** 1335 Summary 1336 ***************/ 1337 1338 /* 1339 - CSS: CSS stack that works independently from the rest of Velocity. 1340 - animate(): Core animation method that iterates over the targeted elements and queues the incoming call onto each element individually. 1341 - Pre-Queueing: Prepare the element for animation by instantiating its data cache and processing the call's options. 1342 - Queueing: The logic that runs once the call has reached its point of execution in the element's $.queue() stack. 1343 Most logic is placed here to avoid risking it becoming stale (if the element's properties have changed). 1344 - Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. 1345 - tick(): The single requestAnimationFrame loop responsible for tweening all in-progress calls. 1346 - completeCall(): Handles the cleanup process for each Velocity call. 1347 */ 1348 1349 /********************* 1350 Helper Functions 1351 *********************/ 1352 1353 /* IE detection. Gist: https://gist.github.com/julianshapiro/9098609 */ 1354 var IE = (function() { 1355 if (document.documentMode) { 1356 return document.documentMode; 1357 } else { 1358 for (var i = 7; i > 4; i--) { 1359 var div = document.createElement("div"); 1360 1361 div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->"; 1362 1363 if (div.getElementsByTagName("span").length) { 1364 div = null; 1365 1366 return i; 1367 } 1368 } 1369 } 1370 1371 return undefined; 1372 })(); 1373 1374 /* rAF shim. Gist: https://gist.github.com/julianshapiro/9497513 */ 1375 var rAFShim = (function() { 1376 var timeLast = 0; 1377 1378 return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { 1379 var timeCurrent = (new Date()).getTime(), 1380 timeDelta; 1381 1382 /* Dynamically set delay on a per-tick basis to match 60fps. */ 1383 /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671 */ 1384 timeDelta = Math.max(0, 16 - (timeCurrent - timeLast)); 1385 timeLast = timeCurrent + timeDelta; 1386 1387 return setTimeout(function() { 1388 callback(timeCurrent + timeDelta); 1389 }, timeDelta); 1390 }; 1391 })(); 1392 1393 var performance = (function() { 1394 var perf = window.performance || {}; 1395 1396 if (typeof perf.now !== "function") { 1397 var nowOffset = perf.timing && perf.timing.navigationStart ? perf.timing.navigationStart : (new Date()).getTime(); 1398 1399 perf.now = function() { 1400 return (new Date()).getTime() - nowOffset; 1401 }; 1402 } 1403 return perf; 1404 })(); 1405 1406 /* Array compacting. Copyright Lo-Dash. MIT License: https://github.com/lodash/lodash/blob/master/LICENSE.txt */ 1407 function compactSparseArray(array) { 1408 var index = -1, 1409 length = array ? array.length : 0, 1410 result = []; 1411 1412 while (++index < length) { 1413 var value = array[index]; 1414 1415 if (value) { 1416 result.push(value); 1417 } 1418 } 1419 1420 return result; 1421 } 1422 1423 /** 1424 * Shim for "fixing" IE's lack of support (IE < 9) for applying slice 1425 * on host objects like NamedNodeMap, NodeList, and HTMLCollection 1426 * (technically, since host objects have been implementation-dependent, 1427 * at least before ES2015, IE hasn't needed to work this way). 1428 * Also works on strings, fixes IE < 9 to allow an explicit undefined 1429 * for the 2nd argument (as in Firefox), and prevents errors when 1430 * called on other DOM objects. 1431 */ 1432 var _slice = (function() { 1433 var slice = Array.prototype.slice; 1434 1435 try { 1436 // Can't be used with DOM elements in IE < 9 1437 slice.call(document.documentElement); 1438 return slice; 1439 } catch (e) { // Fails in IE < 9 1440 1441 // This will work for genuine arrays, array-like objects, 1442 // NamedNodeMap (attributes, entities, notations), 1443 // NodeList (e.g., getElementsByTagName), HTMLCollection (e.g., childNodes), 1444 // and will not fail on other DOM objects (as do DOM elements in IE < 9) 1445 return function(begin, end) { 1446 var len = this.length; 1447 1448 if (typeof begin !== "number") { 1449 begin = 0; 1450 } 1451 // IE < 9 gets unhappy with an undefined end argument 1452 if (typeof end !== "number") { 1453 end = len; 1454 } 1455 // For native Array objects, we use the native slice function 1456 if (this.slice) { 1457 return slice.call(this, begin, end); 1458 } 1459 // For array like object we handle it ourselves. 1460 var i, 1461 cloned = [], 1462 // Handle negative value for "begin" 1463 start = (begin >= 0) ? begin : Math.max(0, len + begin), 1464 // Handle negative value for "end" 1465 upTo = end < 0 ? len + end : Math.min(end, len), 1466 // Actual expected size of the slice 1467 size = upTo - start; 1468 1469 if (size > 0) { 1470 cloned = new Array(size); 1471 if (this.charAt) { 1472 for (i = 0; i < size; i++) { 1473 cloned[i] = this.charAt(start + i); 1474 } 1475 } else { 1476 for (i = 0; i < size; i++) { 1477 cloned[i] = this[start + i]; 1478 } 1479 } 1480 } 1481 return cloned; 1482 }; 1483 } 1484 })(); 1485 1486 /* .indexOf doesn't exist in IE<9 */ 1487 var _inArray = (function() { 1488 if (Array.prototype.includes) { 1489 return function(arr, val) { 1490 return arr.includes(val); 1491 }; 1492 } 1493 if (Array.prototype.indexOf) { 1494 return function(arr, val) { 1495 return arr.indexOf(val) >= 0; 1496 }; 1497 } 1498 return function(arr, val) { 1499 for (var i = 0; i < arr.length; i++) { 1500 if (arr[i] === val) { 1501 return true; 1502 } 1503 } 1504 return false; 1505 }; 1506 }); 1507 1508 function sanitizeElements(elements) { 1509 /* Unwrap jQuery/Zepto objects. */ 1510 if (Type.isWrapped(elements)) { 1511 elements = _slice.call(elements); 1512 /* Wrap a single element in an array so that $.each() can iterate with the element instead of its node's children. */ 1513 } else if (Type.isNode(elements)) { 1514 elements = [elements]; 1515 } 1516 1517 return elements; 1518 } 1519 1520 var Type = { 1521 isNumber: function(variable) { 1522 return (typeof variable === "number"); 1523 }, 1524 isString: function(variable) { 1525 return (typeof variable === "string"); 1526 }, 1527 isArray: Array.isArray || function(variable) { 1528 return Object.prototype.toString.call(variable) === "[object Array]"; 1529 }, 1530 isFunction: function(variable) { 1531 return Object.prototype.toString.call(variable) === "[object Function]"; 1532 }, 1533 isNode: function(variable) { 1534 return variable && variable.nodeType; 1535 }, 1536 /* Determine if variable is an array-like wrapped jQuery, Zepto or similar element, or even a NodeList etc. */ 1537 /* NOTE: HTMLFormElements also have a length. */ 1538 isWrapped: function(variable) { 1539 return variable 1540 && variable !== window 1541 && Type.isNumber(variable.length) 1542 && !Type.isString(variable) 1543 && !Type.isFunction(variable) 1544 && !Type.isNode(variable) 1545 && (variable.length === 0 || Type.isNode(variable[0])); 1546 }, 1547 isSVG: function(variable) { 1548 return window.SVGElement && (variable instanceof window.SVGElement); 1549 }, 1550 isEmptyObject: function(variable) { 1551 for (var name in variable) { 1552 if (variable.hasOwnProperty(name)) { 1553 return false; 1554 } 1555 } 1556 1557 return true; 1558 } 1559 }; 1560 1561 /***************** 1562 Dependencies 1563 *****************/ 1564 1565 var $, 1566 isJQuery = false; 1567 1568 if (global.fn && global.fn.jquery) { 1569 $ = global; 1570 isJQuery = true; 1571 } else { 1572 $ = window.Velocity.Utilities; 1573 } 1574 1575 if (IE <= 8 && !isJQuery) { 1576 throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity."); 1577 } else if (IE <= 7) { 1578 /* Revert to jQuery's $.animate(), and lose Velocity's extra features. */ 1579 jQuery.fn.velocity = jQuery.fn.animate; 1580 1581 /* Now that $.fn.velocity is aliased, abort this Velocity declaration. */ 1582 return; 1583 } 1584 1585 /***************** 1586 Constants 1587 *****************/ 1588 1589 var DURATION_DEFAULT = 400, 1590 EASING_DEFAULT = "swing"; 1591 1592 /************* 1593 State 1594 *************/ 1595 1596 var Velocity = { 1597 /* Container for page-wide Velocity state data. */ 1598 State: { 1599 /* Detect mobile devices to determine if mobileHA should be turned on. */ 1600 isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent), 1601 /* The mobileHA option's behavior changes on older Android devices (Gingerbread, versions 2.3.3-2.3.7). */ 1602 isAndroid: /Android/i.test(window.navigator.userAgent), 1603 isGingerbread: /Android 2\.3\.[3-7]/i.test(window.navigator.userAgent), 1604 isChrome: window.chrome, 1605 isFirefox: /Firefox/i.test(window.navigator.userAgent), 1606 /* Create a cached element for re-use when checking for CSS property prefixes. */ 1607 prefixElement: document.createElement("div"), 1608 /* Cache every prefix match to avoid repeating lookups. */ 1609 prefixMatches: {}, 1610 /* Cache the anchor used for animating window scrolling. */ 1611 scrollAnchor: null, 1612 /* Cache the browser-specific property names associated with the scroll anchor. */ 1613 scrollPropertyLeft: null, 1614 scrollPropertyTop: null, 1615 /* Keep track of whether our RAF tick is running. */ 1616 isTicking: false, 1617 /* Container for every in-progress call to Velocity. */ 1618 calls: [], 1619 delayedElements: { 1620 count: 0 1621 } 1622 }, 1623 /* Velocity's custom CSS stack. Made global for unit testing. */ 1624 CSS: {/* Defined below. */}, 1625 /* A shim of the jQuery utility functions used by Velocity -- provided by Velocity's optional jQuery shim. */ 1626 Utilities: $, 1627 /* Container for the user's custom animation redirects that are referenced by name in place of the properties map argument. */ 1628 Redirects: {/* Manually registered by the user. */}, 1629 Easings: {/* Defined below. */}, 1630 /* Attempt to use ES6 Promises by default. Users can override this with a third-party promises library. */ 1631 Promise: window.Promise, 1632 /* Velocity option defaults, which can be overriden by the user. */ 1633 defaults: { 1634 queue: "", 1635 duration: DURATION_DEFAULT, 1636 easing: EASING_DEFAULT, 1637 begin: undefined, 1638 complete: undefined, 1639 progress: undefined, 1640 display: undefined, 1641 visibility: undefined, 1642 loop: false, 1643 delay: false, 1644 mobileHA: true, 1645 /* Advanced: Set to false to prevent property values from being cached between consecutive Velocity-initiated chain calls. */ 1646 _cacheValues: true, 1647 /* Advanced: Set to false if the promise should always resolve on empty element lists. */ 1648 promiseRejectEmpty: true 1649 }, 1650 /* A design goal of Velocity is to cache data wherever possible in order to avoid DOM requerying. Accordingly, each element has a data cache. */ 1651 init: function(element) { 1652 $.data(element, "velocity", { 1653 /* Store whether this is an SVG element, since its properties are retrieved and updated differently than standard HTML elements. */ 1654 isSVG: Type.isSVG(element), 1655 /* Keep track of whether the element is currently being animated by Velocity. 1656 This is used to ensure that property values are not transferred between non-consecutive (stale) calls. */ 1657 isAnimating: false, 1658 /* A reference to the element's live computedStyle object. Learn more here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ 1659 computedStyle: null, 1660 /* Tween data is cached for each animation on the element so that data can be passed across calls -- 1661 in particular, end values are used as subsequent start values in consecutive Velocity calls. */ 1662 tweensContainer: null, 1663 /* The full root property values of each CSS hook being animated on this element are cached so that: 1664 1) Concurrently-animating hooks sharing the same root can have their root values' merged into one while tweening. 1665 2) Post-hook-injection root values can be transferred over to consecutively chained Velocity calls as starting root values. */ 1666 rootPropertyValueCache: {}, 1667 /* A cache for transform updates, which must be manually flushed via CSS.flushTransformCache(). */ 1668 transformCache: {} 1669 }); 1670 }, 1671 /* A parallel to jQuery's $.css(), used for getting/setting Velocity's hooked CSS properties. */ 1672 hook: null, /* Defined below. */ 1673 /* Velocity-wide animation time remapping for testing purposes. */ 1674 mock: false, 1675 version: {major: 1, minor: 5, patch: 2}, 1676 /* Set to 1 or 2 (most verbose) to output debug info to console. */ 1677 debug: false, 1678 /* Use rAF high resolution timestamp when available */ 1679 timestamp: true, 1680 /* Pause all animations */ 1681 pauseAll: function(queueName) { 1682 var currentTime = (new Date()).getTime(); 1683 1684 $.each(Velocity.State.calls, function(i, activeCall) { 1685 1686 if (activeCall) { 1687 1688 /* If we have a queueName and this call is not on that queue, skip */ 1689 if (queueName !== undefined && ((activeCall[2].queue !== queueName) || (activeCall[2].queue === false))) { 1690 return true; 1691 } 1692 1693 /* Set call to paused */ 1694 activeCall[5] = { 1695 resume: false 1696 }; 1697 } 1698 }); 1699 1700 /* Pause timers on any currently delayed calls */ 1701 $.each(Velocity.State.delayedElements, function(k, element) { 1702 if (!element) { 1703 return; 1704 } 1705 pauseDelayOnElement(element, currentTime); 1706 }); 1707 }, 1708 /* Resume all animations */ 1709 resumeAll: function(queueName) { 1710 var currentTime = (new Date()).getTime(); 1711 1712 $.each(Velocity.State.calls, function(i, activeCall) { 1713 1714 if (activeCall) { 1715 1716 /* If we have a queueName and this call is not on that queue, skip */ 1717 if (queueName !== undefined && ((activeCall[2].queue !== queueName) || (activeCall[2].queue === false))) { 1718 return true; 1719 } 1720 1721 /* Set call to resumed if it was paused */ 1722 if (activeCall[5]) { 1723 activeCall[5].resume = true; 1724 } 1725 } 1726 }); 1727 /* Resume timers on any currently delayed calls */ 1728 $.each(Velocity.State.delayedElements, function(k, element) { 1729 if (!element) { 1730 return; 1731 } 1732 resumeDelayOnElement(element, currentTime); 1733 }); 1734 } 1735 }; 1736 1737 /* Retrieve the appropriate scroll anchor and property name for the browser: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY */ 1738 if (window.pageYOffset !== undefined) { 1739 Velocity.State.scrollAnchor = window; 1740 Velocity.State.scrollPropertyLeft = "pageXOffset"; 1741 Velocity.State.scrollPropertyTop = "pageYOffset"; 1742 } else { 1743 Velocity.State.scrollAnchor = document.documentElement || document.body.parentNode || document.body; 1744 Velocity.State.scrollPropertyLeft = "scrollLeft"; 1745 Velocity.State.scrollPropertyTop = "scrollTop"; 1746 } 1747 1748 /* Shorthand alias for jQuery's $.data() utility. */ 1749 function Data(element) { 1750 /* Hardcode a reference to the plugin name. */ 1751 var response = $.data(element, "velocity"); 1752 1753 /* jQuery <=1.4.2 returns null instead of undefined when no match is found. We normalize this behavior. */ 1754 return response === null ? undefined : response; 1755 } 1756 1757 /************** 1758 Delay Timer 1759 **************/ 1760 1761 function pauseDelayOnElement(element, currentTime) { 1762 /* Check for any delay timers, and pause the set timeouts (while preserving time data) 1763 to be resumed when the "resume" command is issued */ 1764 var data = Data(element); 1765 if (data && data.delayTimer && !data.delayPaused) { 1766 data.delayRemaining = data.delay - currentTime + data.delayBegin; 1767 data.delayPaused = true; 1768 clearTimeout(data.delayTimer.setTimeout); 1769 } 1770 } 1771 1772 function resumeDelayOnElement(element, currentTime) { 1773 /* Check for any paused timers and resume */ 1774 var data = Data(element); 1775 if (data && data.delayTimer && data.delayPaused) { 1776 /* If the element was mid-delay, re initiate the timeout with the remaining delay */ 1777 data.delayPaused = false; 1778 data.delayTimer.setTimeout = setTimeout(data.delayTimer.next, data.delayRemaining); 1779 } 1780 } 1781 1782 1783 1784 /************** 1785 Easing 1786 **************/ 1787 1788 /* Step easing generator. */ 1789 function generateStep(steps) { 1790 return function(p) { 1791 return Math.round(p * steps) * (1 / steps); 1792 }; 1793 } 1794 1795 /* Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ 1796 function generateBezier(mX1, mY1, mX2, mY2) { 1797 var NEWTON_ITERATIONS = 4, 1798 NEWTON_MIN_SLOPE = 0.001, 1799 SUBDIVISION_PRECISION = 0.0000001, 1800 SUBDIVISION_MAX_ITERATIONS = 10, 1801 kSplineTableSize = 11, 1802 kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), 1803 float32ArraySupported = "Float32Array" in window; 1804 1805 /* Must contain four arguments. */ 1806 if (arguments.length !== 4) { 1807 return false; 1808 } 1809 1810 /* Arguments must be numbers. */ 1811 for (var i = 0; i < 4; ++i) { 1812 if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { 1813 return false; 1814 } 1815 } 1816 1817 /* X values must be in the [0, 1] range. */ 1818 mX1 = Math.min(mX1, 1); 1819 mX2 = Math.min(mX2, 1); 1820 mX1 = Math.max(mX1, 0); 1821 mX2 = Math.max(mX2, 0); 1822 1823 var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); 1824 1825 function A(aA1, aA2) { 1826 return 1.0 - 3.0 * aA2 + 3.0 * aA1; 1827 } 1828 function B(aA1, aA2) { 1829 return 3.0 * aA2 - 6.0 * aA1; 1830 } 1831 function C(aA1) { 1832 return 3.0 * aA1; 1833 } 1834 1835 function calcBezier(aT, aA1, aA2) { 1836 return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; 1837 } 1838 1839 function getSlope(aT, aA1, aA2) { 1840 return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); 1841 } 1842 1843 function newtonRaphsonIterate(aX, aGuessT) { 1844 for (var i = 0; i < NEWTON_ITERATIONS; ++i) { 1845 var currentSlope = getSlope(aGuessT, mX1, mX2); 1846 1847 if (currentSlope === 0.0) { 1848 return aGuessT; 1849 } 1850 1851 var currentX = calcBezier(aGuessT, mX1, mX2) - aX; 1852 aGuessT -= currentX / currentSlope; 1853 } 1854 1855 return aGuessT; 1856 } 1857 1858 function calcSampleValues() { 1859 for (var i = 0; i < kSplineTableSize; ++i) { 1860 mSampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2); 1861 } 1862 } 1863 1864 function binarySubdivide(aX, aA, aB) { 1865 var currentX, currentT, i = 0; 1866 1867 do { 1868 currentT = aA + (aB - aA) / 2.0; 1869 currentX = calcBezier(currentT, mX1, mX2) - aX; 1870 if (currentX > 0.0) { 1871 aB = currentT; 1872 } else { 1873 aA = currentT; 1874 } 1875 } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); 1876 1877 return currentT; 1878 } 1879 1880 function getTForX(aX) { 1881 var intervalStart = 0.0, 1882 currentSample = 1, 1883 lastSample = kSplineTableSize - 1; 1884 1885 for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { 1886 intervalStart += kSampleStepSize; 1887 } 1888 1889 --currentSample; 1890 1891 var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]), 1892 guessForT = intervalStart + dist * kSampleStepSize, 1893 initialSlope = getSlope(guessForT, mX1, mX2); 1894 1895 if (initialSlope >= NEWTON_MIN_SLOPE) { 1896 return newtonRaphsonIterate(aX, guessForT); 1897 } else if (initialSlope === 0.0) { 1898 return guessForT; 1899 } else { 1900 return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); 1901 } 1902 } 1903 1904 var _precomputed = false; 1905 1906 function precompute() { 1907 _precomputed = true; 1908 if (mX1 !== mY1 || mX2 !== mY2) { 1909 calcSampleValues(); 1910 } 1911 } 1912 1913 var f = function(aX) { 1914 if (!_precomputed) { 1915 precompute(); 1916 } 1917 if (mX1 === mY1 && mX2 === mY2) { 1918 return aX; 1919 } 1920 if (aX === 0) { 1921 return 0; 1922 } 1923 if (aX === 1) { 1924 return 1; 1925 } 1926 1927 return calcBezier(getTForX(aX), mY1, mY2); 1928 }; 1929 1930 f.getControlPoints = function() { 1931 return [{x: mX1, y: mY1}, {x: mX2, y: mY2}]; 1932 }; 1933 1934 var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; 1935 f.toString = function() { 1936 return str; 1937 }; 1938 1939 return f; 1940 } 1941 1942 /* Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ 1943 /* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass 1944 then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ 1945 var generateSpringRK4 = (function() { 1946 function springAccelerationForState(state) { 1947 return (-state.tension * state.x) - (state.friction * state.v); 1948 } 1949 1950 function springEvaluateStateWithDerivative(initialState, dt, derivative) { 1951 var state = { 1952 x: initialState.x + derivative.dx * dt, 1953 v: initialState.v + derivative.dv * dt, 1954 tension: initialState.tension, 1955 friction: initialState.friction 1956 }; 1957 1958 return {dx: state.v, dv: springAccelerationForState(state)}; 1959 } 1960 1961 function springIntegrateState(state, dt) { 1962 var a = { 1963 dx: state.v, 1964 dv: springAccelerationForState(state) 1965 }, 1966 b = springEvaluateStateWithDerivative(state, dt * 0.5, a), 1967 c = springEvaluateStateWithDerivative(state, dt * 0.5, b), 1968 d = springEvaluateStateWithDerivative(state, dt, c), 1969 dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), 1970 dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); 1971 1972 state.x = state.x + dxdt * dt; 1973 state.v = state.v + dvdt * dt; 1974 1975 return state; 1976 } 1977 1978 return function springRK4Factory(tension, friction, duration) { 1979 1980 var initState = { 1981 x: -1, 1982 v: 0, 1983 tension: null, 1984 friction: null 1985 }, 1986 path = [0], 1987 time_lapsed = 0, 1988 tolerance = 1 / 10000, 1989 DT = 16 / 1000, 1990 have_duration, dt, last_state; 1991 1992 tension = parseFloat(tension) || 500; 1993 friction = parseFloat(friction) || 20; 1994 duration = duration || null; 1995 1996 initState.tension = tension; 1997 initState.friction = friction; 1998 1999 have_duration = duration !== null; 2000 2001 /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ 2002 if (have_duration) { 2003 /* Run the simulation without a duration. */ 2004 time_lapsed = springRK4Factory(tension, friction); 2005 /* Compute the adjusted time delta. */ 2006 dt = time_lapsed / duration * DT; 2007 } else { 2008 dt = DT; 2009 } 2010 2011 while (true) { 2012 /* Next/step function .*/ 2013 last_state = springIntegrateState(last_state || initState, dt); 2014 /* Store the position. */ 2015 path.push(1 + last_state.x); 2016 time_lapsed += 16; 2017 /* If the change threshold is reached, break. */ 2018 if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { 2019 break; 2020 } 2021 } 2022 2023 /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the 2024 computed path and returns a snapshot of the position according to a given percentComplete. */ 2025 return !have_duration ? time_lapsed : function(percentComplete) { 2026 return path[ (percentComplete * (path.length - 1)) | 0 ]; 2027 }; 2028 }; 2029 }()); 2030 2031 /* jQuery easings. */ 2032 Velocity.Easings = { 2033 linear: function(p) { 2034 return p; 2035 }, 2036 swing: function(p) { 2037 return 0.5 - Math.cos(p * Math.PI) / 2; 2038 }, 2039 /* Bonus "spring" easing, which is a less exaggerated version of easeInOutElastic. */ 2040 spring: function(p) { 2041 return 1 - (Math.cos(p * 4.5 * Math.PI) * Math.exp(-p * 6)); 2042 } 2043 }; 2044 2045 /* CSS3 and Robert Penner easings. */ 2046 $.each( 2047 [ 2048 ["ease", [0.25, 0.1, 0.25, 1.0]], 2049 ["ease-in", [0.42, 0.0, 1.00, 1.0]], 2050 ["ease-out", [0.00, 0.0, 0.58, 1.0]], 2051 ["ease-in-out", [0.42, 0.0, 0.58, 1.0]], 2052 ["easeInSine", [0.47, 0, 0.745, 0.715]], 2053 ["easeOutSine", [0.39, 0.575, 0.565, 1]], 2054 ["easeInOutSine", [0.445, 0.05, 0.55, 0.95]], 2055 ["easeInQuad", [0.55, 0.085, 0.68, 0.53]], 2056 ["easeOutQuad", [0.25, 0.46, 0.45, 0.94]], 2057 ["easeInOutQuad", [0.455, 0.03, 0.515, 0.955]], 2058 ["easeInCubic", [0.55, 0.055, 0.675, 0.19]], 2059 ["easeOutCubic", [0.215, 0.61, 0.355, 1]], 2060 ["easeInOutCubic", [0.645, 0.045, 0.355, 1]], 2061 ["easeInQuart", [0.895, 0.03, 0.685, 0.22]], 2062 ["easeOutQuart", [0.165, 0.84, 0.44, 1]], 2063 ["easeInOutQuart", [0.77, 0, 0.175, 1]], 2064 ["easeInQuint", [0.755, 0.05, 0.855, 0.06]], 2065 ["easeOutQuint", [0.23, 1, 0.32, 1]], 2066 ["easeInOutQuint", [0.86, 0, 0.07, 1]], 2067 ["easeInExpo", [0.95, 0.05, 0.795, 0.035]], 2068 ["easeOutExpo", [0.19, 1, 0.22, 1]], 2069 ["easeInOutExpo", [1, 0, 0, 1]], 2070 ["easeInCirc", [0.6, 0.04, 0.98, 0.335]], 2071 ["easeOutCirc", [0.075, 0.82, 0.165, 1]], 2072 ["easeInOutCirc", [0.785, 0.135, 0.15, 0.86]] 2073 ], function(i, easingArray) { 2074 Velocity.Easings[easingArray[0]] = generateBezier.apply(null, easingArray[1]); 2075 }); 2076 2077 /* Determine the appropriate easing type given an easing input. */ 2078 function getEasing(value, duration) { 2079 var easing = value; 2080 2081 /* The easing option can either be a string that references a pre-registered easing, 2082 or it can be a two-/four-item array of integers to be converted into a bezier/spring function. */ 2083 if (Type.isString(value)) { 2084 /* Ensure that the easing has been assigned to jQuery's Velocity.Easings object. */ 2085 if (!Velocity.Easings[value]) { 2086 easing = false; 2087 } 2088 } else if (Type.isArray(value) && value.length === 1) { 2089 easing = generateStep.apply(null, value); 2090 } else if (Type.isArray(value) && value.length === 2) { 2091 /* springRK4 must be passed the animation's duration. */ 2092 /* Note: If the springRK4 array contains non-numbers, generateSpringRK4() returns an easing 2093 function generated with default tension and friction values. */ 2094 easing = generateSpringRK4.apply(null, value.concat([duration])); 2095 } else if (Type.isArray(value) && value.length === 4) { 2096 /* Note: If the bezier array contains non-numbers, generateBezier() returns false. */ 2097 easing = generateBezier.apply(null, value); 2098 } else { 2099 easing = false; 2100 } 2101 2102 /* Revert to the Velocity-wide default easing type, or fall back to "swing" (which is also jQuery's default) 2103 if the Velocity-wide default has been incorrectly modified. */ 2104 if (easing === false) { 2105 if (Velocity.Easings[Velocity.defaults.easing]) { 2106 easing = Velocity.defaults.easing; 2107 } else { 2108 easing = EASING_DEFAULT; 2109 } 2110 } 2111 2112 return easing; 2113 } 2114 2115 /***************** 2116 CSS Stack 2117 *****************/ 2118 2119 /* The CSS object is a highly condensed and performant CSS stack that fully replaces jQuery's. 2120 It handles the validation, getting, and setting of both standard CSS properties and CSS property hooks. */ 2121 /* Note: A "CSS" shorthand is aliased so that our code is easier to read. */ 2122 var CSS = Velocity.CSS = { 2123 /************* 2124 RegEx 2125 *************/ 2126 2127 RegEx: { 2128 isHex: /^#([A-f\d]{3}){1,2}$/i, 2129 /* Unwrap a property value's surrounding text, e.g. "rgba(4, 3, 2, 1)" ==> "4, 3, 2, 1" and "rect(4px 3px 2px 1px)" ==> "4px 3px 2px 1px". */ 2130 valueUnwrap: /^[A-z]+\((.*)\)$/i, 2131 wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, 2132 /* Split a multi-value property into an array of subvalues, e.g. "rgba(4, 3, 2, 1) 4px 3px 2px 1px" ==> [ "rgba(4, 3, 2, 1)", "4px", "3px", "2px", "1px" ]. */ 2133 valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/ig 2134 }, 2135 /************ 2136 Lists 2137 ************/ 2138 2139 Lists: { 2140 colors: ["fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor"], 2141 transformsBase: ["translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ"], 2142 transforms3D: ["transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY"], 2143 units: [ 2144 "%", // relative 2145 "em", "ex", "ch", "rem", // font relative 2146 "vw", "vh", "vmin", "vmax", // viewport relative 2147 "cm", "mm", "Q", "in", "pc", "pt", "px", // absolute lengths 2148 "deg", "grad", "rad", "turn", // angles 2149 "s", "ms" // time 2150 ], 2151 colorNames: { 2152 "aliceblue": "240,248,255", 2153 "antiquewhite": "250,235,215", 2154 "aquamarine": "127,255,212", 2155 "aqua": "0,255,255", 2156 "azure": "240,255,255", 2157 "beige": "245,245,220", 2158 "bisque": "255,228,196", 2159 "black": "0,0,0", 2160 "blanchedalmond": "255,235,205", 2161 "blueviolet": "138,43,226", 2162 "blue": "0,0,255", 2163 "brown": "165,42,42", 2164 "burlywood": "222,184,135", 2165 "cadetblue": "95,158,160", 2166 "chartreuse": "127,255,0", 2167 "chocolate": "210,105,30", 2168 "coral": "255,127,80", 2169 "cornflowerblue": "100,149,237", 2170 "cornsilk": "255,248,220", 2171 "crimson": "220,20,60", 2172 "cyan": "0,255,255", 2173 "darkblue": "0,0,139", 2174 "darkcyan": "0,139,139", 2175 "darkgoldenrod": "184,134,11", 2176 "darkgray": "169,169,169", 2177 "darkgrey": "169,169,169", 2178 "darkgreen": "0,100,0", 2179 "darkkhaki": "189,183,107", 2180 "darkmagenta": "139,0,139", 2181 "darkolivegreen": "85,107,47", 2182 "darkorange": "255,140,0", 2183 "darkorchid": "153,50,204", 2184 "darkred": "139,0,0", 2185 "darksalmon": "233,150,122", 2186 "darkseagreen": "143,188,143", 2187 "darkslateblue": "72,61,139", 2188 "darkslategray": "47,79,79", 2189 "darkturquoise": "0,206,209", 2190 "darkviolet": "148,0,211", 2191 "deeppink": "255,20,147", 2192 "deepskyblue": "0,191,255", 2193 "dimgray": "105,105,105", 2194 "dimgrey": "105,105,105", 2195 "dodgerblue": "30,144,255", 2196 "firebrick": "178,34,34", 2197 "floralwhite": "255,250,240", 2198 "forestgreen": "34,139,34", 2199 "fuchsia": "255,0,255", 2200 "gainsboro": "220,220,220", 2201 "ghostwhite": "248,248,255", 2202 "gold": "255,215,0", 2203 "goldenrod": "218,165,32", 2204 "gray": "128,128,128", 2205 "grey": "128,128,128", 2206 "greenyellow": "173,255,47", 2207 "green": "0,128,0", 2208 "honeydew": "240,255,240", 2209 "hotpink": "255,105,180", 2210 "indianred": "205,92,92", 2211 "indigo": "75,0,130", 2212 "ivory": "255,255,240", 2213 "khaki": "240,230,140", 2214 "lavenderblush": "255,240,245", 2215 "lavender": "230,230,250", 2216 "lawngreen": "124,252,0", 2217 "lemonchiffon": "255,250,205", 2218 "lightblue": "173,216,230", 2219 "lightcoral": "240,128,128", 2220 "lightcyan": "224,255,255", 2221 "lightgoldenrodyellow": "250,250,210", 2222 "lightgray": "211,211,211", 2223 "lightgrey": "211,211,211", 2224 "lightgreen": "144,238,144", 2225 "lightpink": "255,182,193", 2226 "lightsalmon": "255,160,122", 2227 "lightseagreen": "32,178,170", 2228 "lightskyblue": "135,206,250", 2229 "lightslategray": "119,136,153", 2230 "lightsteelblue": "176,196,222", 2231 "lightyellow": "255,255,224", 2232 "limegreen": "50,205,50", 2233 "lime": "0,255,0", 2234 "linen": "250,240,230", 2235 "magenta": "255,0,255", 2236 "maroon": "128,0,0", 2237 "mediumaquamarine": "102,205,170", 2238 "mediumblue": "0,0,205", 2239 "mediumorchid": "186,85,211", 2240 "mediumpurple": "147,112,219", 2241 "mediumseagreen": "60,179,113", 2242 "mediumslateblue": "123,104,238", 2243 "mediumspringgreen": "0,250,154", 2244 "mediumturquoise": "72,209,204", 2245 "mediumvioletred": "199,21,133", 2246 "midnightblue": "25,25,112", 2247 "mintcream": "245,255,250", 2248 "mistyrose": "255,228,225", 2249 "moccasin": "255,228,181", 2250 "navajowhite": "255,222,173", 2251 "navy": "0,0,128", 2252 "oldlace": "253,245,230", 2253 "olivedrab": "107,142,35", 2254 "olive": "128,128,0", 2255 "orangered": "255,69,0", 2256 "orange": "255,165,0", 2257 "orchid": "218,112,214", 2258 "palegoldenrod": "238,232,170", 2259 "palegreen": "152,251,152", 2260 "paleturquoise": "175,238,238", 2261 "palevioletred": "219,112,147", 2262 "papayawhip": "255,239,213", 2263 "peachpuff": "255,218,185", 2264 "peru": "205,133,63", 2265 "pink": "255,192,203", 2266 "plum": "221,160,221", 2267 "powderblue": "176,224,230", 2268 "purple": "128,0,128", 2269 "red": "255,0,0", 2270 "rosybrown": "188,143,143", 2271 "royalblue": "65,105,225", 2272 "saddlebrown": "139,69,19", 2273 "salmon": "250,128,114", 2274 "sandybrown": "244,164,96", 2275 "seagreen": "46,139,87", 2276 "seashell": "255,245,238", 2277 "sienna": "160,82,45", 2278 "silver": "192,192,192", 2279 "skyblue": "135,206,235", 2280 "slateblue": "106,90,205", 2281 "slategray": "112,128,144", 2282 "snow": "255,250,250", 2283 "springgreen": "0,255,127", 2284 "steelblue": "70,130,180", 2285 "tan": "210,180,140", 2286 "teal": "0,128,128", 2287 "thistle": "216,191,216", 2288 "tomato": "255,99,71", 2289 "turquoise": "64,224,208", 2290 "violet": "238,130,238", 2291 "wheat": "245,222,179", 2292 "whitesmoke": "245,245,245", 2293 "white": "255,255,255", 2294 "yellowgreen": "154,205,50", 2295 "yellow": "255,255,0" 2296 } 2297 }, 2298 /************ 2299 Hooks 2300 ************/ 2301 2302 /* Hooks allow a subproperty (e.g. "boxShadowBlur") of a compound-value CSS property 2303 (e.g. "boxShadow: X Y Blur Spread Color") to be animated as if it were a discrete property. */ 2304 /* Note: Beyond enabling fine-grained property animation, hooking is necessary since Velocity only 2305 tweens properties with single numeric values; unlike CSS transitions, Velocity does not interpolate compound-values. */ 2306 Hooks: { 2307 /******************** 2308 Registration 2309 ********************/ 2310 2311 /* Templates are a concise way of indicating which subproperties must be individually registered for each compound-value CSS property. */ 2312 /* Each template consists of the compound-value's base name, its constituent subproperty names, and those subproperties' default values. */ 2313 templates: { 2314 "textShadow": ["Color X Y Blur", "black 0px 0px 0px"], 2315 "boxShadow": ["Color X Y Blur Spread", "black 0px 0px 0px 0px"], 2316 "clip": ["Top Right Bottom Left", "0px 0px 0px 0px"], 2317 "backgroundPosition": ["X Y", "0% 0%"], 2318 "transformOrigin": ["X Y Z", "50% 50% 0px"], 2319 "perspectiveOrigin": ["X Y", "50% 50%"] 2320 }, 2321 /* A "registered" hook is one that has been converted from its template form into a live, 2322 tweenable property. It contains data to associate it with its root property. */ 2323 registered: { 2324 /* Note: A registered hook looks like this ==> textShadowBlur: [ "textShadow", 3 ], 2325 which consists of the subproperty's name, the associated root property's name, 2326 and the subproperty's position in the root's value. */ 2327 }, 2328 /* Convert the templates into individual hooks then append them to the registered object above. */ 2329 register: function() { 2330 /* Color hooks registration: Colors are defaulted to white -- as opposed to black -- since colors that are 2331 currently set to "transparent" default to their respective template below when color-animated, 2332 and white is typically a closer match to transparent than black is. An exception is made for text ("color"), 2333 which is almost always set closer to black than white. */ 2334 for (var i = 0; i < CSS.Lists.colors.length; i++) { 2335 var rgbComponents = (CSS.Lists.colors[i] === "color") ? "0 0 0 1" : "255 255 255 1"; 2336 CSS.Hooks.templates[CSS.Lists.colors[i]] = ["Red Green Blue Alpha", rgbComponents]; 2337 } 2338 2339 var rootProperty, 2340 hookTemplate, 2341 hookNames; 2342 2343 /* In IE, color values inside compound-value properties are positioned at the end the value instead of at the beginning. 2344 Thus, we re-arrange the templates accordingly. */ 2345 if (IE) { 2346 for (rootProperty in CSS.Hooks.templates) { 2347 if (!CSS.Hooks.templates.hasOwnProperty(rootProperty)) { 2348 continue; 2349 } 2350 hookTemplate = CSS.Hooks.templates[rootProperty]; 2351 hookNames = hookTemplate[0].split(" "); 2352 2353 var defaultValues = hookTemplate[1].match(CSS.RegEx.valueSplit); 2354 2355 if (hookNames[0] === "Color") { 2356 /* Reposition both the hook's name and its default value to the end of their respective strings. */ 2357 hookNames.push(hookNames.shift()); 2358 defaultValues.push(defaultValues.shift()); 2359 2360 /* Replace the existing template for the hook's root property. */ 2361 CSS.Hooks.templates[rootProperty] = [hookNames.join(" "), defaultValues.join(" ")]; 2362 } 2363 } 2364 } 2365 2366 /* Hook registration. */ 2367 for (rootProperty in CSS.Hooks.templates) { 2368 if (!CSS.Hooks.templates.hasOwnProperty(rootProperty)) { 2369 continue; 2370 } 2371 hookTemplate = CSS.Hooks.templates[rootProperty]; 2372 hookNames = hookTemplate[0].split(" "); 2373 2374 for (var j in hookNames) { 2375 if (!hookNames.hasOwnProperty(j)) { 2376 continue; 2377 } 2378 var fullHookName = rootProperty + hookNames[j], 2379 hookPosition = j; 2380 2381 /* For each hook, register its full name (e.g. textShadowBlur) with its root property (e.g. textShadow) 2382 and the hook's position in its template's default value string. */ 2383 CSS.Hooks.registered[fullHookName] = [rootProperty, hookPosition]; 2384 } 2385 } 2386 }, 2387 /***************************** 2388 Injection and Extraction 2389 *****************************/ 2390 2391 /* Look up the root property associated with the hook (e.g. return "textShadow" for "textShadowBlur"). */ 2392 /* Since a hook cannot be set directly (the browser won't recognize it), style updating for hooks is routed through the hook's root property. */ 2393 getRoot: function(property) { 2394 var hookData = CSS.Hooks.registered[property]; 2395 2396 if (hookData) { 2397 return hookData[0]; 2398 } else { 2399 /* If there was no hook match, return the property name untouched. */ 2400 return property; 2401 } 2402 }, 2403 getUnit: function(str, start) { 2404 var unit = (str.substr(start || 0, 5).match(/^[a-z%]+/) || [])[0] || ""; 2405 2406 if (unit && _inArray(CSS.Lists.units, unit)) { 2407 return unit; 2408 } 2409 return ""; 2410 }, 2411 fixColors: function(str) { 2412 return str.replace(/(rgba?\(\s*)?(\b[a-z]+\b)/g, function($0, $1, $2) { 2413 if (CSS.Lists.colorNames.hasOwnProperty($2)) { 2414 return ($1 ? $1 : "rgba(") + CSS.Lists.colorNames[$2] + ($1 ? "" : ",1)"); 2415 } 2416 return $1 + $2; 2417 }); 2418 }, 2419 /* Convert any rootPropertyValue, null or otherwise, into a space-delimited list of hook values so that 2420 the targeted hook can be injected or extracted at its standard position. */ 2421 cleanRootPropertyValue: function(rootProperty, rootPropertyValue) { 2422 /* If the rootPropertyValue is wrapped with "rgb()", "clip()", etc., remove the wrapping to normalize the value before manipulation. */ 2423 if (CSS.RegEx.valueUnwrap.test(rootPropertyValue)) { 2424 rootPropertyValue = rootPropertyValue.match(CSS.RegEx.valueUnwrap)[1]; 2425 } 2426 2427 /* If rootPropertyValue is a CSS null-value (from which there's inherently no hook value to extract), 2428 default to the root's default value as defined in CSS.Hooks.templates. */ 2429 /* Note: CSS null-values include "none", "auto", and "transparent". They must be converted into their 2430 zero-values (e.g. textShadow: "none" ==> textShadow: "0px 0px 0px black") for hook manipulation to proceed. */ 2431 if (CSS.Values.isCSSNullValue(rootPropertyValue)) { 2432 rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; 2433 } 2434 2435 return rootPropertyValue; 2436 }, 2437 /* Extracted the hook's value from its root property's value. This is used to get the starting value of an animating hook. */ 2438 extractValue: function(fullHookName, rootPropertyValue) { 2439 var hookData = CSS.Hooks.registered[fullHookName]; 2440 2441 if (hookData) { 2442 var hookRoot = hookData[0], 2443 hookPosition = hookData[1]; 2444 2445 rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); 2446 2447 /* Split rootPropertyValue into its constituent hook values then grab the desired hook at its standard position. */ 2448 return rootPropertyValue.toString().match(CSS.RegEx.valueSplit)[hookPosition]; 2449 } else { 2450 /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ 2451 return rootPropertyValue; 2452 } 2453 }, 2454 /* Inject the hook's value into its root property's value. This is used to piece back together the root property 2455 once Velocity has updated one of its individually hooked values through tweening. */ 2456 injectValue: function(fullHookName, hookValue, rootPropertyValue) { 2457 var hookData = CSS.Hooks.registered[fullHookName]; 2458 2459 if (hookData) { 2460 var hookRoot = hookData[0], 2461 hookPosition = hookData[1], 2462 rootPropertyValueParts, 2463 rootPropertyValueUpdated; 2464 2465 rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); 2466 2467 /* Split rootPropertyValue into its individual hook values, replace the targeted value with hookValue, 2468 then reconstruct the rootPropertyValue string. */ 2469 rootPropertyValueParts = rootPropertyValue.toString().match(CSS.RegEx.valueSplit); 2470 rootPropertyValueParts[hookPosition] = hookValue; 2471 rootPropertyValueUpdated = rootPropertyValueParts.join(" "); 2472 2473 return rootPropertyValueUpdated; 2474 } else { 2475 /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ 2476 return rootPropertyValue; 2477 } 2478 } 2479 }, 2480 /******************* 2481 Normalizations 2482 *******************/ 2483 2484 /* Normalizations standardize CSS property manipulation by pollyfilling browser-specific implementations (e.g. opacity) 2485 and reformatting special properties (e.g. clip, rgba) to look like standard ones. */ 2486 Normalizations: { 2487 /* Normalizations are passed a normalization target (either the property's name, its extracted value, or its injected value), 2488 the targeted element (which may need to be queried), and the targeted property value. */ 2489 registered: { 2490 clip: function(type, element, propertyValue) { 2491 switch (type) { 2492 case "name": 2493 return "clip"; 2494 /* Clip needs to be unwrapped and stripped of its commas during extraction. */ 2495 case "extract": 2496 var extracted; 2497 2498 /* If Velocity also extracted this value, skip extraction. */ 2499 if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { 2500 extracted = propertyValue; 2501 } else { 2502 /* Remove the "rect()" wrapper. */ 2503 extracted = propertyValue.toString().match(CSS.RegEx.valueUnwrap); 2504 2505 /* Strip off commas. */ 2506 extracted = extracted ? extracted[1].replace(/,(\s+)?/g, " ") : propertyValue; 2507 } 2508 2509 return extracted; 2510 /* Clip needs to be re-wrapped during injection. */ 2511 case "inject": 2512 return "rect(" + propertyValue + ")"; 2513 } 2514 }, 2515 blur: function(type, element, propertyValue) { 2516 switch (type) { 2517 case "name": 2518 return Velocity.State.isFirefox ? "filter" : "-webkit-filter"; 2519 case "extract": 2520 var extracted = parseFloat(propertyValue); 2521 2522 /* If extracted is NaN, meaning the value isn't already extracted. */ 2523 if (!(extracted || extracted === 0)) { 2524 var blurComponent = propertyValue.toString().match(/blur\(([0-9]+[A-z]+)\)/i); 2525 2526 /* If the filter string had a blur component, return just the blur value and unit type. */ 2527 if (blurComponent) { 2528 extracted = blurComponent[1]; 2529 /* If the component doesn't exist, default blur to 0. */ 2530 } else { 2531 extracted = 0; 2532 } 2533 } 2534 2535 return extracted; 2536 /* Blur needs to be re-wrapped during injection. */ 2537 case "inject": 2538 /* For the blur effect to be fully de-applied, it needs to be set to "none" instead of 0. */ 2539 if (!parseFloat(propertyValue)) { 2540 return "none"; 2541 } else { 2542 return "blur(" + propertyValue + ")"; 2543 } 2544 } 2545 }, 2546 /* <=IE8 do not support the standard opacity property. They use filter:alpha(opacity=INT) instead. */ 2547 opacity: function(type, element, propertyValue) { 2548 if (IE <= 8) { 2549 switch (type) { 2550 case "name": 2551 return "filter"; 2552 case "extract": 2553 /* <=IE8 return a "filter" value of "alpha(opacity=\d{1,3})". 2554 Extract the value and convert it to a decimal value to match the standard CSS opacity property's formatting. */ 2555 var extracted = propertyValue.toString().match(/alpha\(opacity=(.*)\)/i); 2556 2557 if (extracted) { 2558 /* Convert to decimal value. */ 2559 propertyValue = extracted[1] / 100; 2560 } else { 2561 /* When extracting opacity, default to 1 since a null value means opacity hasn't been set. */ 2562 propertyValue = 1; 2563 } 2564 2565 return propertyValue; 2566 case "inject": 2567 /* Opacified elements are required to have their zoom property set to a non-zero value. */ 2568 element.style.zoom = 1; 2569 2570 /* Setting the filter property on elements with certain font property combinations can result in a 2571 highly unappealing ultra-bolding effect. There's no way to remedy this throughout a tween, but dropping the 2572 value altogether (when opacity hits 1) at leasts ensures that the glitch is gone post-tweening. */ 2573 if (parseFloat(propertyValue) >= 1) { 2574 return ""; 2575 } else { 2576 /* As per the filter property's spec, convert the decimal value to a whole number and wrap the value. */ 2577 return "alpha(opacity=" + parseInt(parseFloat(propertyValue) * 100, 10) + ")"; 2578 } 2579 } 2580 /* With all other browsers, normalization is not required; return the same values that were passed in. */ 2581 } else { 2582 switch (type) { 2583 case "name": 2584 return "opacity"; 2585 case "extract": 2586 return propertyValue; 2587 case "inject": 2588 return propertyValue; 2589 } 2590 } 2591 } 2592 }, 2593 /***************************** 2594 Batched Registrations 2595 *****************************/ 2596 2597 /* Note: Batched normalizations extend the CSS.Normalizations.registered object. */ 2598 register: function() { 2599 2600 /***************** 2601 Transforms 2602 *****************/ 2603 2604 /* Transforms are the subproperties contained by the CSS "transform" property. Transforms must undergo normalization 2605 so that they can be referenced in a properties map by their individual names. */ 2606 /* Note: When transforms are "set", they are actually assigned to a per-element transformCache. When all transform 2607 setting is complete complete, CSS.flushTransformCache() must be manually called to flush the values to the DOM. 2608 Transform setting is batched in this way to improve performance: the transform style only needs to be updated 2609 once when multiple transform subproperties are being animated simultaneously. */ 2610 /* Note: IE9 and Android Gingerbread have support for 2D -- but not 3D -- transforms. Since animating unsupported 2611 transform properties results in the browser ignoring the *entire* transform string, we prevent these 3D values 2612 from being normalized for these browsers so that tweening skips these properties altogether 2613 (since it will ignore them as being unsupported by the browser.) */ 2614 if ((!IE || IE > 9) && !Velocity.State.isGingerbread) { 2615 /* Note: Since the standalone CSS "perspective" property and the CSS transform "perspective" subproperty 2616 share the same name, the latter is given a unique token within Velocity: "transformPerspective". */ 2617 CSS.Lists.transformsBase = CSS.Lists.transformsBase.concat(CSS.Lists.transforms3D); 2618 } 2619 2620 for (var i = 0; i < CSS.Lists.transformsBase.length; i++) { 2621 /* Wrap the dynamically generated normalization function in a new scope so that transformName's value is 2622 paired with its respective function. (Otherwise, all functions would take the final for loop's transformName.) */ 2623 (function() { 2624 var transformName = CSS.Lists.transformsBase[i]; 2625 2626 CSS.Normalizations.registered[transformName] = function(type, element, propertyValue) { 2627 switch (type) { 2628 /* The normalized property name is the parent "transform" property -- the property that is actually set in CSS. */ 2629 case "name": 2630 return "transform"; 2631 /* Transform values are cached onto a per-element transformCache object. */ 2632 case "extract": 2633 /* If this transform has yet to be assigned a value, return its null value. */ 2634 if (Data(element) === undefined || Data(element).transformCache[transformName] === undefined) { 2635 /* Scale CSS.Lists.transformsBase default to 1 whereas all other transform properties default to 0. */ 2636 return /^scale/i.test(transformName) ? 1 : 0; 2637 /* When transform values are set, they are wrapped in parentheses as per the CSS spec. 2638 Thus, when extracting their values (for tween calculations), we strip off the parentheses. */ 2639 } 2640 return Data(element).transformCache[transformName].replace(/[()]/g, ""); 2641 case "inject": 2642 var invalid = false; 2643 2644 /* If an individual transform property contains an unsupported unit type, the browser ignores the *entire* transform property. 2645 Thus, protect users from themselves by skipping setting for transform values supplied with invalid unit types. */ 2646 /* Switch on the base transform type; ignore the axis by removing the last letter from the transform's name. */ 2647 switch (transformName.substr(0, transformName.length - 1)) { 2648 /* Whitelist unit types for each transform. */ 2649 case "translate": 2650 invalid = !/(%|px|em|rem|vw|vh|\d)$/i.test(propertyValue); 2651 break; 2652 /* Since an axis-free "scale" property is supported as well, a little hack is used here to detect it by chopping off its last letter. */ 2653 case "scal": 2654 case "scale": 2655 /* Chrome on Android has a bug in which scaled elements blur if their initial scale 2656 value is below 1 (which can happen with forcefeeding). Thus, we detect a yet-unset scale property 2657 and ensure that its first value is always 1. More info: http://stackoverflow.com/questions/10417890/css3-animations-with-transform-causes-blurred-elements-on-webkit/10417962#10417962 */ 2658 if (Velocity.State.isAndroid && Data(element).transformCache[transformName] === undefined && propertyValue < 1) { 2659 propertyValue = 1; 2660 } 2661 2662 invalid = !/(\d)$/i.test(propertyValue); 2663 break; 2664 case "skew": 2665 invalid = !/(deg|\d)$/i.test(propertyValue); 2666 break; 2667 case "rotate": 2668 invalid = !/(deg|\d)$/i.test(propertyValue); 2669 break; 2670 } 2671 2672 if (!invalid) { 2673 /* As per the CSS spec, wrap the value in parentheses. */ 2674 Data(element).transformCache[transformName] = "(" + propertyValue + ")"; 2675 } 2676 2677 /* Although the value is set on the transformCache object, return the newly-updated value for the calling code to process as normal. */ 2678 return Data(element).transformCache[transformName]; 2679 } 2680 }; 2681 })(); 2682 } 2683 2684 /************* 2685 Colors 2686 *************/ 2687 2688 /* Since Velocity only animates a single numeric value per property, color animation is achieved by hooking the individual RGBA components of CSS color properties. 2689 Accordingly, color values must be normalized (e.g. "#ff0000", "red", and "rgb(255, 0, 0)" ==> "255 0 0 1") so that their components can be injected/extracted by CSS.Hooks logic. */ 2690 for (var j = 0; j < CSS.Lists.colors.length; j++) { 2691 /* Wrap the dynamically generated normalization function in a new scope so that colorName's value is paired with its respective function. 2692 (Otherwise, all functions would take the final for loop's colorName.) */ 2693 (function() { 2694 var colorName = CSS.Lists.colors[j]; 2695 2696 /* Note: In IE<=8, which support rgb but not rgba, color properties are reverted to rgb by stripping off the alpha component. */ 2697 CSS.Normalizations.registered[colorName] = function(type, element, propertyValue) { 2698 switch (type) { 2699 case "name": 2700 return colorName; 2701 /* Convert all color values into the rgb format. (Old IE can return hex values and color names instead of rgb/rgba.) */ 2702 case "extract": 2703 var extracted; 2704 2705 /* If the color is already in its hookable form (e.g. "255 255 255 1") due to having been previously extracted, skip extraction. */ 2706 if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { 2707 extracted = propertyValue; 2708 } else { 2709 var converted, 2710 colorNames = { 2711 black: "rgb(0, 0, 0)", 2712 blue: "rgb(0, 0, 255)", 2713 gray: "rgb(128, 128, 128)", 2714 green: "rgb(0, 128, 0)", 2715 red: "rgb(255, 0, 0)", 2716 white: "rgb(255, 255, 255)" 2717 }; 2718 2719 /* Convert color names to rgb. */ 2720 if (/^[A-z]+$/i.test(propertyValue)) { 2721 if (colorNames[propertyValue] !== undefined) { 2722 converted = colorNames[propertyValue]; 2723 } else { 2724 /* If an unmatched color name is provided, default to black. */ 2725 converted = colorNames.black; 2726 } 2727 /* Convert hex values to rgb. */ 2728 } else if (CSS.RegEx.isHex.test(propertyValue)) { 2729 converted = "rgb(" + CSS.Values.hexToRgb(propertyValue).join(" ") + ")"; 2730 /* If the provided color doesn't match any of the accepted color formats, default to black. */ 2731 } else if (!(/^rgba?\(/i.test(propertyValue))) { 2732 converted = colorNames.black; 2733 } 2734 2735 /* Remove the surrounding "rgb/rgba()" string then replace commas with spaces and strip 2736 repeated spaces (in case the value included spaces to begin with). */ 2737 extracted = (converted || propertyValue).toString().match(CSS.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " "); 2738 } 2739 2740 /* So long as this isn't <=IE8, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ 2741 if ((!IE || IE > 8) && extracted.split(" ").length === 3) { 2742 extracted += " 1"; 2743 } 2744 2745 return extracted; 2746 case "inject": 2747 /* If we have a pattern then it might already have the right values */ 2748 if (/^rgb/.test(propertyValue)) { 2749 return propertyValue; 2750 } 2751 2752 /* If this is IE<=8 and an alpha component exists, strip it off. */ 2753 if (IE <= 8) { 2754 if (propertyValue.split(" ").length === 4) { 2755 propertyValue = propertyValue.split(/\s+/).slice(0, 3).join(" "); 2756 } 2757 /* Otherwise, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ 2758 } else if (propertyValue.split(" ").length === 3) { 2759 propertyValue += " 1"; 2760 } 2761 2762 /* Re-insert the browser-appropriate wrapper("rgb/rgba()"), insert commas, and strip off decimal units 2763 on all values but the fourth (R, G, and B only accept whole numbers). */ 2764 return (IE <= 8 ? "rgb" : "rgba") + "(" + propertyValue.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")"; 2765 } 2766 }; 2767 })(); 2768 } 2769 2770 /************** 2771 Dimensions 2772 **************/ 2773 function augmentDimension(name, element, wantInner) { 2774 var isBorderBox = CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() === "border-box"; 2775 2776 if (isBorderBox === (wantInner || false)) { 2777 /* in box-sizing mode, the CSS width / height accessors already give the outerWidth / outerHeight. */ 2778 var i, 2779 value, 2780 augment = 0, 2781 sides = name === "width" ? ["Left", "Right"] : ["Top", "Bottom"], 2782 fields = ["padding" + sides[0], "padding" + sides[1], "border" + sides[0] + "Width", "border" + sides[1] + "Width"]; 2783 2784 for (i = 0; i < fields.length; i++) { 2785 value = parseFloat(CSS.getPropertyValue(element, fields[i])); 2786 if (!isNaN(value)) { 2787 augment += value; 2788 } 2789 } 2790 return wantInner ? -augment : augment; 2791 } 2792 return 0; 2793 } 2794 function getDimension(name, wantInner) { 2795 return function(type, element, propertyValue) { 2796 switch (type) { 2797 case "name": 2798 return name; 2799 case "extract": 2800 return parseFloat(propertyValue) + augmentDimension(name, element, wantInner); 2801 case "inject": 2802 return (parseFloat(propertyValue) - augmentDimension(name, element, wantInner)) + "px"; 2803 } 2804 }; 2805 } 2806 CSS.Normalizations.registered.innerWidth = getDimension("width", true); 2807 CSS.Normalizations.registered.innerHeight = getDimension("height", true); 2808 CSS.Normalizations.registered.outerWidth = getDimension("width"); 2809 CSS.Normalizations.registered.outerHeight = getDimension("height"); 2810 } 2811 }, 2812 /************************ 2813 CSS Property Names 2814 ************************/ 2815 2816 Names: { 2817 /* Camelcase a property name into its JavaScript notation (e.g. "background-color" ==> "backgroundColor"). 2818 Camelcasing is used to normalize property names between and across calls. */ 2819 camelCase: function(property) { 2820 return property.replace(/-(\w)/g, function(match, subMatch) { 2821 return subMatch.toUpperCase(); 2822 }); 2823 }, 2824 /* For SVG elements, some properties (namely, dimensional ones) are GET/SET via the element's HTML attributes (instead of via CSS styles). */ 2825 SVGAttribute: function(property) { 2826 var SVGAttributes = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2"; 2827 2828 /* Certain browsers require an SVG transform to be applied as an attribute. (Otherwise, application via CSS is preferable due to 3D support.) */ 2829 if (IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) { 2830 SVGAttributes += "|transform"; 2831 } 2832 2833 return new RegExp("^(" + SVGAttributes + ")$", "i").test(property); 2834 }, 2835 /* Determine whether a property should be set with a vendor prefix. */ 2836 /* If a prefixed version of the property exists, return it. Otherwise, return the original property name. 2837 If the property is not at all supported by the browser, return a false flag. */ 2838 prefixCheck: function(property) { 2839 /* If this property has already been checked, return the cached value. */ 2840 if (Velocity.State.prefixMatches[property]) { 2841 return [Velocity.State.prefixMatches[property], true]; 2842 } else { 2843 var vendors = ["", "Webkit", "Moz", "ms", "O"]; 2844 2845 for (var i = 0, vendorsLength = vendors.length; i < vendorsLength; i++) { 2846 var propertyPrefixed; 2847 2848 if (i === 0) { 2849 propertyPrefixed = property; 2850 } else { 2851 /* Capitalize the first letter of the property to conform to JavaScript vendor prefix notation (e.g. webkitFilter). */ 2852 propertyPrefixed = vendors[i] + property.replace(/^\w/, function(match) { 2853 return match.toUpperCase(); 2854 }); 2855 } 2856 2857 /* Check if the browser supports this property as prefixed. */ 2858 if (Type.isString(Velocity.State.prefixElement.style[propertyPrefixed])) { 2859 /* Cache the match. */ 2860 Velocity.State.prefixMatches[property] = propertyPrefixed; 2861 2862 return [propertyPrefixed, true]; 2863 } 2864 } 2865 2866 /* If the browser doesn't support this property in any form, include a false flag so that the caller can decide how to proceed. */ 2867 return [property, false]; 2868 } 2869 } 2870 }, 2871 /************************ 2872 CSS Property Values 2873 ************************/ 2874 2875 Values: { 2876 /* Hex to RGB conversion. Copyright Tim Down: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb */ 2877 hexToRgb: function(hex) { 2878 var shortformRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, 2879 longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, 2880 rgbParts; 2881 2882 hex = hex.replace(shortformRegex, function(m, r, g, b) { 2883 return r + r + g + g + b + b; 2884 }); 2885 2886 rgbParts = longformRegex.exec(hex); 2887 2888 return rgbParts ? [parseInt(rgbParts[1], 16), parseInt(rgbParts[2], 16), parseInt(rgbParts[3], 16)] : [0, 0, 0]; 2889 }, 2890 isCSSNullValue: function(value) { 2891 /* The browser defaults CSS values that have not been set to either 0 or one of several possible null-value strings. 2892 Thus, we check for both falsiness and these special strings. */ 2893 /* Null-value checking is performed to default the special strings to 0 (for the sake of tweening) or their hook 2894 templates as defined as CSS.Hooks (for the sake of hook injection/extraction). */ 2895 /* Note: Chrome returns "rgba(0, 0, 0, 0)" for an undefined color whereas IE returns "transparent". */ 2896 return (!value || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(value)); 2897 }, 2898 /* Retrieve a property's default unit type. Used for assigning a unit type when one is not supplied by the user. */ 2899 getUnitType: function(property) { 2900 if (/^(rotate|skew)/i.test(property)) { 2901 return "deg"; 2902 } else if (/(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(property)) { 2903 /* The above properties are unitless. */ 2904 return ""; 2905 } else { 2906 /* Default to px for all other properties. */ 2907 return "px"; 2908 } 2909 }, 2910 /* HTML elements default to an associated display type when they're not set to display:none. */ 2911 /* Note: This function is used for correctly setting the non-"none" display value in certain Velocity redirects, such as fadeIn/Out. */ 2912 getDisplayType: function(element) { 2913 var tagName = element && element.tagName.toString().toLowerCase(); 2914 2915 if (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(tagName)) { 2916 return "inline"; 2917 } else if (/^(li)$/i.test(tagName)) { 2918 return "list-item"; 2919 } else if (/^(tr)$/i.test(tagName)) { 2920 return "table-row"; 2921 } else if (/^(table)$/i.test(tagName)) { 2922 return "table"; 2923 } else if (/^(tbody)$/i.test(tagName)) { 2924 return "table-row-group"; 2925 /* Default to "block" when no match is found. */ 2926 } else { 2927 return "block"; 2928 } 2929 }, 2930 /* The class add/remove functions are used to temporarily apply a "velocity-animating" class to elements while they're animating. */ 2931 addClass: function(element, className) { 2932 if (element) { 2933 if (element.classList) { 2934 element.classList.add(className); 2935 } else if (Type.isString(element.className)) { 2936 // Element.className is around 15% faster then set/getAttribute 2937 element.className += (element.className.length ? " " : "") + className; 2938 } else { 2939 // Work around for IE strict mode animating SVG - and anything else that doesn't behave correctly - the same way jQuery does it 2940 var currentClass = element.getAttribute(IE <= 7 ? "className" : "class") || ""; 2941 2942 element.setAttribute("class", currentClass + (currentClass ? " " : "") + className); 2943 } 2944 } 2945 }, 2946 removeClass: function(element, className) { 2947 if (element) { 2948 if (element.classList) { 2949 element.classList.remove(className); 2950 } else if (Type.isString(element.className)) { 2951 // Element.className is around 15% faster then set/getAttribute 2952 // TODO: Need some jsperf tests on performance - can we get rid of the regex and maybe use split / array manipulation? 2953 element.className = element.className.toString().replace(new RegExp("(^|\\s)" + className.split(" ").join("|") + "(\\s|$)", "gi"), " "); 2954 } else { 2955 // Work around for IE strict mode animating SVG - and anything else that doesn't behave correctly - the same way jQuery does it 2956 var currentClass = element.getAttribute(IE <= 7 ? "className" : "class") || ""; 2957 2958 element.setAttribute("class", currentClass.replace(new RegExp("(^|\s)" + className.split(" ").join("|") + "(\s|$)", "gi"), " ")); 2959 } 2960 } 2961 } 2962 }, 2963 /**************************** 2964 Style Getting & Setting 2965 ****************************/ 2966 2967 /* The singular getPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ 2968 getPropertyValue: function(element, property, rootPropertyValue, forceStyleLookup) { 2969 /* Get an element's computed property value. */ 2970 /* Note: Retrieving the value of a CSS property cannot simply be performed by checking an element's 2971 style attribute (which only reflects user-defined values). Instead, the browser must be queried for a property's 2972 *computed* value. You can read more about getComputedStyle here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ 2973 function computePropertyValue(element, property) { 2974 /* When box-sizing isn't set to border-box, height and width style values are incorrectly computed when an 2975 element's scrollbars are visible (which expands the element's dimensions). Thus, we defer to the more accurate 2976 offsetHeight/Width property, which includes the total dimensions for interior, border, padding, and scrollbar. 2977 We subtract border and padding to get the sum of interior + scrollbar. */ 2978 var computedValue = 0; 2979 2980 /* IE<=8 doesn't support window.getComputedStyle, thus we defer to jQuery, which has an extensive array 2981 of hacks to accurately retrieve IE8 property values. Re-implementing that logic here is not worth bloating the 2982 codebase for a dying browser. The performance repercussions of using jQuery here are minimal since 2983 Velocity is optimized to rarely (and sometimes never) query the DOM. Further, the $.css() codepath isn't that slow. */ 2984 if (IE <= 8) { 2985 computedValue = $.css(element, property); /* GET */ 2986 /* All other browsers support getComputedStyle. The returned live object reference is cached onto its 2987 associated element so that it does not need to be refetched upon every GET. */ 2988 } else { 2989 /* Browsers do not return height and width values for elements that are set to display:"none". Thus, we temporarily 2990 toggle display to the element type's default value. */ 2991 var toggleDisplay = false; 2992 2993 if (/^(width|height)$/.test(property) && CSS.getPropertyValue(element, "display") === 0) { 2994 toggleDisplay = true; 2995 CSS.setPropertyValue(element, "display", CSS.Values.getDisplayType(element)); 2996 } 2997 2998 var revertDisplay = function() { 2999 if (toggleDisplay) { 3000 CSS.setPropertyValue(element, "display", "none"); 3001 } 3002 }; 3003 3004 if (!forceStyleLookup) { 3005 if (property === "height" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { 3006 var contentBoxHeight = element.offsetHeight - (parseFloat(CSS.getPropertyValue(element, "borderTopWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderBottomWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingTop")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingBottom")) || 0); 3007 revertDisplay(); 3008 3009 return contentBoxHeight; 3010 } else if (property === "width" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { 3011 var contentBoxWidth = element.offsetWidth - (parseFloat(CSS.getPropertyValue(element, "borderLeftWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderRightWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingLeft")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingRight")) || 0); 3012 revertDisplay(); 3013 3014 return contentBoxWidth; 3015 } 3016 } 3017 3018 var computedStyle; 3019 3020 /* For elements that Velocity hasn't been called on directly (e.g. when Velocity queries the DOM on behalf 3021 of a parent of an element its animating), perform a direct getComputedStyle lookup since the object isn't cached. */ 3022 if (Data(element) === undefined) { 3023 computedStyle = window.getComputedStyle(element, null); /* GET */ 3024 /* If the computedStyle object has yet to be cached, do so now. */ 3025 } else if (!Data(element).computedStyle) { 3026 computedStyle = Data(element).computedStyle = window.getComputedStyle(element, null); /* GET */ 3027 /* If computedStyle is cached, use it. */ 3028 } else { 3029 computedStyle = Data(element).computedStyle; 3030 } 3031 3032 /* IE and Firefox do not return a value for the generic borderColor -- they only return individual values for each border side's color. 3033 Also, in all browsers, when border colors aren't all the same, a compound value is returned that Velocity isn't setup to parse. 3034 So, as a polyfill for querying individual border side colors, we just return the top border's color and animate all borders from that value. */ 3035 if (property === "borderColor") { 3036 property = "borderTopColor"; 3037 } 3038 3039 /* IE9 has a bug in which the "filter" property must be accessed from computedStyle using the getPropertyValue method 3040 instead of a direct property lookup. The getPropertyValue method is slower than a direct lookup, which is why we avoid it by default. */ 3041 if (IE === 9 && property === "filter") { 3042 computedValue = computedStyle.getPropertyValue(property); /* GET */ 3043 } else { 3044 computedValue = computedStyle[property]; 3045 } 3046 3047 /* Fall back to the property's style value (if defined) when computedValue returns nothing, 3048 which can happen when the element hasn't been painted. */ 3049 if (computedValue === "" || computedValue === null) { 3050 computedValue = element.style[property]; 3051 } 3052 3053 revertDisplay(); 3054 } 3055 3056 /* For top, right, bottom, and left (TRBL) values that are set to "auto" on elements of "fixed" or "absolute" position, 3057 defer to jQuery for converting "auto" to a numeric value. (For elements with a "static" or "relative" position, "auto" has the same 3058 effect as being set to 0, so no conversion is necessary.) */ 3059 /* An example of why numeric conversion is necessary: When an element with "position:absolute" has an untouched "left" 3060 property, which reverts to "auto", left's value is 0 relative to its parent element, but is often non-zero relative 3061 to its *containing* (not parent) element, which is the nearest "position:relative" ancestor or the viewport (and always the viewport in the case of "position:fixed"). */ 3062 if (computedValue === "auto" && /^(top|right|bottom|left)$/i.test(property)) { 3063 var position = computePropertyValue(element, "position"); /* GET */ 3064 3065 /* For absolute positioning, jQuery's $.position() only returns values for top and left; 3066 right and bottom will have their "auto" value reverted to 0. */ 3067 /* Note: A jQuery object must be created here since jQuery doesn't have a low-level alias for $.position(). 3068 Not a big deal since we're currently in a GET batch anyway. */ 3069 if (position === "fixed" || (position === "absolute" && /top|left/i.test(property))) { 3070 /* Note: jQuery strips the pixel unit from its returned values; we re-add it here to conform with computePropertyValue's behavior. */ 3071 computedValue = $(element).position()[property] + "px"; /* GET */ 3072 } 3073 } 3074 3075 return computedValue; 3076 } 3077 3078 var propertyValue; 3079 3080 /* If this is a hooked property (e.g. "clipLeft" instead of the root property of "clip"), 3081 extract the hook's value from a normalized rootPropertyValue using CSS.Hooks.extractValue(). */ 3082 if (CSS.Hooks.registered[property]) { 3083 var hook = property, 3084 hookRoot = CSS.Hooks.getRoot(hook); 3085 3086 /* If a cached rootPropertyValue wasn't passed in (which Velocity always attempts to do in order to avoid requerying the DOM), 3087 query the DOM for the root property's value. */ 3088 if (rootPropertyValue === undefined) { 3089 /* Since the browser is now being directly queried, use the official post-prefixing property name for this lookup. */ 3090 rootPropertyValue = CSS.getPropertyValue(element, CSS.Names.prefixCheck(hookRoot)[0]); /* GET */ 3091 } 3092 3093 /* If this root has a normalization registered, peform the associated normalization extraction. */ 3094 if (CSS.Normalizations.registered[hookRoot]) { 3095 rootPropertyValue = CSS.Normalizations.registered[hookRoot]("extract", element, rootPropertyValue); 3096 } 3097 3098 /* Extract the hook's value. */ 3099 propertyValue = CSS.Hooks.extractValue(hook, rootPropertyValue); 3100 3101 /* If this is a normalized property (e.g. "opacity" becomes "filter" in <=IE8) or "translateX" becomes "transform"), 3102 normalize the property's name and value, and handle the special case of transforms. */ 3103 /* Note: Normalizing a property is mutually exclusive from hooking a property since hook-extracted values are strictly 3104 numerical and therefore do not require normalization extraction. */ 3105 } else if (CSS.Normalizations.registered[property]) { 3106 var normalizedPropertyName, 3107 normalizedPropertyValue; 3108 3109 normalizedPropertyName = CSS.Normalizations.registered[property]("name", element); 3110 3111 /* Transform values are calculated via normalization extraction (see below), which checks against the element's transformCache. 3112 At no point do transform GETs ever actually query the DOM; initial stylesheet values are never processed. 3113 This is because parsing 3D transform matrices is not always accurate and would bloat our codebase; 3114 thus, normalization extraction defaults initial transform values to their zero-values (e.g. 1 for scaleX and 0 for translateX). */ 3115 if (normalizedPropertyName !== "transform") { 3116 normalizedPropertyValue = computePropertyValue(element, CSS.Names.prefixCheck(normalizedPropertyName)[0]); /* GET */ 3117 3118 /* If the value is a CSS null-value and this property has a hook template, use that zero-value template so that hooks can be extracted from it. */ 3119 if (CSS.Values.isCSSNullValue(normalizedPropertyValue) && CSS.Hooks.templates[property]) { 3120 normalizedPropertyValue = CSS.Hooks.templates[property][1]; 3121 } 3122 } 3123 3124 propertyValue = CSS.Normalizations.registered[property]("extract", element, normalizedPropertyValue); 3125 } 3126 3127 /* If a (numeric) value wasn't produced via hook extraction or normalization, query the DOM. */ 3128 if (!/^[\d-]/.test(propertyValue)) { 3129 /* For SVG elements, dimensional properties (which SVGAttribute() detects) are tweened via 3130 their HTML attribute values instead of their CSS style values. */ 3131 var data = Data(element); 3132 3133 if (data && data.isSVG && CSS.Names.SVGAttribute(property)) { 3134 /* Since the height/width attribute values must be set manually, they don't reflect computed values. 3135 Thus, we use use getBBox() to ensure we always get values for elements with undefined height/width attributes. */ 3136 if (/^(height|width)$/i.test(property)) { 3137 /* Firefox throws an error if .getBBox() is called on an SVG that isn't attached to the DOM. */ 3138 try { 3139 propertyValue = element.getBBox()[property]; 3140 } catch (error) { 3141 propertyValue = 0; 3142 } 3143 /* Otherwise, access the attribute value directly. */ 3144 } else { 3145 propertyValue = element.getAttribute(property); 3146 } 3147 } else { 3148 propertyValue = computePropertyValue(element, CSS.Names.prefixCheck(property)[0]); /* GET */ 3149 } 3150 } 3151 3152 /* Since property lookups are for animation purposes (which entails computing the numeric delta between start and end values), 3153 convert CSS null-values to an integer of value 0. */ 3154 if (CSS.Values.isCSSNullValue(propertyValue)) { 3155 propertyValue = 0; 3156 } 3157 3158 if (Velocity.debug >= 2) { 3159 console.log("Get " + property + ": " + propertyValue); 3160 } 3161 3162 return propertyValue; 3163 }, 3164 /* The singular setPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ 3165 setPropertyValue: function(element, property, propertyValue, rootPropertyValue, scrollData) { 3166 var propertyName = property; 3167 3168 /* In order to be subjected to call options and element queueing, scroll animation is routed through Velocity as if it were a standard CSS property. */ 3169 if (property === "scroll") { 3170 /* If a container option is present, scroll the container instead of the browser window. */ 3171 if (scrollData.container) { 3172 scrollData.container["scroll" + scrollData.direction] = propertyValue; 3173 /* Otherwise, Velocity defaults to scrolling the browser window. */ 3174 } else { 3175 if (scrollData.direction === "Left") { 3176 window.scrollTo(propertyValue, scrollData.alternateValue); 3177 } else { 3178 window.scrollTo(scrollData.alternateValue, propertyValue); 3179 } 3180 } 3181 } else { 3182 /* Transforms (translateX, rotateZ, etc.) are applied to a per-element transformCache object, which is manually flushed via flushTransformCache(). 3183 Thus, for now, we merely cache transforms being SET. */ 3184 if (CSS.Normalizations.registered[property] && CSS.Normalizations.registered[property]("name", element) === "transform") { 3185 /* Perform a normalization injection. */ 3186 /* Note: The normalization logic handles the transformCache updating. */ 3187 CSS.Normalizations.registered[property]("inject", element, propertyValue); 3188 3189 propertyName = "transform"; 3190 propertyValue = Data(element).transformCache[property]; 3191 } else { 3192 /* Inject hooks. */ 3193 if (CSS.Hooks.registered[property]) { 3194 var hookName = property, 3195 hookRoot = CSS.Hooks.getRoot(property); 3196 3197 /* If a cached rootPropertyValue was not provided, query the DOM for the hookRoot's current value. */ 3198 rootPropertyValue = rootPropertyValue || CSS.getPropertyValue(element, hookRoot); /* GET */ 3199 3200 propertyValue = CSS.Hooks.injectValue(hookName, propertyValue, rootPropertyValue); 3201 property = hookRoot; 3202 } 3203 3204 /* Normalize names and values. */ 3205 if (CSS.Normalizations.registered[property]) { 3206 propertyValue = CSS.Normalizations.registered[property]("inject", element, propertyValue); 3207 property = CSS.Normalizations.registered[property]("name", element); 3208 } 3209 3210 /* Assign the appropriate vendor prefix before performing an official style update. */ 3211 propertyName = CSS.Names.prefixCheck(property)[0]; 3212 3213 /* A try/catch is used for IE<=8, which throws an error when "invalid" CSS values are set, e.g. a negative width. 3214 Try/catch is avoided for other browsers since it incurs a performance overhead. */ 3215 if (IE <= 8) { 3216 try { 3217 element.style[propertyName] = propertyValue; 3218 } catch (error) { 3219 if (Velocity.debug) { 3220 console.log("Browser does not support [" + propertyValue + "] for [" + propertyName + "]"); 3221 } 3222 } 3223 /* SVG elements have their dimensional properties (width, height, x, y, cx, etc.) applied directly as attributes instead of as styles. */ 3224 /* Note: IE8 does not support SVG elements, so it's okay that we skip it for SVG animation. */ 3225 } else { 3226 var data = Data(element); 3227 3228 if (data && data.isSVG && CSS.Names.SVGAttribute(property)) { 3229 /* Note: For SVG attributes, vendor-prefixed property names are never used. */ 3230 /* Note: Not all CSS properties can be animated via attributes, but the browser won't throw an error for unsupported properties. */ 3231 element.setAttribute(property, propertyValue); 3232 } else { 3233 element.style[propertyName] = propertyValue; 3234 } 3235 } 3236 3237 if (Velocity.debug >= 2) { 3238 console.log("Set " + property + " (" + propertyName + "): " + propertyValue); 3239 } 3240 } 3241 } 3242 3243 /* Return the normalized property name and value in case the caller wants to know how these values were modified before being applied to the DOM. */ 3244 return [propertyName, propertyValue]; 3245 }, 3246 /* To increase performance by batching transform updates into a single SET, transforms are not directly applied to an element until flushTransformCache() is called. */ 3247 /* Note: Velocity applies transform properties in the same order that they are chronogically introduced to the element's CSS styles. */ 3248 flushTransformCache: function(element) { 3249 var transformString = "", 3250 data = Data(element); 3251 3252 /* Certain browsers require that SVG transforms be applied as an attribute. However, the SVG transform attribute takes a modified version of CSS's transform string 3253 (units are dropped and, except for skewX/Y, subproperties are merged into their master property -- e.g. scaleX and scaleY are merged into scale(X Y). */ 3254 if ((IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) && data && data.isSVG) { 3255 /* Since transform values are stored in their parentheses-wrapped form, we use a helper function to strip out their numeric values. 3256 Further, SVG transform properties only take unitless (representing pixels) values, so it's okay that parseFloat() strips the unit suffixed to the float value. */ 3257 var getTransformFloat = function(transformProperty) { 3258 return parseFloat(CSS.getPropertyValue(element, transformProperty)); 3259 }; 3260 3261 /* Create an object to organize all the transforms that we'll apply to the SVG element. To keep the logic simple, 3262 we process *all* transform properties -- even those that may not be explicitly applied (since they default to their zero-values anyway). */ 3263 var SVGTransforms = { 3264 translate: [getTransformFloat("translateX"), getTransformFloat("translateY")], 3265 skewX: [getTransformFloat("skewX")], skewY: [getTransformFloat("skewY")], 3266 /* If the scale property is set (non-1), use that value for the scaleX and scaleY values 3267 (this behavior mimics the result of animating all these properties at once on HTML elements). */ 3268 scale: getTransformFloat("scale") !== 1 ? [getTransformFloat("scale"), getTransformFloat("scale")] : [getTransformFloat("scaleX"), getTransformFloat("scaleY")], 3269 /* Note: SVG's rotate transform takes three values: rotation degrees followed by the X and Y values 3270 defining the rotation's origin point. We ignore the origin values (default them to 0). */ 3271 rotate: [getTransformFloat("rotateZ"), 0, 0] 3272 }; 3273 3274 /* Iterate through the transform properties in the user-defined property map order. 3275 (This mimics the behavior of non-SVG transform animation.) */ 3276 $.each(Data(element).transformCache, function(transformName) { 3277 /* Except for with skewX/Y, revert the axis-specific transform subproperties to their axis-free master 3278 properties so that they match up with SVG's accepted transform properties. */ 3279 if (/^translate/i.test(transformName)) { 3280 transformName = "translate"; 3281 } else if (/^scale/i.test(transformName)) { 3282 transformName = "scale"; 3283 } else if (/^rotate/i.test(transformName)) { 3284 transformName = "rotate"; 3285 } 3286 3287 /* Check that we haven't yet deleted the property from the SVGTransforms container. */ 3288 if (SVGTransforms[transformName]) { 3289 /* Append the transform property in the SVG-supported transform format. As per the spec, surround the space-delimited values in parentheses. */ 3290 transformString += transformName + "(" + SVGTransforms[transformName].join(" ") + ")" + " "; 3291 3292 /* After processing an SVG transform property, delete it from the SVGTransforms container so we don't 3293 re-insert the same master property if we encounter another one of its axis-specific properties. */ 3294 delete SVGTransforms[transformName]; 3295 } 3296 }); 3297 } else { 3298 var transformValue, 3299 perspective; 3300 3301 /* Transform properties are stored as members of the transformCache object. Concatenate all the members into a string. */ 3302 $.each(Data(element).transformCache, function(transformName) { 3303 transformValue = Data(element).transformCache[transformName]; 3304 3305 /* Transform's perspective subproperty must be set first in order to take effect. Store it temporarily. */ 3306 if (transformName === "transformPerspective") { 3307 perspective = transformValue; 3308 return true; 3309 } 3310 3311 /* IE9 only supports one rotation type, rotateZ, which it refers to as "rotate". */ 3312 if (IE === 9 && transformName === "rotateZ") { 3313 transformName = "rotate"; 3314 } 3315 3316 transformString += transformName + transformValue + " "; 3317 }); 3318 3319 /* If present, set the perspective subproperty first. */ 3320 if (perspective) { 3321 transformString = "perspective" + perspective + " " + transformString; 3322 } 3323 } 3324 3325 CSS.setPropertyValue(element, "transform", transformString); 3326 } 3327 }; 3328 3329 /* Register hooks and normalizations. */ 3330 CSS.Hooks.register(); 3331 CSS.Normalizations.register(); 3332 3333 /* Allow hook setting in the same fashion as jQuery's $.css(). */ 3334 Velocity.hook = function(elements, arg2, arg3) { 3335 var value; 3336 3337 elements = sanitizeElements(elements); 3338 3339 $.each(elements, function(i, element) { 3340 /* Initialize Velocity's per-element data cache if this element hasn't previously been animated. */ 3341 if (Data(element) === undefined) { 3342 Velocity.init(element); 3343 } 3344 3345 /* Get property value. If an element set was passed in, only return the value for the first element. */ 3346 if (arg3 === undefined) { 3347 if (value === undefined) { 3348 value = CSS.getPropertyValue(element, arg2); 3349 } 3350 /* Set property value. */ 3351 } else { 3352 /* sPV returns an array of the normalized propertyName/propertyValue pair used to update the DOM. */ 3353 var adjustedSet = CSS.setPropertyValue(element, arg2, arg3); 3354 3355 /* Transform properties don't automatically set. They have to be flushed to the DOM. */ 3356 if (adjustedSet[0] === "transform") { 3357 Velocity.CSS.flushTransformCache(element); 3358 } 3359 3360 value = adjustedSet; 3361 } 3362 }); 3363 3364 return value; 3365 }; 3366 3367 /***************** 3368 Animation 3369 *****************/ 3370 3371 var animate = function() { 3372 var opts; 3373 3374 /****************** 3375 Call Chain 3376 ******************/ 3377 3378 /* Logic for determining what to return to the call stack when exiting out of Velocity. */ 3379 function getChain() { 3380 /* If we are using the utility function, attempt to return this call's promise. If no promise library was detected, 3381 default to null instead of returning the targeted elements so that utility function's return value is standardized. */ 3382 if (isUtility) { 3383 return promiseData.promise || null; 3384 /* Otherwise, if we're using $.fn, return the jQuery-/Zepto-wrapped element set. */ 3385 } else { 3386 return elementsWrapped; 3387 } 3388 } 3389 3390 /************************* 3391 Arguments Assignment 3392 *************************/ 3393 3394 /* To allow for expressive CoffeeScript code, Velocity supports an alternative syntax in which "elements" (or "e"), "properties" (or "p"), and "options" (or "o") 3395 objects are defined on a container object that's passed in as Velocity's sole argument. */ 3396 /* Note: Some browsers automatically populate arguments with a "properties" object. We detect it by checking for its default "names" property. */ 3397 var syntacticSugar = (arguments[0] && (arguments[0].p || (($.isPlainObject(arguments[0].properties) && !arguments[0].properties.names) || Type.isString(arguments[0].properties)))), 3398 /* Whether Velocity was called via the utility function (as opposed to on a jQuery/Zepto object). */ 3399 isUtility, 3400 /* When Velocity is called via the utility function ($.Velocity()/Velocity()), elements are explicitly 3401 passed in as the first parameter. Thus, argument positioning varies. We normalize them here. */ 3402 elementsWrapped, 3403 argumentIndex; 3404 3405 var elements, 3406 propertiesMap, 3407 options; 3408 3409 /* Detect jQuery/Zepto elements being animated via the $.fn method. */ 3410 if (Type.isWrapped(this)) { 3411 isUtility = false; 3412 3413 argumentIndex = 0; 3414 elements = this; 3415 elementsWrapped = this; 3416 /* Otherwise, raw elements are being animated via the utility function. */ 3417 } else { 3418 isUtility = true; 3419 3420 argumentIndex = 1; 3421 elements = syntacticSugar ? (arguments[0].elements || arguments[0].e) : arguments[0]; 3422 } 3423 3424 /*************** 3425 Promises 3426 ***************/ 3427 3428 var promiseData = { 3429 promise: null, 3430 resolver: null, 3431 rejecter: null 3432 }; 3433 3434 /* If this call was made via the utility function (which is the default method of invocation when jQuery/Zepto are not being used), and if 3435 promise support was detected, create a promise object for this call and store references to its resolver and rejecter methods. The resolve 3436 method is used when a call completes naturally or is prematurely stopped by the user. In both cases, completeCall() handles the associated 3437 call cleanup and promise resolving logic. The reject method is used when an invalid set of arguments is passed into a Velocity call. */ 3438 /* Note: Velocity employs a call-based queueing architecture, which means that stopping an animating element actually stops the full call that 3439 triggered it -- not that one element exclusively. Similarly, there is one promise per call, and all elements targeted by a Velocity call are 3440 grouped together for the purposes of resolving and rejecting a promise. */ 3441 if (isUtility && Velocity.Promise) { 3442 promiseData.promise = new Velocity.Promise(function(resolve, reject) { 3443 promiseData.resolver = resolve; 3444 promiseData.rejecter = reject; 3445 }); 3446 } 3447 3448 if (syntacticSugar) { 3449 propertiesMap = arguments[0].properties || arguments[0].p; 3450 options = arguments[0].options || arguments[0].o; 3451 } else { 3452 propertiesMap = arguments[argumentIndex]; 3453 options = arguments[argumentIndex + 1]; 3454 } 3455 3456 elements = sanitizeElements(elements); 3457 3458 if (!elements) { 3459 if (promiseData.promise) { 3460 if (!propertiesMap || !options || options.promiseRejectEmpty !== false) { 3461 promiseData.rejecter(); 3462 } else { 3463 promiseData.resolver(); 3464 } 3465 } 3466 return; 3467 } 3468 3469 /* The length of the element set (in the form of a nodeList or an array of elements) is defaulted to 1 in case a 3470 single raw DOM element is passed in (which doesn't contain a length property). */ 3471 var elementsLength = elements.length, 3472 elementsIndex = 0; 3473 3474 /*************************** 3475 Argument Overloading 3476 ***************************/ 3477 3478 /* Support is included for jQuery's argument overloading: $.animate(propertyMap [, duration] [, easing] [, complete]). 3479 Overloading is detected by checking for the absence of an object being passed into options. */ 3480 /* Note: The stop/finish/pause/resume actions do not accept animation options, and are therefore excluded from this check. */ 3481 if (!/^(stop|finish|finishAll|pause|resume)$/i.test(propertiesMap) && !$.isPlainObject(options)) { 3482 /* The utility function shifts all arguments one position to the right, so we adjust for that offset. */ 3483 var startingArgumentPosition = argumentIndex + 1; 3484 3485 options = {}; 3486 3487 /* Iterate through all options arguments */ 3488 for (var i = startingArgumentPosition; i < arguments.length; i++) { 3489 /* Treat a number as a duration. Parse it out. */ 3490 /* Note: The following RegEx will return true if passed an array with a number as its first item. 3491 Thus, arrays are skipped from this check. */ 3492 if (!Type.isArray(arguments[i]) && (/^(fast|normal|slow)$/i.test(arguments[i]) || /^\d/.test(arguments[i]))) { 3493 options.duration = arguments[i]; 3494 /* Treat strings and arrays as easings. */ 3495 } else if (Type.isString(arguments[i]) || Type.isArray(arguments[i])) { 3496 options.easing = arguments[i]; 3497 /* Treat a function as a complete callback. */ 3498 } else if (Type.isFunction(arguments[i])) { 3499 options.complete = arguments[i]; 3500 } 3501 } 3502 } 3503 3504 /********************* 3505 Action Detection 3506 *********************/ 3507 3508 /* Velocity's behavior is categorized into "actions": Elements can either be specially scrolled into view, 3509 or they can be started, stopped, paused, resumed, or reversed . If a literal or referenced properties map is passed in as Velocity's 3510 first argument, the associated action is "start". Alternatively, "scroll", "reverse", "pause", "resume" or "stop" can be passed in 3511 instead of a properties map. */ 3512 var action; 3513 3514 switch (propertiesMap) { 3515 case "scroll": 3516 action = "scroll"; 3517 break; 3518 3519 case "reverse": 3520 action = "reverse"; 3521 break; 3522 3523 case "pause": 3524 3525 /******************* 3526 Action: Pause 3527 *******************/ 3528 3529 var currentTime = (new Date()).getTime(); 3530 3531 /* Handle delay timers */ 3532 $.each(elements, function(i, element) { 3533 pauseDelayOnElement(element, currentTime); 3534 }); 3535 3536 /* Pause and Resume are call-wide (not on a per element basis). Thus, calling pause or resume on a 3537 single element will cause any calls that containt tweens for that element to be paused/resumed 3538 as well. */ 3539 3540 /* Iterate through all calls and pause any that contain any of our elements */ 3541 $.each(Velocity.State.calls, function(i, activeCall) { 3542 3543 var found = false; 3544 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 3545 if (activeCall) { 3546 /* Iterate through the active call's targeted elements. */ 3547 $.each(activeCall[1], function(k, activeElement) { 3548 var queueName = (options === undefined) ? "" : options; 3549 3550 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 3551 return true; 3552 } 3553 3554 /* Iterate through the calls targeted by the stop command. */ 3555 $.each(elements, function(l, element) { 3556 /* Check that this call was applied to the target element. */ 3557 if (element === activeElement) { 3558 3559 /* Set call to paused */ 3560 activeCall[5] = { 3561 resume: false 3562 }; 3563 3564 /* Once we match an element, we can bounce out to the next call entirely */ 3565 found = true; 3566 return false; 3567 } 3568 }); 3569 3570 /* Proceed to check next call if we have already matched */ 3571 if (found) { 3572 return false; 3573 } 3574 }); 3575 } 3576 3577 }); 3578 3579 /* Since pause creates no new tweens, exit out of Velocity. */ 3580 return getChain(); 3581 3582 case "resume": 3583 3584 /******************* 3585 Action: Resume 3586 *******************/ 3587 3588 /* Handle delay timers */ 3589 $.each(elements, function(i, element) { 3590 resumeDelayOnElement(element, currentTime); 3591 }); 3592 3593 /* Pause and Resume are call-wide (not on a per elemnt basis). Thus, calling pause or resume on a 3594 single element will cause any calls that containt tweens for that element to be paused/resumed 3595 as well. */ 3596 3597 /* Iterate through all calls and pause any that contain any of our elements */ 3598 $.each(Velocity.State.calls, function(i, activeCall) { 3599 var found = false; 3600 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 3601 if (activeCall) { 3602 /* Iterate through the active call's targeted elements. */ 3603 $.each(activeCall[1], function(k, activeElement) { 3604 var queueName = (options === undefined) ? "" : options; 3605 3606 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 3607 return true; 3608 } 3609 3610 /* Skip any calls that have never been paused */ 3611 if (!activeCall[5]) { 3612 return true; 3613 } 3614 3615 /* Iterate through the calls targeted by the stop command. */ 3616 $.each(elements, function(l, element) { 3617 /* Check that this call was applied to the target element. */ 3618 if (element === activeElement) { 3619 3620 /* Flag a pause object to be resumed, which will occur during the next tick. In 3621 addition, the pause object will at that time be deleted */ 3622 activeCall[5].resume = true; 3623 3624 /* Once we match an element, we can bounce out to the next call entirely */ 3625 found = true; 3626 return false; 3627 } 3628 }); 3629 3630 /* Proceed to check next call if we have already matched */ 3631 if (found) { 3632 return false; 3633 } 3634 }); 3635 } 3636 3637 }); 3638 3639 /* Since resume creates no new tweens, exit out of Velocity. */ 3640 return getChain(); 3641 3642 case "finish": 3643 case "finishAll": 3644 case "stop": 3645 /******************* 3646 Action: Stop 3647 *******************/ 3648 3649 /* Clear the currently-active delay on each targeted element. */ 3650 $.each(elements, function(i, element) { 3651 if (Data(element) && Data(element).delayTimer) { 3652 /* Stop the timer from triggering its cached next() function. */ 3653 clearTimeout(Data(element).delayTimer.setTimeout); 3654 3655 /* Manually call the next() function so that the subsequent queue items can progress. */ 3656 if (Data(element).delayTimer.next) { 3657 Data(element).delayTimer.next(); 3658 } 3659 3660 delete Data(element).delayTimer; 3661 } 3662 3663 /* If we want to finish everything in the queue, we have to iterate through it 3664 and call each function. This will make them active calls below, which will 3665 cause them to be applied via the duration setting. */ 3666 if (propertiesMap === "finishAll" && (options === true || Type.isString(options))) { 3667 /* Iterate through the items in the element's queue. */ 3668 $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { 3669 /* The queue array can contain an "inprogress" string, which we skip. */ 3670 if (Type.isFunction(item)) { 3671 item(); 3672 } 3673 }); 3674 3675 /* Clearing the $.queue() array is achieved by resetting it to []. */ 3676 $.queue(element, Type.isString(options) ? options : "", []); 3677 } 3678 }); 3679 3680 var callsToStop = []; 3681 3682 /* When the stop action is triggered, the elements' currently active call is immediately stopped. The active call might have 3683 been applied to multiple elements, in which case all of the call's elements will be stopped. When an element 3684 is stopped, the next item in its animation queue is immediately triggered. */ 3685 /* An additional argument may be passed in to clear an element's remaining queued calls. Either true (which defaults to the "fx" queue) 3686 or a custom queue string can be passed in. */ 3687 /* Note: The stop command runs prior to Velocity's Queueing phase since its behavior is intended to take effect *immediately*, 3688 regardless of the element's current queue state. */ 3689 3690 /* Iterate through every active call. */ 3691 $.each(Velocity.State.calls, function(i, activeCall) { 3692 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 3693 if (activeCall) { 3694 /* Iterate through the active call's targeted elements. */ 3695 $.each(activeCall[1], function(k, activeElement) { 3696 /* If true was passed in as a secondary argument, clear absolutely all calls on this element. Otherwise, only 3697 clear calls associated with the relevant queue. */ 3698 /* Call stopping logic works as follows: 3699 - options === true --> stop current default queue calls (and queue:false calls), including remaining queued ones. 3700 - options === undefined --> stop current queue:"" call and all queue:false calls. 3701 - options === false --> stop only queue:false calls. 3702 - options === "custom" --> stop current queue:"custom" call, including remaining queued ones (there is no functionality to only clear the currently-running queue:"custom" call). */ 3703 var queueName = (options === undefined) ? "" : options; 3704 3705 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 3706 return true; 3707 } 3708 3709 /* Iterate through the calls targeted by the stop command. */ 3710 $.each(elements, function(l, element) { 3711 /* Check that this call was applied to the target element. */ 3712 if (element === activeElement) { 3713 /* Optionally clear the remaining queued calls. If we're doing "finishAll" this won't find anything, 3714 due to the queue-clearing above. */ 3715 if (options === true || Type.isString(options)) { 3716 /* Iterate through the items in the element's queue. */ 3717 $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { 3718 /* The queue array can contain an "inprogress" string, which we skip. */ 3719 if (Type.isFunction(item)) { 3720 /* Pass the item's callback a flag indicating that we want to abort from the queue call. 3721 (Specifically, the queue will resolve the call's associated promise then abort.) */ 3722 item(null, true); 3723 } 3724 }); 3725 3726 /* Clearing the $.queue() array is achieved by resetting it to []. */ 3727 $.queue(element, Type.isString(options) ? options : "", []); 3728 } 3729 3730 if (propertiesMap === "stop") { 3731 /* Since "reverse" uses cached start values (the previous call's endValues), these values must be 3732 changed to reflect the final value that the elements were actually tweened to. */ 3733 /* Note: If only queue:false/queue:"custom" animations are currently running on an element, it won't have a tweensContainer 3734 object. Also, queue:false/queue:"custom" animations can't be reversed. */ 3735 var data = Data(element); 3736 if (data && data.tweensContainer && (queueName === true || queueName === "")) { 3737 $.each(data.tweensContainer, function(m, activeTween) { 3738 activeTween.endValue = activeTween.currentValue; 3739 }); 3740 } 3741 3742 callsToStop.push(i); 3743 } else if (propertiesMap === "finish" || propertiesMap === "finishAll") { 3744 /* To get active tweens to finish immediately, we forcefully shorten their durations to 1ms so that 3745 they finish upon the next rAf tick then proceed with normal call completion logic. */ 3746 activeCall[2].duration = 1; 3747 } 3748 } 3749 }); 3750 }); 3751 } 3752 }); 3753 3754 /* Prematurely call completeCall() on each matched active call. Pass an additional flag for "stop" to indicate 3755 that the complete callback and display:none setting should be skipped since we're completing prematurely. */ 3756 if (propertiesMap === "stop") { 3757 $.each(callsToStop, function(i, j) { 3758 completeCall(j, true); 3759 }); 3760 3761 if (promiseData.promise) { 3762 /* Immediately resolve the promise associated with this stop call since stop runs synchronously. */ 3763 promiseData.resolver(elements); 3764 } 3765 } 3766 3767 /* Since we're stopping, and not proceeding with queueing, exit out of Velocity. */ 3768 return getChain(); 3769 3770 default: 3771 /* Treat a non-empty plain object as a literal properties map. */ 3772 if ($.isPlainObject(propertiesMap) && !Type.isEmptyObject(propertiesMap)) { 3773 action = "start"; 3774 3775 /**************** 3776 Redirects 3777 ****************/ 3778 3779 /* Check if a string matches a registered redirect (see Redirects above). */ 3780 } else if (Type.isString(propertiesMap) && Velocity.Redirects[propertiesMap]) { 3781 opts = $.extend({}, options); 3782 3783 var durationOriginal = opts.duration, 3784 delayOriginal = opts.delay || 0; 3785 3786 /* If the backwards option was passed in, reverse the element set so that elements animate from the last to the first. */ 3787 if (opts.backwards === true) { 3788 elements = $.extend(true, [], elements).reverse(); 3789 } 3790 3791 /* Individually trigger the redirect for each element in the set to prevent users from having to handle iteration logic in their redirect. */ 3792 $.each(elements, function(elementIndex, element) { 3793 /* If the stagger option was passed in, successively delay each element by the stagger value (in ms). Retain the original delay value. */ 3794 if (parseFloat(opts.stagger)) { 3795 opts.delay = delayOriginal + (parseFloat(opts.stagger) * elementIndex); 3796 } else if (Type.isFunction(opts.stagger)) { 3797 opts.delay = delayOriginal + opts.stagger.call(element, elementIndex, elementsLength); 3798 } 3799 3800 /* If the drag option was passed in, successively increase/decrease (depending on the presense of opts.backwards) 3801 the duration of each element's animation, using floors to prevent producing very short durations. */ 3802 if (opts.drag) { 3803 /* Default the duration of UI pack effects (callouts and transitions) to 1000ms instead of the usual default duration of 400ms. */ 3804 opts.duration = parseFloat(durationOriginal) || (/^(callout|transition)/.test(propertiesMap) ? 1000 : DURATION_DEFAULT); 3805 3806 /* For each element, take the greater duration of: A) animation completion percentage relative to the original duration, 3807 B) 75% of the original duration, or C) a 200ms fallback (in case duration is already set to a low value). 3808 The end result is a baseline of 75% of the redirect's duration that increases/decreases as the end of the element set is approached. */ 3809 opts.duration = Math.max(opts.duration * (opts.backwards ? 1 - elementIndex / elementsLength : (elementIndex + 1) / elementsLength), opts.duration * 0.75, 200); 3810 } 3811 3812 /* Pass in the call's opts object so that the redirect can optionally extend it. It defaults to an empty object instead of null to 3813 reduce the opts checking logic required inside the redirect. */ 3814 Velocity.Redirects[propertiesMap].call(element, element, opts || {}, elementIndex, elementsLength, elements, promiseData.promise ? promiseData : undefined); 3815 }); 3816 3817 /* Since the animation logic resides within the redirect's own code, abort the remainder of this call. 3818 (The performance overhead up to this point is virtually non-existant.) */ 3819 /* Note: The jQuery call chain is kept intact by returning the complete element set. */ 3820 return getChain(); 3821 } else { 3822 var abortError = "Velocity: First argument (" + propertiesMap + ") was not a property map, a known action, or a registered redirect. Aborting."; 3823 3824 if (promiseData.promise) { 3825 promiseData.rejecter(new Error(abortError)); 3826 } else if (window.console) { 3827 console.log(abortError); 3828 } 3829 3830 return getChain(); 3831 } 3832 } 3833 3834 /************************** 3835 Call-Wide Variables 3836 **************************/ 3837 3838 /* A container for CSS unit conversion ratios (e.g. %, rem, and em ==> px) that is used to cache ratios across all elements 3839 being animated in a single Velocity call. Calculating unit ratios necessitates DOM querying and updating, and is therefore 3840 avoided (via caching) wherever possible. This container is call-wide instead of page-wide to avoid the risk of using stale 3841 conversion metrics across Velocity animations that are not immediately consecutively chained. */ 3842 var callUnitConversionData = { 3843 lastParent: null, 3844 lastPosition: null, 3845 lastFontSize: null, 3846 lastPercentToPxWidth: null, 3847 lastPercentToPxHeight: null, 3848 lastEmToPx: null, 3849 remToPx: null, 3850 vwToPx: null, 3851 vhToPx: null 3852 }; 3853 3854 /* A container for all the ensuing tween data and metadata associated with this call. This container gets pushed to the page-wide 3855 Velocity.State.calls array that is processed during animation ticking. */ 3856 var call = []; 3857 3858 /************************ 3859 Element Processing 3860 ************************/ 3861 3862 /* Element processing consists of three parts -- data processing that cannot go stale and data processing that *can* go stale (i.e. third-party style modifications): 3863 1) Pre-Queueing: Element-wide variables, including the element's data storage, are instantiated. Call options are prepared. If triggered, the Stop action is executed. 3864 2) Queueing: The logic that runs once this call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale. 3865 3) Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. 3866 `elementArrayIndex` allows passing index of the element in the original array to value functions. 3867 If `elementsIndex` were used instead the index would be determined by the elements' per-element queue. 3868 */ 3869 function processElement(element, elementArrayIndex) { 3870 3871 /************************* 3872 Part I: Pre-Queueing 3873 *************************/ 3874 3875 /*************************** 3876 Element-Wide Variables 3877 ***************************/ 3878 3879 var /* The runtime opts object is the extension of the current call's options and Velocity's page-wide option defaults. */ 3880 opts = $.extend({}, Velocity.defaults, options), 3881 /* A container for the processed data associated with each property in the propertyMap. 3882 (Each property in the map produces its own "tween".) */ 3883 tweensContainer = {}, 3884 elementUnitConversionData; 3885 3886 /****************** 3887 Element Init 3888 ******************/ 3889 3890 if (Data(element) === undefined) { 3891 Velocity.init(element); 3892 } 3893 3894 /****************** 3895 Option: Delay 3896 ******************/ 3897 3898 /* Since queue:false doesn't respect the item's existing queue, we avoid injecting its delay here (it's set later on). */ 3899 /* Note: Velocity rolls its own delay function since jQuery doesn't have a utility alias for $.fn.delay() 3900 (and thus requires jQuery element creation, which we avoid since its overhead includes DOM querying). */ 3901 if (parseFloat(opts.delay) && opts.queue !== false) { 3902 $.queue(element, opts.queue, function(next, clearQueue) { 3903 if (clearQueue === true) { 3904 /* Do not continue with animation queueing. */ 3905 return true; 3906 } 3907 3908 /* This is a flag used to indicate to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ 3909 Velocity.velocityQueueEntryFlag = true; 3910 3911 /* The ensuing queue item (which is assigned to the "next" argument that $.queue() automatically passes in) will be triggered after a setTimeout delay. 3912 The setTimeout is stored so that it can be subjected to clearTimeout() if this animation is prematurely stopped via Velocity's "stop" command, and 3913 delayBegin/delayTime is used to ensure we can "pause" and "resume" a tween that is still mid-delay. */ 3914 3915 /* Temporarily store delayed elements to facilite access for global pause/resume */ 3916 var callIndex = Velocity.State.delayedElements.count++; 3917 Velocity.State.delayedElements[callIndex] = element; 3918 3919 var delayComplete = (function(index) { 3920 return function() { 3921 /* Clear the temporary element */ 3922 Velocity.State.delayedElements[index] = false; 3923 3924 /* Finally, issue the call */ 3925 next(); 3926 }; 3927 })(callIndex); 3928 3929 3930 Data(element).delayBegin = (new Date()).getTime(); 3931 Data(element).delay = parseFloat(opts.delay); 3932 Data(element).delayTimer = { 3933 setTimeout: setTimeout(next, parseFloat(opts.delay)), 3934 next: delayComplete 3935 }; 3936 }); 3937 } 3938 3939 /********************* 3940 Option: Duration 3941 *********************/ 3942 3943 /* Support for jQuery's named durations. */ 3944 switch (opts.duration.toString().toLowerCase()) { 3945 case "fast": 3946 opts.duration = 200; 3947 break; 3948 3949 case "normal": 3950 opts.duration = DURATION_DEFAULT; 3951 break; 3952 3953 case "slow": 3954 opts.duration = 600; 3955 break; 3956 3957 default: 3958 /* Remove the potential "ms" suffix and default to 1 if the user is attempting to set a duration of 0 (in order to produce an immediate style change). */ 3959 opts.duration = parseFloat(opts.duration) || 1; 3960 } 3961 3962 /************************ 3963 Global Option: Mock 3964 ************************/ 3965 3966 if (Velocity.mock !== false) { 3967 /* In mock mode, all animations are forced to 1ms so that they occur immediately upon the next rAF tick. 3968 Alternatively, a multiplier can be passed in to time remap all delays and durations. */ 3969 if (Velocity.mock === true) { 3970 opts.duration = opts.delay = 1; 3971 } else { 3972 opts.duration *= parseFloat(Velocity.mock) || 1; 3973 opts.delay *= parseFloat(Velocity.mock) || 1; 3974 } 3975 } 3976 3977 /******************* 3978 Option: Easing 3979 *******************/ 3980 3981 opts.easing = getEasing(opts.easing, opts.duration); 3982 3983 /********************** 3984 Option: Callbacks 3985 **********************/ 3986 3987 /* Callbacks must functions. Otherwise, default to null. */ 3988 if (opts.begin && !Type.isFunction(opts.begin)) { 3989 opts.begin = null; 3990 } 3991 3992 if (opts.progress && !Type.isFunction(opts.progress)) { 3993 opts.progress = null; 3994 } 3995 3996 if (opts.complete && !Type.isFunction(opts.complete)) { 3997 opts.complete = null; 3998 } 3999 4000 /********************************* 4001 Option: Display & Visibility 4002 *********************************/ 4003 4004 /* Refer to Velocity's documentation (VelocityJS.org/#displayAndVisibility) for a description of the display and visibility options' behavior. */ 4005 /* Note: We strictly check for undefined instead of falsiness because display accepts an empty string value. */ 4006 if (opts.display !== undefined && opts.display !== null) { 4007 opts.display = opts.display.toString().toLowerCase(); 4008 4009 /* Users can pass in a special "auto" value to instruct Velocity to set the element to its default display value. */ 4010 if (opts.display === "auto") { 4011 opts.display = Velocity.CSS.Values.getDisplayType(element); 4012 } 4013 } 4014 4015 if (opts.visibility !== undefined && opts.visibility !== null) { 4016 opts.visibility = opts.visibility.toString().toLowerCase(); 4017 } 4018 4019 /********************** 4020 Option: mobileHA 4021 **********************/ 4022 4023 /* When set to true, and if this is a mobile device, mobileHA automatically enables hardware acceleration (via a null transform hack) 4024 on animating elements. HA is removed from the element at the completion of its animation. */ 4025 /* Note: Android Gingerbread doesn't support HA. If a null transform hack (mobileHA) is in fact set, it will prevent other tranform subproperties from taking effect. */ 4026 /* Note: You can read more about the use of mobileHA in Velocity's documentation: VelocityJS.org/#mobileHA. */ 4027 opts.mobileHA = (opts.mobileHA && Velocity.State.isMobile && !Velocity.State.isGingerbread); 4028 4029 /*********************** 4030 Part II: Queueing 4031 ***********************/ 4032 4033 /* When a set of elements is targeted by a Velocity call, the set is broken up and each element has the current Velocity call individually queued onto it. 4034 In this way, each element's existing queue is respected; some elements may already be animating and accordingly should not have this current Velocity call triggered immediately. */ 4035 /* In each queue, tween data is processed for each animating property then pushed onto the call-wide calls array. When the last element in the set has had its tweens processed, 4036 the call array is pushed to Velocity.State.calls for live processing by the requestAnimationFrame tick. */ 4037 function buildQueue(next) { 4038 var data, lastTweensContainer; 4039 4040 /******************* 4041 Option: Begin 4042 *******************/ 4043 4044 /* The begin callback is fired once per call -- not once per elemenet -- and is passed the full raw DOM element set as both its context and its first argument. */ 4045 if (opts.begin && elementsIndex === 0) { 4046 /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ 4047 try { 4048 opts.begin.call(elements, elements); 4049 } catch (error) { 4050 setTimeout(function() { 4051 throw error; 4052 }, 1); 4053 } 4054 } 4055 4056 /***************************************** 4057 Tween Data Construction (for Scroll) 4058 *****************************************/ 4059 4060 /* Note: In order to be subjected to chaining and animation options, scroll's tweening is routed through Velocity as if it were a standard CSS property animation. */ 4061 if (action === "scroll") { 4062 /* The scroll action uniquely takes an optional "offset" option -- specified in pixels -- that offsets the targeted scroll position. */ 4063 var scrollDirection = (/^x$/i.test(opts.axis) ? "Left" : "Top"), 4064 scrollOffset = parseFloat(opts.offset) || 0, 4065 scrollPositionCurrent, 4066 scrollPositionCurrentAlternate, 4067 scrollPositionEnd; 4068 4069 /* Scroll also uniquely takes an optional "container" option, which indicates the parent element that should be scrolled -- 4070 as opposed to the browser window itself. This is useful for scrolling toward an element that's inside an overflowing parent element. */ 4071 if (opts.container) { 4072 /* Ensure that either a jQuery object or a raw DOM element was passed in. */ 4073 if (Type.isWrapped(opts.container) || Type.isNode(opts.container)) { 4074 /* Extract the raw DOM element from the jQuery wrapper. */ 4075 opts.container = opts.container[0] || opts.container; 4076 /* Note: Unlike other properties in Velocity, the browser's scroll position is never cached since it so frequently changes 4077 (due to the user's natural interaction with the page). */ 4078 scrollPositionCurrent = opts.container["scroll" + scrollDirection]; /* GET */ 4079 4080 /* $.position() values are relative to the container's currently viewable area (without taking into account the container's true dimensions 4081 -- say, for example, if the container was not overflowing). Thus, the scroll end value is the sum of the child element's position *and* 4082 the scroll container's current scroll position. */ 4083 scrollPositionEnd = (scrollPositionCurrent + $(element).position()[scrollDirection.toLowerCase()]) + scrollOffset; /* GET */ 4084 /* If a value other than a jQuery object or a raw DOM element was passed in, default to null so that this option is ignored. */ 4085 } else { 4086 opts.container = null; 4087 } 4088 } else { 4089 /* If the window itself is being scrolled -- not a containing element -- perform a live scroll position lookup using 4090 the appropriate cached property names (which differ based on browser type). */ 4091 scrollPositionCurrent = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + scrollDirection]]; /* GET */ 4092 /* When scrolling the browser window, cache the alternate axis's current value since window.scrollTo() doesn't let us change only one value at a time. */ 4093 scrollPositionCurrentAlternate = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + (scrollDirection === "Left" ? "Top" : "Left")]]; /* GET */ 4094 4095 /* Unlike $.position(), $.offset() values are relative to the browser window's true dimensions -- not merely its currently viewable area -- 4096 and therefore end values do not need to be compounded onto current values. */ 4097 scrollPositionEnd = $(element).offset()[scrollDirection.toLowerCase()] + scrollOffset; /* GET */ 4098 } 4099 4100 /* Since there's only one format that scroll's associated tweensContainer can take, we create it manually. */ 4101 tweensContainer = { 4102 scroll: { 4103 rootPropertyValue: false, 4104 startValue: scrollPositionCurrent, 4105 currentValue: scrollPositionCurrent, 4106 endValue: scrollPositionEnd, 4107 unitType: "", 4108 easing: opts.easing, 4109 scrollData: { 4110 container: opts.container, 4111 direction: scrollDirection, 4112 alternateValue: scrollPositionCurrentAlternate 4113 } 4114 }, 4115 element: element 4116 }; 4117 4118 if (Velocity.debug) { 4119 console.log("tweensContainer (scroll): ", tweensContainer.scroll, element); 4120 } 4121 4122 /****************************************** 4123 Tween Data Construction (for Reverse) 4124 ******************************************/ 4125 4126 /* Reverse acts like a "start" action in that a property map is animated toward. The only difference is 4127 that the property map used for reverse is the inverse of the map used in the previous call. Thus, we manipulate 4128 the previous call to construct our new map: use the previous map's end values as our new map's start values. Copy over all other data. */ 4129 /* Note: Reverse can be directly called via the "reverse" parameter, or it can be indirectly triggered via the loop option. (Loops are composed of multiple reverses.) */ 4130 /* Note: Reverse calls do not need to be consecutively chained onto a currently-animating element in order to operate on cached values; 4131 there is no harm to reverse being called on a potentially stale data cache since reverse's behavior is simply defined 4132 as reverting to the element's values as they were prior to the previous *Velocity* call. */ 4133 } else if (action === "reverse") { 4134 data = Data(element); 4135 4136 /* Abort if there is no prior animation data to reverse to. */ 4137 if (!data) { 4138 return; 4139 } 4140 4141 if (!data.tweensContainer) { 4142 /* Dequeue the element so that this queue entry releases itself immediately, allowing subsequent queue entries to run. */ 4143 $.dequeue(element, opts.queue); 4144 4145 return; 4146 } else { 4147 /********************* 4148 Options Parsing 4149 *********************/ 4150 4151 /* If the element was hidden via the display option in the previous call, 4152 revert display to "auto" prior to reversal so that the element is visible again. */ 4153 if (data.opts.display === "none") { 4154 data.opts.display = "auto"; 4155 } 4156 4157 if (data.opts.visibility === "hidden") { 4158 data.opts.visibility = "visible"; 4159 } 4160 4161 /* If the loop option was set in the previous call, disable it so that "reverse" calls aren't recursively generated. 4162 Further, remove the previous call's callback options; typically, users do not want these to be refired. */ 4163 data.opts.loop = false; 4164 data.opts.begin = null; 4165 data.opts.complete = null; 4166 4167 /* Since we're extending an opts object that has already been extended with the defaults options object, 4168 we remove non-explicitly-defined properties that are auto-assigned values. */ 4169 if (!options.easing) { 4170 delete opts.easing; 4171 } 4172 4173 if (!options.duration) { 4174 delete opts.duration; 4175 } 4176 4177 /* The opts object used for reversal is an extension of the options object optionally passed into this 4178 reverse call plus the options used in the previous Velocity call. */ 4179 opts = $.extend({}, data.opts, opts); 4180 4181 /************************************* 4182 Tweens Container Reconstruction 4183 *************************************/ 4184 4185 /* Create a deepy copy (indicated via the true flag) of the previous call's tweensContainer. */ 4186 lastTweensContainer = $.extend(true, {}, data ? data.tweensContainer : null); 4187 4188 /* Manipulate the previous tweensContainer by replacing its end values and currentValues with its start values. */ 4189 for (var lastTween in lastTweensContainer) { 4190 /* In addition to tween data, tweensContainers contain an element property that we ignore here. */ 4191 if (lastTweensContainer.hasOwnProperty(lastTween) && lastTween !== "element") { 4192 var lastStartValue = lastTweensContainer[lastTween].startValue; 4193 4194 lastTweensContainer[lastTween].startValue = lastTweensContainer[lastTween].currentValue = lastTweensContainer[lastTween].endValue; 4195 lastTweensContainer[lastTween].endValue = lastStartValue; 4196 4197 /* Easing is the only option that embeds into the individual tween data (since it can be defined on a per-property basis). 4198 Accordingly, every property's easing value must be updated when an options object is passed in with a reverse call. 4199 The side effect of this extensibility is that all per-property easing values are forcefully reset to the new value. */ 4200 if (!Type.isEmptyObject(options)) { 4201 lastTweensContainer[lastTween].easing = opts.easing; 4202 } 4203 4204 if (Velocity.debug) { 4205 console.log("reverse tweensContainer (" + lastTween + "): " + JSON.stringify(lastTweensContainer[lastTween]), element); 4206 } 4207 } 4208 } 4209 4210 tweensContainer = lastTweensContainer; 4211 } 4212 4213 /***************************************** 4214 Tween Data Construction (for Start) 4215 *****************************************/ 4216 4217 } else if (action === "start") { 4218 4219 /************************* 4220 Value Transferring 4221 *************************/ 4222 4223 /* If this queue entry follows a previous Velocity-initiated queue entry *and* if this entry was created 4224 while the element was in the process of being animated by Velocity, then this current call is safe to use 4225 the end values from the prior call as its start values. Velocity attempts to perform this value transfer 4226 process whenever possible in order to avoid requerying the DOM. */ 4227 /* If values aren't transferred from a prior call and start values were not forcefed by the user (more on this below), 4228 then the DOM is queried for the element's current values as a last resort. */ 4229 /* Note: Conversely, animation reversal (and looping) *always* perform inter-call value transfers; they never requery the DOM. */ 4230 4231 data = Data(element); 4232 4233 /* The per-element isAnimating flag is used to indicate whether it's safe (i.e. the data isn't stale) 4234 to transfer over end values to use as start values. If it's set to true and there is a previous 4235 Velocity call to pull values from, do so. */ 4236 if (data && data.tweensContainer && data.isAnimating === true) { 4237 lastTweensContainer = data.tweensContainer; 4238 } 4239 4240 /*************************** 4241 Tween Data Calculation 4242 ***************************/ 4243 4244 /* This function parses property data and defaults endValue, easing, and startValue as appropriate. */ 4245 /* Property map values can either take the form of 1) a single value representing the end value, 4246 or 2) an array in the form of [ endValue, [, easing] [, startValue] ]. 4247 The optional third parameter is a forcefed startValue to be used instead of querying the DOM for 4248 the element's current value. Read Velocity's docmentation to learn more about forcefeeding: VelocityJS.org/#forcefeeding */ 4249 var parsePropertyValue = function(valueData, skipResolvingEasing) { 4250 var endValue, easing, startValue; 4251 4252 /* If we have a function as the main argument then resolve it first, in case it returns an array that needs to be split */ 4253 if (Type.isFunction(valueData)) { 4254 valueData = valueData.call(element, elementArrayIndex, elementsLength); 4255 } 4256 4257 /* Handle the array format, which can be structured as one of three potential overloads: 4258 A) [ endValue, easing, startValue ], B) [ endValue, easing ], or C) [ endValue, startValue ] */ 4259 if (Type.isArray(valueData)) { 4260 /* endValue is always the first item in the array. Don't bother validating endValue's value now 4261 since the ensuing property cycling logic does that. */ 4262 endValue = valueData[0]; 4263 4264 /* Two-item array format: If the second item is a number, function, or hex string, treat it as a 4265 start value since easings can only be non-hex strings or arrays. */ 4266 if ((!Type.isArray(valueData[1]) && /^[\d-]/.test(valueData[1])) || Type.isFunction(valueData[1]) || CSS.RegEx.isHex.test(valueData[1])) { 4267 startValue = valueData[1]; 4268 /* Two or three-item array: If the second item is a non-hex string easing name or an array, treat it as an easing. */ 4269 } else if ((Type.isString(valueData[1]) && !CSS.RegEx.isHex.test(valueData[1]) && Velocity.Easings[valueData[1]]) || Type.isArray(valueData[1])) { 4270 easing = skipResolvingEasing ? valueData[1] : getEasing(valueData[1], opts.duration); 4271 4272 /* Don't bother validating startValue's value now since the ensuing property cycling logic inherently does that. */ 4273 startValue = valueData[2]; 4274 } else { 4275 startValue = valueData[1] || valueData[2]; 4276 } 4277 /* Handle the single-value format. */ 4278 } else { 4279 endValue = valueData; 4280 } 4281 4282 /* Default to the call's easing if a per-property easing type was not defined. */ 4283 if (!skipResolvingEasing) { 4284 easing = easing || opts.easing; 4285 } 4286 4287 /* If functions were passed in as values, pass the function the current element as its context, 4288 plus the element's index and the element set's size as arguments. Then, assign the returned value. */ 4289 if (Type.isFunction(endValue)) { 4290 endValue = endValue.call(element, elementArrayIndex, elementsLength); 4291 } 4292 4293 if (Type.isFunction(startValue)) { 4294 startValue = startValue.call(element, elementArrayIndex, elementsLength); 4295 } 4296 4297 /* Allow startValue to be left as undefined to indicate to the ensuing code that its value was not forcefed. */ 4298 return [endValue || 0, easing, startValue]; 4299 }; 4300 4301 var fixPropertyValue = function(property, valueData) { 4302 /* In case this property is a hook, there are circumstances where we will intend to work on the hook's root property and not the hooked subproperty. */ 4303 var rootProperty = CSS.Hooks.getRoot(property), 4304 rootPropertyValue = false, 4305 /* Parse out endValue, easing, and startValue from the property's data. */ 4306 endValue = valueData[0], 4307 easing = valueData[1], 4308 startValue = valueData[2], 4309 pattern; 4310 4311 /************************** 4312 Start Value Sourcing 4313 **************************/ 4314 4315 /* Other than for the dummy tween property, properties that are not supported by the browser (and do not have an associated normalization) will 4316 inherently produce no style changes when set, so they are skipped in order to decrease animation tick overhead. 4317 Property support is determined via prefixCheck(), which returns a false flag when no supported is detected. */ 4318 /* Note: Since SVG elements have some of their properties directly applied as HTML attributes, 4319 there is no way to check for their explicit browser support, and so we skip skip this check for them. */ 4320 if ((!data || !data.isSVG) && rootProperty !== "tween" && CSS.Names.prefixCheck(rootProperty)[1] === false && CSS.Normalizations.registered[rootProperty] === undefined) { 4321 if (Velocity.debug) { 4322 console.log("Skipping [" + rootProperty + "] due to a lack of browser support."); 4323 } 4324 return; 4325 } 4326 4327 /* If the display option is being set to a non-"none" (e.g. "block") and opacity (filter on IE<=8) is being 4328 animated to an endValue of non-zero, the user's intention is to fade in from invisible, thus we forcefeed opacity 4329 a startValue of 0 if its startValue hasn't already been sourced by value transferring or prior forcefeeding. */ 4330 if (((opts.display !== undefined && opts.display !== null && opts.display !== "none") || (opts.visibility !== undefined && opts.visibility !== "hidden")) && /opacity|filter/.test(property) && !startValue && endValue !== 0) { 4331 startValue = 0; 4332 } 4333 4334 /* If values have been transferred from the previous Velocity call, extract the endValue and rootPropertyValue 4335 for all of the current call's properties that were *also* animated in the previous call. */ 4336 /* Note: Value transferring can optionally be disabled by the user via the _cacheValues option. */ 4337 if (opts._cacheValues && lastTweensContainer && lastTweensContainer[property]) { 4338 if (startValue === undefined) { 4339 startValue = lastTweensContainer[property].endValue + lastTweensContainer[property].unitType; 4340 } 4341 4342 /* The previous call's rootPropertyValue is extracted from the element's data cache since that's the 4343 instance of rootPropertyValue that gets freshly updated by the tweening process, whereas the rootPropertyValue 4344 attached to the incoming lastTweensContainer is equal to the root property's value prior to any tweening. */ 4345 rootPropertyValue = data.rootPropertyValueCache[rootProperty]; 4346 /* If values were not transferred from a previous Velocity call, query the DOM as needed. */ 4347 } else { 4348 /* Handle hooked properties. */ 4349 if (CSS.Hooks.registered[property]) { 4350 if (startValue === undefined) { 4351 rootPropertyValue = CSS.getPropertyValue(element, rootProperty); /* GET */ 4352 /* Note: The following getPropertyValue() call does not actually trigger a DOM query; 4353 getPropertyValue() will extract the hook from rootPropertyValue. */ 4354 startValue = CSS.getPropertyValue(element, property, rootPropertyValue); 4355 /* If startValue is already defined via forcefeeding, do not query the DOM for the root property's value; 4356 just grab rootProperty's zero-value template from CSS.Hooks. This overwrites the element's actual 4357 root property value (if one is set), but this is acceptable since the primary reason users forcefeed is 4358 to avoid DOM queries, and thus we likewise avoid querying the DOM for the root property's value. */ 4359 } else { 4360 /* Grab this hook's zero-value template, e.g. "0px 0px 0px black". */ 4361 rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; 4362 } 4363 /* Handle non-hooked properties that haven't already been defined via forcefeeding. */ 4364 } else if (startValue === undefined) { 4365 startValue = CSS.getPropertyValue(element, property); /* GET */ 4366 } 4367 } 4368 4369 /************************** 4370 Value Data Extraction 4371 **************************/ 4372 4373 var separatedValue, 4374 endValueUnitType, 4375 startValueUnitType, 4376 operator = false; 4377 4378 /* Separates a property value into its numeric value and its unit type. */ 4379 var separateValue = function(property, value) { 4380 var unitType, 4381 numericValue; 4382 4383 numericValue = (value || "0") 4384 .toString() 4385 .toLowerCase() 4386 /* Match the unit type at the end of the value. */ 4387 .replace(/[%A-z]+$/, function(match) { 4388 /* Grab the unit type. */ 4389 unitType = match; 4390 4391 /* Strip the unit type off of value. */ 4392 return ""; 4393 }); 4394 4395 /* If no unit type was supplied, assign one that is appropriate for this property (e.g. "deg" for rotateZ or "px" for width). */ 4396 if (!unitType) { 4397 unitType = CSS.Values.getUnitType(property); 4398 } 4399 4400 return [numericValue, unitType]; 4401 }; 4402 4403 if (startValue !== endValue && Type.isString(startValue) && Type.isString(endValue)) { 4404 pattern = ""; 4405 var iStart = 0, // index in startValue 4406 iEnd = 0, // index in endValue 4407 aStart = [], // array of startValue numbers 4408 aEnd = [], // array of endValue numbers 4409 inCalc = 0, // Keep track of being inside a "calc()" so we don't duplicate it 4410 inRGB = 0, // Keep track of being inside an RGB as we can't use fractional values 4411 inRGBA = 0; // Keep track of being inside an RGBA as we must pass fractional for the alpha channel 4412 4413 startValue = CSS.Hooks.fixColors(startValue); 4414 endValue = CSS.Hooks.fixColors(endValue); 4415 while (iStart < startValue.length && iEnd < endValue.length) { 4416 var cStart = startValue[iStart], 4417 cEnd = endValue[iEnd]; 4418 4419 if (/[\d\.-]/.test(cStart) && /[\d\.-]/.test(cEnd)) { 4420 var tStart = cStart, // temporary character buffer 4421 tEnd = cEnd, // temporary character buffer 4422 dotStart = ".", // Make sure we can only ever match a single dot in a decimal 4423 dotEnd = "."; // Make sure we can only ever match a single dot in a decimal 4424 4425 while (++iStart < startValue.length) { 4426 cStart = startValue[iStart]; 4427 if (cStart === dotStart) { 4428 dotStart = ".."; // Can never match two characters 4429 } else if (!/\d/.test(cStart)) { 4430 break; 4431 } 4432 tStart += cStart; 4433 } 4434 while (++iEnd < endValue.length) { 4435 cEnd = endValue[iEnd]; 4436 if (cEnd === dotEnd) { 4437 dotEnd = ".."; // Can never match two characters 4438 } else if (!/\d/.test(cEnd)) { 4439 break; 4440 } 4441 tEnd += cEnd; 4442 } 4443 var uStart = CSS.Hooks.getUnit(startValue, iStart), // temporary unit type 4444 uEnd = CSS.Hooks.getUnit(endValue, iEnd); // temporary unit type 4445 4446 iStart += uStart.length; 4447 iEnd += uEnd.length; 4448 if (uStart === uEnd) { 4449 // Same units 4450 if (tStart === tEnd) { 4451 // Same numbers, so just copy over 4452 pattern += tStart + uStart; 4453 } else { 4454 // Different numbers, so store them 4455 pattern += "{" + aStart.length + (inRGB ? "!" : "") + "}" + uStart; 4456 aStart.push(parseFloat(tStart)); 4457 aEnd.push(parseFloat(tEnd)); 4458 } 4459 } else { 4460 // Different units, so put into a "calc(from + to)" and animate each side to/from zero 4461 var nStart = parseFloat(tStart), 4462 nEnd = parseFloat(tEnd); 4463 4464 pattern += (inCalc < 5 ? "calc" : "") + "(" 4465 + (nStart ? "{" + aStart.length + (inRGB ? "!" : "") + "}" : "0") + uStart 4466 + " + " 4467 + (nEnd ? "{" + (aStart.length + (nStart ? 1 : 0)) + (inRGB ? "!" : "") + "}" : "0") + uEnd 4468 + ")"; 4469 if (nStart) { 4470 aStart.push(nStart); 4471 aEnd.push(0); 4472 } 4473 if (nEnd) { 4474 aStart.push(0); 4475 aEnd.push(nEnd); 4476 } 4477 } 4478 } else if (cStart === cEnd) { 4479 pattern += cStart; 4480 iStart++; 4481 iEnd++; 4482 // Keep track of being inside a calc() 4483 if (inCalc === 0 && cStart === "c" 4484 || inCalc === 1 && cStart === "a" 4485 || inCalc === 2 && cStart === "l" 4486 || inCalc === 3 && cStart === "c" 4487 || inCalc >= 4 && cStart === "(" 4488 ) { 4489 inCalc++; 4490 } else if ((inCalc && inCalc < 5) 4491 || inCalc >= 4 && cStart === ")" && --inCalc < 5) { 4492 inCalc = 0; 4493 } 4494 // Keep track of being inside an rgb() / rgba() 4495 if (inRGB === 0 && cStart === "r" 4496 || inRGB === 1 && cStart === "g" 4497 || inRGB === 2 && cStart === "b" 4498 || inRGB === 3 && cStart === "a" 4499 || inRGB >= 3 && cStart === "(" 4500 ) { 4501 if (inRGB === 3 && cStart === "a") { 4502 inRGBA = 1; 4503 } 4504 inRGB++; 4505 } else if (inRGBA && cStart === ",") { 4506 if (++inRGBA > 3) { 4507 inRGB = inRGBA = 0; 4508 } 4509 } else if ((inRGBA && inRGB < (inRGBA ? 5 : 4)) 4510 || inRGB >= (inRGBA ? 4 : 3) && cStart === ")" && --inRGB < (inRGBA ? 5 : 4)) { 4511 inRGB = inRGBA = 0; 4512 } 4513 } else { 4514 inCalc = 0; 4515 // TODO: changing units, fixing colours 4516 break; 4517 } 4518 } 4519 if (iStart !== startValue.length || iEnd !== endValue.length) { 4520 if (Velocity.debug) { 4521 console.error("Trying to pattern match mis-matched strings [\"" + endValue + "\", \"" + startValue + "\"]"); 4522 } 4523 pattern = undefined; 4524 } 4525 if (pattern) { 4526 if (aStart.length) { 4527 if (Velocity.debug) { 4528 console.log("Pattern found \"" + pattern + "\" -> ", aStart, aEnd, "[" + startValue + "," + endValue + "]"); 4529 } 4530 startValue = aStart; 4531 endValue = aEnd; 4532 endValueUnitType = startValueUnitType = ""; 4533 } else { 4534 pattern = undefined; 4535 } 4536 } 4537 } 4538 4539 if (!pattern) { 4540 /* Separate startValue. */ 4541 separatedValue = separateValue(property, startValue); 4542 startValue = separatedValue[0]; 4543 startValueUnitType = separatedValue[1]; 4544 4545 /* Separate endValue, and extract a value operator (e.g. "+=", "-=") if one exists. */ 4546 separatedValue = separateValue(property, endValue); 4547 endValue = separatedValue[0].replace(/^([+-\/*])=/, function(match, subMatch) { 4548 operator = subMatch; 4549 4550 /* Strip the operator off of the value. */ 4551 return ""; 4552 }); 4553 endValueUnitType = separatedValue[1]; 4554 4555 /* Parse float values from endValue and startValue. Default to 0 if NaN is returned. */ 4556 startValue = parseFloat(startValue) || 0; 4557 endValue = parseFloat(endValue) || 0; 4558 4559 /*************************************** 4560 Property-Specific Value Conversion 4561 ***************************************/ 4562 4563 /* Custom support for properties that don't actually accept the % unit type, but where pollyfilling is trivial and relatively foolproof. */ 4564 if (endValueUnitType === "%") { 4565 /* A %-value fontSize/lineHeight is relative to the parent's fontSize (as opposed to the parent's dimensions), 4566 which is identical to the em unit's behavior, so we piggyback off of that. */ 4567 if (/^(fontSize|lineHeight)$/.test(property)) { 4568 /* Convert % into an em decimal value. */ 4569 endValue = endValue / 100; 4570 endValueUnitType = "em"; 4571 /* For scaleX and scaleY, convert the value into its decimal format and strip off the unit type. */ 4572 } else if (/^scale/.test(property)) { 4573 endValue = endValue / 100; 4574 endValueUnitType = ""; 4575 /* For RGB components, take the defined percentage of 255 and strip off the unit type. */ 4576 } else if (/(Red|Green|Blue)$/i.test(property)) { 4577 endValue = (endValue / 100) * 255; 4578 endValueUnitType = ""; 4579 } 4580 } 4581 } 4582 4583 /*************************** 4584 Unit Ratio Calculation 4585 ***************************/ 4586 4587 /* When queried, the browser returns (most) CSS property values in pixels. Therefore, if an endValue with a unit type of 4588 %, em, or rem is animated toward, startValue must be converted from pixels into the same unit type as endValue in order 4589 for value manipulation logic (increment/decrement) to proceed. Further, if the startValue was forcefed or transferred 4590 from a previous call, startValue may also not be in pixels. Unit conversion logic therefore consists of two steps: 4591 1) Calculating the ratio of %/em/rem/vh/vw relative to pixels 4592 2) Converting startValue into the same unit of measurement as endValue based on these ratios. */ 4593 /* Unit conversion ratios are calculated by inserting a sibling node next to the target node, copying over its position property, 4594 setting values with the target unit type then comparing the returned pixel value. */ 4595 /* Note: Even if only one of these unit types is being animated, all unit ratios are calculated at once since the overhead 4596 of batching the SETs and GETs together upfront outweights the potential overhead 4597 of layout thrashing caused by re-querying for uncalculated ratios for subsequently-processed properties. */ 4598 /* Todo: Shift this logic into the calls' first tick instance so that it's synced with RAF. */ 4599 var calculateUnitRatios = function() { 4600 4601 /************************ 4602 Same Ratio Checks 4603 ************************/ 4604 4605 /* The properties below are used to determine whether the element differs sufficiently from this call's 4606 previously iterated element to also differ in its unit conversion ratios. If the properties match up with those 4607 of the prior element, the prior element's conversion ratios are used. Like most optimizations in Velocity, 4608 this is done to minimize DOM querying. */ 4609 var sameRatioIndicators = { 4610 myParent: element.parentNode || document.body, /* GET */ 4611 position: CSS.getPropertyValue(element, "position"), /* GET */ 4612 fontSize: CSS.getPropertyValue(element, "fontSize") /* GET */ 4613 }, 4614 /* Determine if the same % ratio can be used. % is based on the element's position value and its parent's width and height dimensions. */ 4615 samePercentRatio = ((sameRatioIndicators.position === callUnitConversionData.lastPosition) && (sameRatioIndicators.myParent === callUnitConversionData.lastParent)), 4616 /* Determine if the same em ratio can be used. em is relative to the element's fontSize. */ 4617 sameEmRatio = (sameRatioIndicators.fontSize === callUnitConversionData.lastFontSize); 4618 4619 /* Store these ratio indicators call-wide for the next element to compare against. */ 4620 callUnitConversionData.lastParent = sameRatioIndicators.myParent; 4621 callUnitConversionData.lastPosition = sameRatioIndicators.position; 4622 callUnitConversionData.lastFontSize = sameRatioIndicators.fontSize; 4623 4624 /*************************** 4625 Element-Specific Units 4626 ***************************/ 4627 4628 /* Note: IE8 rounds to the nearest pixel when returning CSS values, thus we perform conversions using a measurement 4629 of 100 (instead of 1) to give our ratios a precision of at least 2 decimal values. */ 4630 var measurement = 100, 4631 unitRatios = {}; 4632 4633 if (!sameEmRatio || !samePercentRatio) { 4634 var dummy = data && data.isSVG ? document.createElementNS("http://www.w3.org/2000/svg", "rect") : document.createElement("div"); 4635 4636 Velocity.init(dummy); 4637 sameRatioIndicators.myParent.appendChild(dummy); 4638 4639 /* To accurately and consistently calculate conversion ratios, the element's cascaded overflow and box-sizing are stripped. 4640 Similarly, since width/height can be artificially constrained by their min-/max- equivalents, these are controlled for as well. */ 4641 /* Note: Overflow must be also be controlled for per-axis since the overflow property overwrites its per-axis values. */ 4642 $.each(["overflow", "overflowX", "overflowY"], function(i, property) { 4643 Velocity.CSS.setPropertyValue(dummy, property, "hidden"); 4644 }); 4645 Velocity.CSS.setPropertyValue(dummy, "position", sameRatioIndicators.position); 4646 Velocity.CSS.setPropertyValue(dummy, "fontSize", sameRatioIndicators.fontSize); 4647 Velocity.CSS.setPropertyValue(dummy, "boxSizing", "content-box"); 4648 4649 /* width and height act as our proxy properties for measuring the horizontal and vertical % ratios. */ 4650 $.each(["minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height"], function(i, property) { 4651 Velocity.CSS.setPropertyValue(dummy, property, measurement + "%"); 4652 }); 4653 /* paddingLeft arbitrarily acts as our proxy property for the em ratio. */ 4654 Velocity.CSS.setPropertyValue(dummy, "paddingLeft", measurement + "em"); 4655 4656 /* Divide the returned value by the measurement to get the ratio between 1% and 1px. Default to 1 since working with 0 can produce Infinite. */ 4657 unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth = (parseFloat(CSS.getPropertyValue(dummy, "width", null, true)) || 1) / measurement; /* GET */ 4658 unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight = (parseFloat(CSS.getPropertyValue(dummy, "height", null, true)) || 1) / measurement; /* GET */ 4659 unitRatios.emToPx = callUnitConversionData.lastEmToPx = (parseFloat(CSS.getPropertyValue(dummy, "paddingLeft")) || 1) / measurement; /* GET */ 4660 4661 sameRatioIndicators.myParent.removeChild(dummy); 4662 } else { 4663 unitRatios.emToPx = callUnitConversionData.lastEmToPx; 4664 unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth; 4665 unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight; 4666 } 4667 4668 /*************************** 4669 Element-Agnostic Units 4670 ***************************/ 4671 4672 /* Whereas % and em ratios are determined on a per-element basis, the rem unit only needs to be checked 4673 once per call since it's exclusively dependant upon document.body's fontSize. If this is the first time 4674 that calculateUnitRatios() is being run during this call, remToPx will still be set to its default value of null, 4675 so we calculate it now. */ 4676 if (callUnitConversionData.remToPx === null) { 4677 /* Default to browsers' default fontSize of 16px in the case of 0. */ 4678 callUnitConversionData.remToPx = parseFloat(CSS.getPropertyValue(document.body, "fontSize")) || 16; /* GET */ 4679 } 4680 4681 /* Similarly, viewport units are %-relative to the window's inner dimensions. */ 4682 if (callUnitConversionData.vwToPx === null) { 4683 callUnitConversionData.vwToPx = parseFloat(window.innerWidth) / 100; /* GET */ 4684 callUnitConversionData.vhToPx = parseFloat(window.innerHeight) / 100; /* GET */ 4685 } 4686 4687 unitRatios.remToPx = callUnitConversionData.remToPx; 4688 unitRatios.vwToPx = callUnitConversionData.vwToPx; 4689 unitRatios.vhToPx = callUnitConversionData.vhToPx; 4690 4691 if (Velocity.debug >= 1) { 4692 console.log("Unit ratios: " + JSON.stringify(unitRatios), element); 4693 } 4694 return unitRatios; 4695 }; 4696 4697 /******************** 4698 Unit Conversion 4699 ********************/ 4700 4701 /* The * and / operators, which are not passed in with an associated unit, inherently use startValue's unit. Skip value and unit conversion. */ 4702 if (/[\/*]/.test(operator)) { 4703 endValueUnitType = startValueUnitType; 4704 /* If startValue and endValue differ in unit type, convert startValue into the same unit type as endValue so that if endValueUnitType 4705 is a relative unit (%, em, rem), the values set during tweening will continue to be accurately relative even if the metrics they depend 4706 on are dynamically changing during the course of the animation. Conversely, if we always normalized into px and used px for setting values, the px ratio 4707 would become stale if the original unit being animated toward was relative and the underlying metrics change during the animation. */ 4708 /* Since 0 is 0 in any unit type, no conversion is necessary when startValue is 0 -- we just start at 0 with endValueUnitType. */ 4709 } else if ((startValueUnitType !== endValueUnitType) && startValue !== 0) { 4710 /* Unit conversion is also skipped when endValue is 0, but *startValueUnitType* must be used for tween values to remain accurate. */ 4711 /* Note: Skipping unit conversion here means that if endValueUnitType was originally a relative unit, the animation won't relatively 4712 match the underlying metrics if they change, but this is acceptable since we're animating toward invisibility instead of toward visibility, 4713 which remains past the point of the animation's completion. */ 4714 if (endValue === 0) { 4715 endValueUnitType = startValueUnitType; 4716 } else { 4717 /* By this point, we cannot avoid unit conversion (it's undesirable since it causes layout thrashing). 4718 If we haven't already, we trigger calculateUnitRatios(), which runs once per element per call. */ 4719 elementUnitConversionData = elementUnitConversionData || calculateUnitRatios(); 4720 4721 /* The following RegEx matches CSS properties that have their % values measured relative to the x-axis. */ 4722 /* Note: W3C spec mandates that all of margin and padding's properties (even top and bottom) are %-relative to the *width* of the parent element. */ 4723 var axis = (/margin|padding|left|right|width|text|word|letter/i.test(property) || /X$/.test(property) || property === "x") ? "x" : "y"; 4724 4725 /* In order to avoid generating n^2 bespoke conversion functions, unit conversion is a two-step process: 4726 1) Convert startValue into pixels. 2) Convert this new pixel value into endValue's unit type. */ 4727 switch (startValueUnitType) { 4728 case "%": 4729 /* Note: translateX and translateY are the only properties that are %-relative to an element's own dimensions -- not its parent's dimensions. 4730 Velocity does not include a special conversion process to account for this behavior. Therefore, animating translateX/Y from a % value 4731 to a non-% value will produce an incorrect start value. Fortunately, this sort of cross-unit conversion is rarely done by users in practice. */ 4732 startValue *= (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); 4733 break; 4734 4735 case "px": 4736 /* px acts as our midpoint in the unit conversion process; do nothing. */ 4737 break; 4738 4739 default: 4740 startValue *= elementUnitConversionData[startValueUnitType + "ToPx"]; 4741 } 4742 4743 /* Invert the px ratios to convert into to the target unit. */ 4744 switch (endValueUnitType) { 4745 case "%": 4746 startValue *= 1 / (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); 4747 break; 4748 4749 case "px": 4750 /* startValue is already in px, do nothing; we're done. */ 4751 break; 4752 4753 default: 4754 startValue *= 1 / elementUnitConversionData[endValueUnitType + "ToPx"]; 4755 } 4756 } 4757 } 4758 4759 /********************* 4760 Relative Values 4761 *********************/ 4762 4763 /* Operator logic must be performed last since it requires unit-normalized start and end values. */ 4764 /* Note: Relative *percent values* do not behave how most people think; while one would expect "+=50%" 4765 to increase the property 1.5x its current value, it in fact increases the percent units in absolute terms: 4766 50 points is added on top of the current % value. */ 4767 switch (operator) { 4768 case "+": 4769 endValue = startValue + endValue; 4770 break; 4771 4772 case "-": 4773 endValue = startValue - endValue; 4774 break; 4775 4776 case "*": 4777 endValue = startValue * endValue; 4778 break; 4779 4780 case "/": 4781 endValue = startValue / endValue; 4782 break; 4783 } 4784 4785 /************************** 4786 tweensContainer Push 4787 **************************/ 4788 4789 /* Construct the per-property tween object, and push it to the element's tweensContainer. */ 4790 tweensContainer[property] = { 4791 rootPropertyValue: rootPropertyValue, 4792 startValue: startValue, 4793 currentValue: startValue, 4794 endValue: endValue, 4795 unitType: endValueUnitType, 4796 easing: easing 4797 }; 4798 if (pattern) { 4799 tweensContainer[property].pattern = pattern; 4800 } 4801 4802 if (Velocity.debug) { 4803 console.log("tweensContainer (" + property + "): " + JSON.stringify(tweensContainer[property]), element); 4804 } 4805 }; 4806 4807 /* Create a tween out of each property, and append its associated data to tweensContainer. */ 4808 for (var property in propertiesMap) { 4809 4810 if (!propertiesMap.hasOwnProperty(property)) { 4811 continue; 4812 } 4813 /* The original property name's format must be used for the parsePropertyValue() lookup, 4814 but we then use its camelCase styling to normalize it for manipulation. */ 4815 var propertyName = CSS.Names.camelCase(property), 4816 valueData = parsePropertyValue(propertiesMap[property]); 4817 4818 /* Find shorthand color properties that have been passed a hex string. */ 4819 /* Would be quicker to use CSS.Lists.colors.includes() if possible */ 4820 if (_inArray(CSS.Lists.colors, propertyName)) { 4821 /* Parse the value data for each shorthand. */ 4822 var endValue = valueData[0], 4823 easing = valueData[1], 4824 startValue = valueData[2]; 4825 4826 if (CSS.RegEx.isHex.test(endValue)) { 4827 /* Convert the hex strings into their RGB component arrays. */ 4828 var colorComponents = ["Red", "Green", "Blue"], 4829 endValueRGB = CSS.Values.hexToRgb(endValue), 4830 startValueRGB = startValue ? CSS.Values.hexToRgb(startValue) : undefined; 4831 4832 /* Inject the RGB component tweens into propertiesMap. */ 4833 for (var i = 0; i < colorComponents.length; i++) { 4834 var dataArray = [endValueRGB[i]]; 4835 4836 if (easing) { 4837 dataArray.push(easing); 4838 } 4839 4840 if (startValueRGB !== undefined) { 4841 dataArray.push(startValueRGB[i]); 4842 } 4843 4844 fixPropertyValue(propertyName + colorComponents[i], dataArray); 4845 } 4846 /* If we have replaced a shortcut color value then don't update the standard property name */ 4847 continue; 4848 } 4849 } 4850 fixPropertyValue(propertyName, valueData); 4851 } 4852 4853 /* Along with its property data, store a reference to the element itself onto tweensContainer. */ 4854 tweensContainer.element = element; 4855 } 4856 4857 /***************** 4858 Call Push 4859 *****************/ 4860 4861 /* Note: tweensContainer can be empty if all of the properties in this call's property map were skipped due to not 4862 being supported by the browser. The element property is used for checking that the tweensContainer has been appended to. */ 4863 if (tweensContainer.element) { 4864 /* Apply the "velocity-animating" indicator class. */ 4865 CSS.Values.addClass(element, "velocity-animating"); 4866 4867 /* The call array houses the tweensContainers for each element being animated in the current call. */ 4868 call.push(tweensContainer); 4869 4870 data = Data(element); 4871 4872 if (data) { 4873 /* Store the tweensContainer and options if we're working on the default effects queue, so that they can be used by the reverse command. */ 4874 if (opts.queue === "") { 4875 4876 data.tweensContainer = tweensContainer; 4877 data.opts = opts; 4878 } 4879 4880 /* Switch on the element's animating flag. */ 4881 data.isAnimating = true; 4882 } 4883 4884 /* Once the final element in this call's element set has been processed, push the call array onto 4885 Velocity.State.calls for the animation tick to immediately begin processing. */ 4886 if (elementsIndex === elementsLength - 1) { 4887 /* Add the current call plus its associated metadata (the element set and the call's options) onto the global call container. 4888 Anything on this call container is subjected to tick() processing. */ 4889 Velocity.State.calls.push([call, elements, opts, null, promiseData.resolver, null, 0]); 4890 4891 /* If the animation tick isn't running, start it. (Velocity shuts it off when there are no active calls to process.) */ 4892 if (Velocity.State.isTicking === false) { 4893 Velocity.State.isTicking = true; 4894 4895 /* Start the tick loop. */ 4896 tick(); 4897 } 4898 } else { 4899 elementsIndex++; 4900 } 4901 } 4902 } 4903 4904 /* When the queue option is set to false, the call skips the element's queue and fires immediately. */ 4905 if (opts.queue === false) { 4906 /* Since this buildQueue call doesn't respect the element's existing queue (which is where a delay option would have been appended), 4907 we manually inject the delay property here with an explicit setTimeout. */ 4908 if (opts.delay) { 4909 4910 /* Temporarily store delayed elements to facilitate access for global pause/resume */ 4911 var callIndex = Velocity.State.delayedElements.count++; 4912 Velocity.State.delayedElements[callIndex] = element; 4913 4914 var delayComplete = (function(index) { 4915 return function() { 4916 /* Clear the temporary element */ 4917 Velocity.State.delayedElements[index] = false; 4918 4919 /* Finally, issue the call */ 4920 buildQueue(); 4921 }; 4922 })(callIndex); 4923 4924 Data(element).delayBegin = (new Date()).getTime(); 4925 Data(element).delay = parseFloat(opts.delay); 4926 Data(element).delayTimer = { 4927 setTimeout: setTimeout(buildQueue, parseFloat(opts.delay)), 4928 next: delayComplete 4929 }; 4930 } else { 4931 buildQueue(); 4932 } 4933 /* Otherwise, the call undergoes element queueing as normal. */ 4934 /* Note: To interoperate with jQuery, Velocity uses jQuery's own $.queue() stack for queuing logic. */ 4935 } else { 4936 $.queue(element, opts.queue, function(next, clearQueue) { 4937 /* If the clearQueue flag was passed in by the stop command, resolve this call's promise. (Promises can only be resolved once, 4938 so it's fine if this is repeatedly triggered for each element in the associated call.) */ 4939 if (clearQueue === true) { 4940 if (promiseData.promise) { 4941 promiseData.resolver(elements); 4942 } 4943 4944 /* Do not continue with animation queueing. */ 4945 return true; 4946 } 4947 4948 /* This flag indicates to the upcoming completeCall() function that this queue entry was initiated by Velocity. 4949 See completeCall() for further details. */ 4950 Velocity.velocityQueueEntryFlag = true; 4951 4952 buildQueue(next); 4953 }); 4954 } 4955 4956 /********************* 4957 Auto-Dequeuing 4958 *********************/ 4959 4960 /* As per jQuery's $.queue() behavior, to fire the first non-custom-queue entry on an element, the element 4961 must be dequeued if its queue stack consists *solely* of the current call. (This can be determined by checking 4962 for the "inprogress" item that jQuery prepends to active queue stack arrays.) Regardless, whenever the element's 4963 queue is further appended with additional items -- including $.delay()'s or even $.animate() calls, the queue's 4964 first entry is automatically fired. This behavior contrasts that of custom queues, which never auto-fire. */ 4965 /* Note: When an element set is being subjected to a non-parallel Velocity call, the animation will not begin until 4966 each one of the elements in the set has reached the end of its individually pre-existing queue chain. */ 4967 /* Note: Unfortunately, most people don't fully grasp jQuery's powerful, yet quirky, $.queue() function. 4968 Lean more here: http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me */ 4969 if ((opts.queue === "" || opts.queue === "fx") && $.queue(element)[0] !== "inprogress") { 4970 $.dequeue(element); 4971 } 4972 } 4973 4974 /************************** 4975 Element Set Iteration 4976 **************************/ 4977 4978 /* If the "nodeType" property exists on the elements variable, we're animating a single element. 4979 Place it in an array so that $.each() can iterate over it. */ 4980 $.each(elements, function(i, element) { 4981 /* Ensure each element in a set has a nodeType (is a real element) to avoid throwing errors. */ 4982 if (Type.isNode(element)) { 4983 processElement(element, i); 4984 } 4985 }); 4986 4987 /****************** 4988 Option: Loop 4989 ******************/ 4990 4991 /* The loop option accepts an integer indicating how many times the element should loop between the values in the 4992 current call's properties map and the element's property values prior to this call. */ 4993 /* Note: The loop option's logic is performed here -- after element processing -- because the current call needs 4994 to undergo its queue insertion prior to the loop option generating its series of constituent "reverse" calls, 4995 which chain after the current call. Two reverse calls (two "alternations") constitute one loop. */ 4996 opts = $.extend({}, Velocity.defaults, options); 4997 opts.loop = parseInt(opts.loop, 10); 4998 var reverseCallsCount = (opts.loop * 2) - 1; 4999 5000 if (opts.loop) { 5001 /* Double the loop count to convert it into its appropriate number of "reverse" calls. 5002 Subtract 1 from the resulting value since the current call is included in the total alternation count. */ 5003 for (var x = 0; x < reverseCallsCount; x++) { 5004 /* Since the logic for the reverse action occurs inside Queueing and therefore this call's options object 5005 isn't parsed until then as well, the current call's delay option must be explicitly passed into the reverse 5006 call so that the delay logic that occurs inside *Pre-Queueing* can process it. */ 5007 var reverseOptions = { 5008 delay: opts.delay, 5009 progress: opts.progress 5010 }; 5011 5012 /* If a complete callback was passed into this call, transfer it to the loop redirect's final "reverse" call 5013 so that it's triggered when the entire redirect is complete (and not when the very first animation is complete). */ 5014 if (x === reverseCallsCount - 1) { 5015 reverseOptions.display = opts.display; 5016 reverseOptions.visibility = opts.visibility; 5017 reverseOptions.complete = opts.complete; 5018 } 5019 5020 animate(elements, "reverse", reverseOptions); 5021 } 5022 } 5023 5024 /*************** 5025 Chaining 5026 ***************/ 5027 5028 /* Return the elements back to the call chain, with wrapped elements taking precedence in case Velocity was called via the $.fn. extension. */ 5029 return getChain(); 5030 }; 5031 5032 /* Turn Velocity into the animation function, extended with the pre-existing Velocity object. */ 5033 Velocity = $.extend(animate, Velocity); 5034 /* For legacy support, also expose the literal animate method. */ 5035 Velocity.animate = animate; 5036 5037 /************** 5038 Timing 5039 **************/ 5040 5041 /* Ticker function. */ 5042 var ticker = window.requestAnimationFrame || rAFShim; 5043 5044 /* Inactive browser tabs pause rAF, which results in all active animations immediately sprinting to their completion states when the tab refocuses. 5045 To get around this, we dynamically switch rAF to setTimeout (which the browser *doesn't* pause) when the tab loses focus. We skip this for mobile 5046 devices to avoid wasting battery power on inactive tabs. */ 5047 /* Note: Tab focus detection doesn't work on older versions of IE, but that's okay since they don't support rAF to begin with. */ 5048 if (!Velocity.State.isMobile && document.hidden !== undefined) { 5049 var updateTicker = function() { 5050 /* Reassign the rAF function (which the global tick() function uses) based on the tab's focus state. */ 5051 if (document.hidden) { 5052 ticker = function(callback) { 5053 /* The tick function needs a truthy first argument in order to pass its internal timestamp check. */ 5054 return setTimeout(function() { 5055 callback(true); 5056 }, 16); 5057 }; 5058 5059 /* The rAF loop has been paused by the browser, so we manually restart the tick. */ 5060 tick(); 5061 } else { 5062 ticker = window.requestAnimationFrame || rAFShim; 5063 } 5064 }; 5065 5066 /* Page could be sitting in the background at this time (i.e. opened as new tab) so making sure we use correct ticker from the start */ 5067 updateTicker(); 5068 5069 /* And then run check again every time visibility changes */ 5070 document.addEventListener("visibilitychange", updateTicker); 5071 } 5072 5073 /************ 5074 Tick 5075 ************/ 5076 5077 /* Note: All calls to Velocity are pushed to the Velocity.State.calls array, which is fully iterated through upon each tick. */ 5078 function tick(timestamp) { 5079 /* An empty timestamp argument indicates that this is the first tick occurence since ticking was turned on. 5080 We leverage this metadata to fully ignore the first tick pass since RAF's initial pass is fired whenever 5081 the browser's next tick sync time occurs, which results in the first elements subjected to Velocity 5082 calls being animated out of sync with any elements animated immediately thereafter. In short, we ignore 5083 the first RAF tick pass so that elements being immediately consecutively animated -- instead of simultaneously animated 5084 by the same Velocity call -- are properly batched into the same initial RAF tick and consequently remain in sync thereafter. */ 5085 if (timestamp) { 5086 /* We normally use RAF's high resolution timestamp but as it can be significantly offset when the browser is 5087 under high stress we give the option for choppiness over allowing the browser to drop huge chunks of frames. 5088 We use performance.now() and shim it if it doesn't exist for when the tab is hidden. */ 5089 var timeCurrent = Velocity.timestamp && timestamp !== true ? timestamp : performance.now(); 5090 5091 /******************** 5092 Call Iteration 5093 ********************/ 5094 5095 var callsLength = Velocity.State.calls.length; 5096 5097 /* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed) 5098 when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation 5099 has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */ 5100 if (callsLength > 10000) { 5101 Velocity.State.calls = compactSparseArray(Velocity.State.calls); 5102 callsLength = Velocity.State.calls.length; 5103 } 5104 5105 /* Iterate through each active call. */ 5106 for (var i = 0; i < callsLength; i++) { 5107 /* When a Velocity call is completed, its Velocity.State.calls entry is set to false. Continue on to the next call. */ 5108 if (!Velocity.State.calls[i]) { 5109 continue; 5110 } 5111 5112 /************************ 5113 Call-Wide Variables 5114 ************************/ 5115 5116 var callContainer = Velocity.State.calls[i], 5117 call = callContainer[0], 5118 opts = callContainer[2], 5119 timeStart = callContainer[3], 5120 firstTick = !timeStart, 5121 tweenDummyValue = null, 5122 pauseObject = callContainer[5], 5123 millisecondsEllapsed = callContainer[6]; 5124 5125 5126 5127 /* If timeStart is undefined, then this is the first time that this call has been processed by tick(). 5128 We assign timeStart now so that its value is as close to the real animation start time as possible. 5129 (Conversely, had timeStart been defined when this call was added to Velocity.State.calls, the delay 5130 between that time and now would cause the first few frames of the tween to be skipped since 5131 percentComplete is calculated relative to timeStart.) */ 5132 /* Further, subtract 16ms (the approximate resolution of RAF) from the current time value so that the 5133 first tick iteration isn't wasted by animating at 0% tween completion, which would produce the 5134 same style value as the element's current value. */ 5135 if (!timeStart) { 5136 timeStart = Velocity.State.calls[i][3] = timeCurrent - 16; 5137 } 5138 5139 /* If a pause object is present, skip processing unless it has been set to resume */ 5140 if (pauseObject) { 5141 if (pauseObject.resume === true) { 5142 /* Update the time start to accomodate the paused completion amount */ 5143 timeStart = callContainer[3] = Math.round(timeCurrent - millisecondsEllapsed - 16); 5144 5145 /* Remove pause object after processing */ 5146 callContainer[5] = null; 5147 } else { 5148 continue; 5149 } 5150 } 5151 5152 millisecondsEllapsed = callContainer[6] = timeCurrent - timeStart; 5153 5154 /* The tween's completion percentage is relative to the tween's start time, not the tween's start value 5155 (which would result in unpredictable tween durations since JavaScript's timers are not particularly accurate). 5156 Accordingly, we ensure that percentComplete does not exceed 1. */ 5157 var percentComplete = Math.min((millisecondsEllapsed) / opts.duration, 1); 5158 5159 /********************** 5160 Element Iteration 5161 **********************/ 5162 5163 /* For every call, iterate through each of the elements in its set. */ 5164 for (var j = 0, callLength = call.length; j < callLength; j++) { 5165 var tweensContainer = call[j], 5166 element = tweensContainer.element; 5167 5168 /* Check to see if this element has been deleted midway through the animation by checking for the 5169 continued existence of its data cache. If it's gone, or the element is currently paused, skip animating this element. */ 5170 if (!Data(element)) { 5171 continue; 5172 } 5173 5174 var transformPropertyExists = false; 5175 5176 /********************************** 5177 Display & Visibility Toggling 5178 **********************************/ 5179 5180 /* If the display option is set to non-"none", set it upfront so that the element can become visible before tweening begins. 5181 (Otherwise, display's "none" value is set in completeCall() once the animation has completed.) */ 5182 if (opts.display !== undefined && opts.display !== null && opts.display !== "none") { 5183 if (opts.display === "flex") { 5184 var flexValues = ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex"]; 5185 5186 $.each(flexValues, function(i, flexValue) { 5187 CSS.setPropertyValue(element, "display", flexValue); 5188 }); 5189 } 5190 5191 CSS.setPropertyValue(element, "display", opts.display); 5192 } 5193 5194 /* Same goes with the visibility option, but its "none" equivalent is "hidden". */ 5195 if (opts.visibility !== undefined && opts.visibility !== "hidden") { 5196 CSS.setPropertyValue(element, "visibility", opts.visibility); 5197 } 5198 5199 /************************ 5200 Property Iteration 5201 ************************/ 5202 5203 /* For every element, iterate through each property. */ 5204 for (var property in tweensContainer) { 5205 /* Note: In addition to property tween data, tweensContainer contains a reference to its associated element. */ 5206 if (tweensContainer.hasOwnProperty(property) && property !== "element") { 5207 var tween = tweensContainer[property], 5208 currentValue, 5209 /* Easing can either be a pre-genereated function or a string that references a pre-registered easing 5210 on the Velocity.Easings object. In either case, return the appropriate easing *function*. */ 5211 easing = Type.isString(tween.easing) ? Velocity.Easings[tween.easing] : tween.easing; 5212 5213 /****************************** 5214 Current Value Calculation 5215 ******************************/ 5216 5217 if (Type.isString(tween.pattern)) { 5218 var patternReplace = percentComplete === 1 ? 5219 function($0, index, round) { 5220 var result = tween.endValue[index]; 5221 5222 return round ? Math.round(result) : result; 5223 } : 5224 function($0, index, round) { 5225 var startValue = tween.startValue[index], 5226 tweenDelta = tween.endValue[index] - startValue, 5227 result = startValue + (tweenDelta * easing(percentComplete, opts, tweenDelta)); 5228 5229 return round ? Math.round(result) : result; 5230 }; 5231 5232 currentValue = tween.pattern.replace(/{(\d+)(!)?}/g, patternReplace); 5233 } else if (percentComplete === 1) { 5234 /* If this is the last tick pass (if we've reached 100% completion for this tween), 5235 ensure that currentValue is explicitly set to its target endValue so that it's not subjected to any rounding. */ 5236 currentValue = tween.endValue; 5237 } else { 5238 /* Otherwise, calculate currentValue based on the current delta from startValue. */ 5239 var tweenDelta = tween.endValue - tween.startValue; 5240 5241 currentValue = tween.startValue + (tweenDelta * easing(percentComplete, opts, tweenDelta)); 5242 /* If no value change is occurring, don't proceed with DOM updating. */ 5243 } 5244 if (!firstTick && (currentValue === tween.currentValue)) { 5245 continue; 5246 } 5247 5248 tween.currentValue = currentValue; 5249 5250 /* If we're tweening a fake 'tween' property in order to log transition values, update the one-per-call variable so that 5251 it can be passed into the progress callback. */ 5252 if (property === "tween") { 5253 tweenDummyValue = currentValue; 5254 } else { 5255 /****************** 5256 Hooks: Part I 5257 ******************/ 5258 var hookRoot; 5259 5260 /* For hooked properties, the newly-updated rootPropertyValueCache is cached onto the element so that it can be used 5261 for subsequent hooks in this call that are associated with the same root property. If we didn't cache the updated 5262 rootPropertyValue, each subsequent update to the root property in this tick pass would reset the previous hook's 5263 updates to rootPropertyValue prior to injection. A nice performance byproduct of rootPropertyValue caching is that 5264 subsequently chained animations using the same hookRoot but a different hook can use this cached rootPropertyValue. */ 5265 if (CSS.Hooks.registered[property]) { 5266 hookRoot = CSS.Hooks.getRoot(property); 5267 5268 var rootPropertyValueCache = Data(element).rootPropertyValueCache[hookRoot]; 5269 5270 if (rootPropertyValueCache) { 5271 tween.rootPropertyValue = rootPropertyValueCache; 5272 } 5273 } 5274 5275 /***************** 5276 DOM Update 5277 *****************/ 5278 5279 /* setPropertyValue() returns an array of the property name and property value post any normalization that may have been performed. */ 5280 /* Note: To solve an IE<=8 positioning bug, the unit type is dropped when setting a property value of 0. */ 5281 var adjustedSetData = CSS.setPropertyValue(element, /* SET */ 5282 property, 5283 tween.currentValue + (IE < 9 && parseFloat(currentValue) === 0 ? "" : tween.unitType), 5284 tween.rootPropertyValue, 5285 tween.scrollData); 5286 5287 /******************* 5288 Hooks: Part II 5289 *******************/ 5290 5291 /* Now that we have the hook's updated rootPropertyValue (the post-processed value provided by adjustedSetData), cache it onto the element. */ 5292 if (CSS.Hooks.registered[property]) { 5293 /* Since adjustedSetData contains normalized data ready for DOM updating, the rootPropertyValue needs to be re-extracted from its normalized form. ?? */ 5294 if (CSS.Normalizations.registered[hookRoot]) { 5295 Data(element).rootPropertyValueCache[hookRoot] = CSS.Normalizations.registered[hookRoot]("extract", null, adjustedSetData[1]); 5296 } else { 5297 Data(element).rootPropertyValueCache[hookRoot] = adjustedSetData[1]; 5298 } 5299 } 5300 5301 /*************** 5302 Transforms 5303 ***************/ 5304 5305 /* Flag whether a transform property is being animated so that flushTransformCache() can be triggered once this tick pass is complete. */ 5306 if (adjustedSetData[0] === "transform") { 5307 transformPropertyExists = true; 5308 } 5309 5310 } 5311 } 5312 } 5313 5314 /**************** 5315 mobileHA 5316 ****************/ 5317 5318 /* If mobileHA is enabled, set the translate3d transform to null to force hardware acceleration. 5319 It's safe to override this property since Velocity doesn't actually support its animation (hooks are used in its place). */ 5320 if (opts.mobileHA) { 5321 /* Don't set the null transform hack if we've already done so. */ 5322 if (Data(element).transformCache.translate3d === undefined) { 5323 /* All entries on the transformCache object are later concatenated into a single transform string via flushTransformCache(). */ 5324 Data(element).transformCache.translate3d = "(0px, 0px, 0px)"; 5325 5326 transformPropertyExists = true; 5327 } 5328 } 5329 5330 if (transformPropertyExists) { 5331 CSS.flushTransformCache(element); 5332 } 5333 } 5334 5335 /* The non-"none" display value is only applied to an element once -- when its associated call is first ticked through. 5336 Accordingly, it's set to false so that it isn't re-processed by this call in the next tick. */ 5337 if (opts.display !== undefined && opts.display !== "none") { 5338 Velocity.State.calls[i][2].display = false; 5339 } 5340 if (opts.visibility !== undefined && opts.visibility !== "hidden") { 5341 Velocity.State.calls[i][2].visibility = false; 5342 } 5343 5344 /* Pass the elements and the timing data (percentComplete, msRemaining, timeStart, tweenDummyValue) into the progress callback. */ 5345 if (opts.progress) { 5346 opts.progress.call(callContainer[1], 5347 callContainer[1], 5348 percentComplete, 5349 Math.max(0, (timeStart + opts.duration) - timeCurrent), 5350 timeStart, 5351 tweenDummyValue); 5352 } 5353 5354 /* If this call has finished tweening, pass its index to completeCall() to handle call cleanup. */ 5355 if (percentComplete === 1) { 5356 completeCall(i); 5357 } 5358 } 5359 } 5360 5361 /* Note: completeCall() sets the isTicking flag to false when the last call on Velocity.State.calls has completed. */ 5362 if (Velocity.State.isTicking) { 5363 ticker(tick); 5364 } 5365 } 5366 5367 /********************** 5368 Call Completion 5369 **********************/ 5370 5371 /* Note: Unlike tick(), which processes all active calls at once, call completion is handled on a per-call basis. */ 5372 function completeCall(callIndex, isStopped) { 5373 /* Ensure the call exists. */ 5374 if (!Velocity.State.calls[callIndex]) { 5375 return false; 5376 } 5377 5378 /* Pull the metadata from the call. */ 5379 var call = Velocity.State.calls[callIndex][0], 5380 elements = Velocity.State.calls[callIndex][1], 5381 opts = Velocity.State.calls[callIndex][2], 5382 resolver = Velocity.State.calls[callIndex][4]; 5383 5384 var remainingCallsExist = false; 5385 5386 /************************* 5387 Element Finalization 5388 *************************/ 5389 5390 for (var i = 0, callLength = call.length; i < callLength; i++) { 5391 var element = call[i].element; 5392 5393 /* If the user set display to "none" (intending to hide the element), set it now that the animation has completed. */ 5394 /* Note: display:none isn't set when calls are manually stopped (via Velocity("stop"). */ 5395 /* Note: Display gets ignored with "reverse" calls and infinite loops, since this behavior would be undesirable. */ 5396 if (!isStopped && !opts.loop) { 5397 if (opts.display === "none") { 5398 CSS.setPropertyValue(element, "display", opts.display); 5399 } 5400 5401 if (opts.visibility === "hidden") { 5402 CSS.setPropertyValue(element, "visibility", opts.visibility); 5403 } 5404 } 5405 5406 /* If the element's queue is empty (if only the "inprogress" item is left at position 0) or if its queue is about to run 5407 a non-Velocity-initiated entry, turn off the isAnimating flag. A non-Velocity-initiatied queue entry's logic might alter 5408 an element's CSS values and thereby cause Velocity's cached value data to go stale. To detect if a queue entry was initiated by Velocity, 5409 we check for the existence of our special Velocity.queueEntryFlag declaration, which minifiers won't rename since the flag 5410 is assigned to jQuery's global $ object and thus exists out of Velocity's own scope. */ 5411 var data = Data(element); 5412 5413 if (opts.loop !== true && ($.queue(element)[1] === undefined || !/\.velocityQueueEntryFlag/i.test($.queue(element)[1]))) { 5414 /* The element may have been deleted. Ensure that its data cache still exists before acting on it. */ 5415 if (data) { 5416 data.isAnimating = false; 5417 /* Clear the element's rootPropertyValueCache, which will become stale. */ 5418 data.rootPropertyValueCache = {}; 5419 5420 var transformHAPropertyExists = false; 5421 /* If any 3D transform subproperty is at its default value (regardless of unit type), remove it. */ 5422 $.each(CSS.Lists.transforms3D, function(i, transformName) { 5423 var defaultValue = /^scale/.test(transformName) ? 1 : 0, 5424 currentValue = data.transformCache[transformName]; 5425 5426 if (data.transformCache[transformName] !== undefined && new RegExp("^\\(" + defaultValue + "[^.]").test(currentValue)) { 5427 transformHAPropertyExists = true; 5428 5429 delete data.transformCache[transformName]; 5430 } 5431 }); 5432 5433 /* Mobile devices have hardware acceleration removed at the end of the animation in order to avoid hogging the GPU's memory. */ 5434 if (opts.mobileHA) { 5435 transformHAPropertyExists = true; 5436 delete data.transformCache.translate3d; 5437 } 5438 5439 /* Flush the subproperty removals to the DOM. */ 5440 if (transformHAPropertyExists) { 5441 CSS.flushTransformCache(element); 5442 } 5443 5444 /* Remove the "velocity-animating" indicator class. */ 5445 CSS.Values.removeClass(element, "velocity-animating"); 5446 } 5447 } 5448 5449 /********************* 5450 Option: Complete 5451 *********************/ 5452 5453 /* Complete is fired once per call (not once per element) and is passed the full raw DOM element set as both its context and its first argument. */ 5454 /* Note: Callbacks aren't fired when calls are manually stopped (via Velocity("stop"). */ 5455 if (!isStopped && opts.complete && !opts.loop && (i === callLength - 1)) { 5456 /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ 5457 try { 5458 opts.complete.call(elements, elements); 5459 } catch (error) { 5460 setTimeout(function() { 5461 throw error; 5462 }, 1); 5463 } 5464 } 5465 5466 /********************** 5467 Promise Resolving 5468 **********************/ 5469 5470 /* Note: Infinite loops don't return promises. */ 5471 if (resolver && opts.loop !== true) { 5472 resolver(elements); 5473 } 5474 5475 /**************************** 5476 Option: Loop (Infinite) 5477 ****************************/ 5478 5479 if (data && opts.loop === true && !isStopped) { 5480 /* If a rotateX/Y/Z property is being animated by 360 deg with loop:true, swap tween start/end values to enable 5481 continuous iterative rotation looping. (Otherise, the element would just rotate back and forth.) */ 5482 $.each(data.tweensContainer, function(propertyName, tweenContainer) { 5483 if (/^rotate/.test(propertyName) && ((parseFloat(tweenContainer.startValue) - parseFloat(tweenContainer.endValue)) % 360 === 0)) { 5484 var oldStartValue = tweenContainer.startValue; 5485 5486 tweenContainer.startValue = tweenContainer.endValue; 5487 tweenContainer.endValue = oldStartValue; 5488 } 5489 5490 if (/^backgroundPosition/.test(propertyName) && parseFloat(tweenContainer.endValue) === 100 && tweenContainer.unitType === "%") { 5491 tweenContainer.endValue = 0; 5492 tweenContainer.startValue = 100; 5493 } 5494 }); 5495 5496 Velocity(element, "reverse", {loop: true, delay: opts.delay}); 5497 } 5498 5499 /*************** 5500 Dequeueing 5501 ***************/ 5502 5503 /* Fire the next call in the queue so long as this call's queue wasn't set to false (to trigger a parallel animation), 5504 which would have already caused the next call to fire. Note: Even if the end of the animation queue has been reached, 5505 $.dequeue() must still be called in order to completely clear jQuery's animation queue. */ 5506 if (opts.queue !== false) { 5507 $.dequeue(element, opts.queue); 5508 } 5509 } 5510 5511 /************************ 5512 Calls Array Cleanup 5513 ************************/ 5514 5515 /* Since this call is complete, set it to false so that the rAF tick skips it. This array is later compacted via compactSparseArray(). 5516 (For performance reasons, the call is set to false instead of being deleted from the array: http://www.html5rocks.com/en/tutorials/speed/v8/) */ 5517 Velocity.State.calls[callIndex] = false; 5518 5519 /* Iterate through the calls array to determine if this was the final in-progress animation. 5520 If so, set a flag to end ticking and clear the calls array. */ 5521 for (var j = 0, callsLength = Velocity.State.calls.length; j < callsLength; j++) { 5522 if (Velocity.State.calls[j] !== false) { 5523 remainingCallsExist = true; 5524 5525 break; 5526 } 5527 } 5528 5529 if (remainingCallsExist === false) { 5530 /* tick() will detect this flag upon its next iteration and subsequently turn itself off. */ 5531 Velocity.State.isTicking = false; 5532 5533 /* Clear the calls array so that its length is reset. */ 5534 delete Velocity.State.calls; 5535 Velocity.State.calls = []; 5536 } 5537 } 5538 5539 /****************** 5540 Frameworks 5541 ******************/ 5542 5543 /* Both jQuery and Zepto allow their $.fn object to be extended to allow wrapped elements to be subjected to plugin calls. 5544 If either framework is loaded, register a "velocity" extension pointing to Velocity's core animate() method. Velocity 5545 also registers itself onto a global container (window.jQuery || window.Zepto || window) so that certain features are 5546 accessible beyond just a per-element scope. This master object contains an .animate() method, which is later assigned to $.fn 5547 (if jQuery or Zepto are present). Accordingly, Velocity can both act on wrapped DOM elements and stand alone for targeting raw DOM elements. */ 5548 global.Velocity = Velocity; 5549 5550 if (global !== window) { 5551 /* Assign the element function to Velocity's core animate() method. */ 5552 global.fn.velocity = animate; 5553 /* Assign the object function's defaults to Velocity's global defaults object. */ 5554 global.fn.velocity.defaults = Velocity.defaults; 5555 } 5556 5557 /*********************** 5558 Packaged Redirects 5559 ***********************/ 5560 5561 /* slideUp, slideDown */ 5562 $.each(["Down", "Up"], function(i, direction) { 5563 Velocity.Redirects["slide" + direction] = function(element, options, elementsIndex, elementsSize, elements, promiseData) { 5564 var opts = $.extend({}, options), 5565 begin = opts.begin, 5566 complete = opts.complete, 5567 inlineValues = {}, 5568 computedValues = {height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: ""}; 5569 5570 if (opts.display === undefined) { 5571 /* Show the element before slideDown begins and hide the element after slideUp completes. */ 5572 /* Note: Inline elements cannot have dimensions animated, so they're reverted to inline-block. */ 5573 opts.display = (direction === "Down" ? (Velocity.CSS.Values.getDisplayType(element) === "inline" ? "inline-block" : "block") : "none"); 5574 } 5575 5576 opts.begin = function() { 5577 /* If the user passed in a begin callback, fire it now. */ 5578 if (elementsIndex === 0 && begin) { 5579 begin.call(elements, elements); 5580 } 5581 5582 /* Cache the elements' original vertical dimensional property values so that we can animate back to them. */ 5583 for (var property in computedValues) { 5584 if (!computedValues.hasOwnProperty(property)) { 5585 continue; 5586 } 5587 inlineValues[property] = element.style[property]; 5588 5589 /* For slideDown, use forcefeeding to animate all vertical properties from 0. For slideUp, 5590 use forcefeeding to start from computed values and animate down to 0. */ 5591 var propertyValue = CSS.getPropertyValue(element, property); 5592 computedValues[property] = (direction === "Down") ? [propertyValue, 0] : [0, propertyValue]; 5593 } 5594 5595 /* Force vertical overflow content to clip so that sliding works as expected. */ 5596 inlineValues.overflow = element.style.overflow; 5597 element.style.overflow = "hidden"; 5598 }; 5599 5600 opts.complete = function() { 5601 /* Reset element to its pre-slide inline values once its slide animation is complete. */ 5602 for (var property in inlineValues) { 5603 if (inlineValues.hasOwnProperty(property)) { 5604 element.style[property] = inlineValues[property]; 5605 } 5606 } 5607 5608 /* If the user passed in a complete callback, fire it now. */ 5609 if (elementsIndex === elementsSize - 1) { 5610 if (complete) { 5611 complete.call(elements, elements); 5612 } 5613 if (promiseData) { 5614 promiseData.resolver(elements); 5615 } 5616 } 5617 }; 5618 5619 Velocity(element, computedValues, opts); 5620 }; 5621 }); 5622 5623 /* fadeIn, fadeOut */ 5624 $.each(["In", "Out"], function(i, direction) { 5625 Velocity.Redirects["fade" + direction] = function(element, options, elementsIndex, elementsSize, elements, promiseData) { 5626 var opts = $.extend({}, options), 5627 complete = opts.complete, 5628 propertiesMap = {opacity: (direction === "In") ? 1 : 0}; 5629 5630 /* Since redirects are triggered individually for each element in the animated set, avoid repeatedly triggering 5631 callbacks by firing them only when the final element has been reached. */ 5632 if (elementsIndex !== 0) { 5633 opts.begin = null; 5634 } 5635 if (elementsIndex !== elementsSize - 1) { 5636 opts.complete = null; 5637 } else { 5638 opts.complete = function() { 5639 if (complete) { 5640 complete.call(elements, elements); 5641 } 5642 if (promiseData) { 5643 promiseData.resolver(elements); 5644 } 5645 }; 5646 } 5647 5648 /* If a display was passed in, use it. Otherwise, default to "none" for fadeOut or the element-specific default for fadeIn. */ 5649 /* Note: We allow users to pass in "null" to skip display setting altogether. */ 5650 if (opts.display === undefined) { 5651 opts.display = (direction === "In" ? "auto" : "none"); 5652 } 5653 5654 Velocity(this, propertiesMap, opts); 5655 }; 5656 }); 5657 5658 return Velocity; 5659 }((window.jQuery || window.Zepto || window), window, (window ? window.document : undefined)); 5660})); 5661 5662/****************** 5663 Known Issues 5664 ******************/ 5665 5666/* The CSS spec mandates that the translateX/Y/Z transforms are %-relative to the element itself -- not its parent. 5667 Velocity, however, doesn't make this distinction. Thus, converting to or from the % unit with these subproperties 5668 will produce an inaccurate conversion value. The same issue exists with the cx/cy attributes of SVG circles and ellipses. */ 5669 5670 5671/***/ }), 5672
5673/***/ "../../../upup-baseline/js/src/header/sticky-header.js": 5674/*!**************************************************************************************************************************!*\ 5675 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/header/sticky-header.js ***! 5676 \**************************************************************************************************************************/ 5677/*! exports provided: default */ 5678/***/ (function(module, __webpack_exports__, __webpack_require__) { 5679 5680"use strict"; 5681__webpack_require__.r(__webpack_exports__); 5682/* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utility */ "../../../upup-baseline/js/src/utility.js"); 5683function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5684 5685function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 5686 5687function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 5688 5689function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 5690 5691/** 5692 * StickyHeader 5693 * Assumes header is already "Sticky" via css 5694 * This class monitors when a header is beyond a threshold on the page to allow for additional manipulation 5695 */ 5696 5697 5698var StickyHeader = /*#__PURE__*/function () { 5699 function StickyHeader() { 5700 var _this = this; 5701 5702 _classCallCheck(this, StickyHeader); 5703 5704 _defineProperty(this, "handleScroll", function (e) { 5705 _this.updateScrollProps(e); // if moving beyond the threshold, add a class 5706 5707 5708 if (_this.directionalDelta < 0 && Math.abs(_this.directionalDelta) > _this.menuShowThreshold) { 5709 _this.header.classList.add('scrolling-up'); 5710 5711 _this.header.classList.remove('scrolling-down'); 5712 } else if (_this.directionalDelta > 0) { 5713 _this.header.classList.add('scrolling-down'); 5714 5715 _this.header.classList.remove('scrolling-up'); 5716 } 5717 5718 if (_this.isBeyondThreshold()) { 5719 _this.header.classList.add('beyond-threshold'); 5720 } else { 5721 _this.header.classList.remove('beyond-threshold'); 5722 } 5723 }); 5724 5725 this.header = document.querySelector('.js-sticky-header'); 5726 this.scrollHandler = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["throttle"])(this.handleScroll, 100, true); 5727 this.directionalDelta = 0; 5728 this.lastScrollPos = window.scrollY; 5729 this.menuShowThreshold = 20; // how much a user has to scroll up at once to be considered "scrolling up" 5730 // TODO: maybe alter this value on resize? 5731 // retain the original header height that was loaded 5732 // utility script favors this value when calculating the true headerHeight 5733 5734 this.header.setAttribute('data-original-height', this.header.offsetHeight); 5735 5736 if (this.header) { 5737 this.listen(); 5738 } 5739 } 5740 5741 _createClass(StickyHeader, [{ 5742 key: "listen", 5743 value: function listen() { 5744 window.addEventListener('scroll', this.scrollHandler); 5745 } 5746 /** 5747 * Handle scroll event 5748 */ 5749 5750 }, { 5751 key: "updateScrollProps", 5752 value: function updateScrollProps(e) { 5753 var scrollPosNow = window.scrollY, 5754 deltaY = scrollPosNow - this.lastScrollPos; 5755 5756 if (deltaY < 0 && this.directionalDelta < 0) { 5757 this.directionalDelta += deltaY; 5758 } else if (deltaY > 0 && this.directionalDelta > 0) { 5759 this.directionalDelta += deltaY; 5760 } else { 5761 this.directionalDelta = deltaY; 5762 } 5763 5764 this.lastScrollPos = scrollPosNow; 5765 } 5766 /** 5767 * Have we scrolled past the height of the header? 5768 * Take into account the header being offset from the top of the page b
5768y another container (Ex: alert bar) 5769 * @returns {boolean} 5770 */ 5771 5772 }, { 5773 key: "isBeyondThreshold", 5774 value: function isBeyondThreshold() { 5775 return window.scrollY > this.header.offsetHeight; 5776 } 5777 }]); 5778 5779 return StickyHeader; 5780}(); 5781 5782/* harmony default export */ __webpack_exports__["default"] = (StickyHeader); 5783 5784/***/ }), 5785
5786/***/ "../../../upup-baseline/js/src/menu/menuController.js": 5787/*!*************************************************************************************************************************!*\ 5788 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/menu/menuController.js ***! 5789 \*************************************************************************************************************************/ 5790/*! exports provided: default */ 5791/***/ (function(module, __webpack_exports__, __webpack_require__) { 5792 5793"use strict"; 5794__webpack_require__.r(__webpack_exports__); 5795/* harmony import */ var _menuItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./menuItem */ "../../../upup-baseline/js/src/menu/menuItem.js"); 5796function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5797 5798function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 5799 5800function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 5801 5802function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 5803 5804 5805/** 5806 * Parent class for menu controller 5807 * Handles turning focus on and off for items and moving focus around 5808 */ 5809 5810var MenuController = /*#__PURE__*/function () { 5811 function MenuController(menuElement, parentMenuItem) { 5812 var _this = this; 5813 5814 _classCallCheck(this, MenuController); 5815 5816 _defineProperty(this, "handleFocusOut", function () { 5817 _this.blurTimeout = setTimeout(function () { 5818 _this.resetFocus(); 5819 }, 100); 5820 }); 5821 5822 _defineProperty(this, "handleFocusIn", function () { 5823 clearTimeout(_this.blurTimeout); 5824 }); 5825 5826 this.isActive = false; // applies for sub-menus 5827 5828 this.activeMenuItemIndex = 0; // which menu item has focus; 5829 5830 this.menuElement = menuElement; 5831 this.parentItem = parentMenuItem; 5832 this.menuItems = []; 5833 this.menuItemsCount = 0; 5834 this.menuItemObjects = []; 5835 this.blurTimeout = null; // timeout for exiting the menu 5836 5837 this.discover(); 5838 this.listen(); 5839 this.setup(); 5840 } 5841 /** 5842 * Focus out of this menu 5843 * Turn of focusability of all sub-nav items 5844 */ 5845 5846 5847 _createClass(MenuController, [{ 5848 key: "discover", 5849 5850 /** 5851 * Find all the menu items 5852 */ 5853 value: function discover() { 5854 //using the menu element find all the menu children 5855 this.menuItems = Array.from(this.menuElement.children).filter(function (item) { 5856 return item.matches('li'); 5857 }); 5858 this.menuItemsCount = this.menuItems.length; 5859 } 5860 /** 5861 * Listen to this menu structure 5862 */ 5863 5864 }, { 5865 key: "listen", 5866 value: function listen() { 5867 this.menuElement.addEventListener('focusout', this.handleFocusOut); 5868 this.menuElement.addEventListener('focusin', this.handleFocusIn); 5869 } 5870 /** 5871 * Must be overridden lower down 5872 * Will set up the menu items using a provided class 5873 * Each level of menu items may be a little different 5874 */ 5875 5876 }, { 5877 key: "setup", 5878 value: function setup() {} 5879 /** 5880 * Must be overridden lower down 5881 * @param menuItem 5882 * @param submenuState 5883 */ 5884 5885 }, { 5886 key: "handleSubmenuChange", 5887 value: function handleSubmenuChange(menuItem, submenuState) {} 5888 /** 5889 * Loop over menu items and turn off the focus for each one 5890 */ 5891 5892 }, { 5893 key: "resetFocus", 5894 value: function resetFocus() { 5895 this.menuItemObjects.forEach(function (item) { 5896 item.focusabilityOff(); 5897 }); 5898 this.activeMenuItemIndex = 0; 5899 } 5900 }, { 5901 key: "focusFirst", 5902 value: function focusFirst() { 5903 this.focusTo(0); 5904 } 5905 }, { 5906 key: "focusLast", 5907 value: function focusLast() { 5908 this.focusTo(this.menuItemsCount - 1); 5909 } 5910 }, { 5911 key: "focusNext", 5912 value: function focusNext() { 5913 if (this.activeMenuItemIndex === this.menuItemsCount - 1) { 5914 this.focusTo(0); 5915 } else { 5916 this.focusTo(this.activeMenuItemIndex + 1); 5917 } 5918 } 5919 }, { 5920 key: "focusPrevious", 5921 value: function focusPrevious() { 5922 if (this.activeMenuItemIndex === 0) { 5923 this.focusTo(this.menuItemsCount - 1); 5924 } else { 5925 this.focusTo(this.activeMenuItemIndex - 1); 5926 } 5927 } 5928 }, { 5929 key: "focusTo", 5930 value: function focusTo(index) { 5931 var currentMenuItem = this.menuItemObjects[this.activeMenuItemIndex], 5932 nextMenuItem = this.menuItemObjects[index]; 5933 currentMenuItem.focusabilityOff(); 5934 nextMenuItem.focusabilityOn(); 5935 nextMenuItem.focus(); 5936 this.activeMenuItemIndex = index; 5937 } 5938 /** 5939 * Focus the parent item for this menu 5940 * Applies for sub-menus 5941 */ 5942 5943 }, { 5944 key: "focusParent", 5945 value: function focusParent() { 5946 var currentMenuItem = this.menuItemObjects[this.activeMenuItemIndex]; 5947 5948 if (this.parentItem) { 5949 currentMenuItem.focusabilityOff(); 5950 5951 if (this.parentItem instanceof _menuItem__WEBPACK_IMPORTED_MODULE_0__["default"]) { 5952 this.parentItem.focusabilityOn(); 5953 } 5954 5955 this.parentItem.focus(); 5956 } 5957 } 5958 /** 5959 * Check this menu to see if a sub-menu is open 5960 * Add or remove a class accordingly 5961 */ 5962 5963 }, { 5964 key: "checkForSubMenu", 5965 value: function checkForSubMenu() { 5966 //check to see if any of the items have a sub-menu open 5967 var subMenuOpen = false;
5968 this.menuItemObjects.forEach(function (item) { 5969 if (item.subMenu && item.subMenu.isActive) { 5970 subMenuOpen = true; 5971 } 5972 }); 5973 5974 if (subMenuOpen) { 5975 this.menuElement.classList.add('sub-menu-active'); 5976 } else { 5977 this.menuElement.classList.remove('sub-menu-active'); 5978 } 5979 } 5980 /** 5981 * Close all sub menus of children 5982 */ 5983 5984 }, { 5985 key: "closeChildSubMenus", 5986 value: function closeChildSubMenus() { 5987 this.menuItemObjects.forEach(function (item) { 5988 if (item.subMenu && item.subMenu.isActive) { 5989 item.closeSubMenu(); 5990 } 5991 }); 5992 } 5993 }]); 5994 5995 return MenuController; 5996}(); 5997 5998/* harmony default export */ __webpack_exports__["default"] = (MenuController); 5999 6000/***/ }), 6001
6002/***/ "../../../upup-baseline/js/src/menu/menuItem.js": 6003/*!*******************************************************************************************************************!*\ 6004 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/menu/menuItem.js ***! 6005 \*******************************************************************************************************************/ 6006/*! exports provided: default */ 6007/***/ (function(module, __webpack_exports__, __webpack_require__) { 6008 6009"use strict"; 6010__webpack_require__.r(__webpack_exports__); 6011function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6012 6013function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 6014 6015function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 6016 6017function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 6018 6019var MenuItem = /*#__PURE__*/function () { 6020 // props can be passed to the menu item by the menu 6021 // TODO: props is a little bit implementation specific - maybe add common callback points with extendable functions? 6022 function MenuItem(item, menu) { 6023 var _this = this; 6024 6025 var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 6026 6027 _classCallCheck(this, MenuItem); 6028 6029 _defineProperty(this, "handleFocusOut", function () { 6030 _this.blurTimeout = setTimeout(function () { 6031 _this.item.classList.remove('has-focus'); 6032 }, 1); 6033 }); 6034 6035 _defineProperty(this, "handleFocusIn", function () { 6036 clearTimeout(_this.blurTimeout); 6037 6038 _this.item.classList.add('has-focus'); 6039 }); 6040 6041 _defineProperty(this, "handleSubMenuToggle", function (e) { 6042 if (!_this.subMenu.isActive) { 6043 _this.item.classList.add('active'); 6044 6045 _this.subMenu.focusFirst(); 6046 6047 _this.subMenu.isActive = true; 6048 6049 if (_this.submenuToggle) { 6050 _this.submenuToggle.setAttribute('aria-expanded', 'true'); 6051 } 6052 } else { 6053 _this.closeSubMenu(); 6054 } // on submenu change 6055 6056 6057 if (_this.props.onSubmenuChange) { 6058 _this.props.onSubmenuChange(_this, _this.subMenu.isActive); 6059 } // check the parent for open sub-menus 6060 // if there are open sub menus, the parent will add the appropriate class 6061 6062 6063 _this.menu.checkForSubMenu(); 6064 }); 6065 6066 _defineProperty(this, "handleSubMenuKeyDown", function (e) { 6067 switch (e.key) { 6068 case "Down": // IE/Edge specific value 6069 6070 case "ArrowDown": 6071 _this.handleToggleDown(e); 6072 6073 _this.stopEvent(e); 6074 6075 break; 6076 6077 case "Up": // IE/Edge specific value 6078 6079 case "ArrowUp": 6080 _this.handleToggleUp(e); 6081 6082 _this.stopEvent(e); 6083 6084 break; 6085 6086 case "Left": // IE/Edge specific value 6087 6088 case "ArrowLeft": 6089 _this.handleToggleLeft(e); 6090 6091 _this.stopEvent(e); 6092 6093 break; 6094 6095 case "Right": // IE/Edge specific value 6096 6097 case "ArrowRight": 6098 _this.handleToggleRight(e); 6099 6100 _this.stopEvent(e); 6101 6102 break; 6103 6104 case "Spacebar": 6105 case " ": 6106 if (_this.submenuToggle) { 6107 _this.submenuToggle.click(); 6108 } 6109 6110 _this.stopEvent(e); 6111 6112 break; 6113 } 6114 }); 6115 6116 _defineProperty(this, "handleKeyDown", function (e) { 6117 switch (e.key) { 6118 case "Down": // IE/Edge specific value 6119 6120 case "ArrowDown": 6121 _this.handleDown(e); 6122 6123 _this.stopEvent(e); 6124 6125 break; 6126 6127 case "Up": // IE/Edge specific value 6128 6129 case "ArrowUp": 6130 _this.handleUp(e); 6131 6132 _this.stopEvent(e); 6133 6134 break; 6135 6136 case "Left": // IE/Edge specific value 6137 6138 case "ArrowLeft": 6139 _this.handleLeft(e); 6140 6141 _this.stopEvent(e); 6142 6143 break; 6144 6145 case "Right": // IE/Edge specific value 6146 6147 case "ArrowRight": 6148 _this.handleRight(e); 6149 6150 _this.stopEvent(e); 6151 6152 break; 6153 6154 case "Spacebar": 6155 case " ": 6156 if (_this.link) { 6157 _this.link.click(); 6158 } else { 6159 _this.item.click(); 6160 } 6161 6162 _this.handleSpace(e); 6163 6164 _this.stopEvent(e); 6165 6166 break; 6167 // Escape backs up to the parent menu item 6168 6169 case "Esc": 6170 case "Escape": 6171 // focus the parent 6172 if (_this.menu.parentItem) { 6173 _this.menu.resetFocus(); // if the parent has a toggle button, focus back on the toggle button 6174 6175 6176 if (_this.menu.parentItem.submenuToggle) { 6177 _this.menu.parentItem.submenuToggle.focus(); 6178 } else { 6179 _this.menu.focusParent(); 6180 } // close the sub-menu if the parent has one 6181 6182 6183 if (_this.menu.parentItem.subMenu && _this.menu.parentItem.subMenu.isActive) { 6184 _this.menu.parentItem.handleSubMenuToggle(); 6185 } 6186 6187 _this.stopEvent(e); // pressing escape on an item where the submenu is open should close it 6188 6189 } else if (_this.subMenu) { 6190 if (_this.subMenu.isActive) { 6191 _this.handleSubMenuToggle(); 6192 } // allow user to dismiss submenu on focus by pressing escape 6193 6194 6195 _this.item.classList.add('dismissed'); 6196 } // still allow a custom class to add behavior 6197 6198 6199 _this.handleEscape(e); 6200 6201 break; 6202 } 6203 }); 6204 6205 _defineProperty(this, "stopEvent", function (e) { 6206 e.preventDefault(); 6207 e.stopPropagation(); 6208 }); 6209 6210 this.props = props; 6211 this.item = item; 6212 this.menu = menu; 6213 this.element = item; 6214 this.subMenu = null; 6215 this.link = null; 6216 this.submenuToggle = null; 6217 this.mouseInside = false;
6218 this.discover(); 6219 this.setup(); 6220 this.listen(); 6221 this.blurTimeout = null; 6222 } 6223 6224 _createClass(MenuItem, [{ 6225 key: "discover", 6226 value: function discover() { 6227 this.link = this.item.querySelector('a'); 6228 } 6229 }, { 6230 key: "listen", 6231 value: function listen() { 6232 // allow for the possibility of the item being a button 6233 if (this.link) { 6234 this.link.addEventListener('keydown', this.handleKeyDown.bind(this)); 6235 this.link.addEventListener('blur', this.handleBlur.bind(this)); 6236 } else { 6237 this.item.addEventListener('keydown', this.handleKeyDown.bind(this)); 6238 this.item.addEventListener('blur', this.handleBlur.bind(this)); 6239 } 6240 6241 this.item.addEventListener('focusin', this.handleFocusIn.bind(this)); 6242 this.item.addEventListener('focusout', this.handleFocusOut.bind(this)); 6243 6244 if (this.subMenu && this.submenuToggle) { 6245 this.submenuToggle.addEventListener('click', this.handleSubMenuToggle.bind(this)); 6246 this.submenuToggle.addEventListener('keydown', this.handleSubMenuKeyDown.bind(this)); 6247 this.submenuToggle.addEventListener('blur', this.handleToggleBlur.bind(this)); 6248 } 6249 } 6250 /** 6251 * Find submenu and submenu toggle 6252 * This is done in the child class 6253 */ 6254 6255 }, { 6256 key: "setup", 6257 value: function setup() {} 6258 }, { 6259 key: "focus", 6260 value: function focus() { 6261 this.focusabilityOn(); 6262 6263 if (this.link) { 6264 this.link.focus(); 6265 } else { 6266 this.item.focus(); 6267 } 6268 } 6269 }, { 6270 key: "handleBlur", 6271 value: function handleBlur() { 6272 var _this2 = this; 6273 6274 this.focusabilityOff(); 6275 setTimeout(function () { 6276 _this2.item.classList.remove('dismissed'); 6277 }, 2); 6278 } 6279 }, { 6280 key: "handleToggleBlur", 6281 value: function handleToggleBlur() { 6282 this.submenuToggle.setAttribute('tabindex', '-1'); 6283 } 6284 }, { 6285 key: "focusSubmenuToggle", 6286 value: function focusSubmenuToggle() { 6287 if (this.submenuToggle) { 6288 this.submenuToggle.setAttribute('tabindex', '0'); 6289 this.submenuToggle.focus(); 6290 } 6291 } 6292 /** 6293 * Toggle the sub-menu 6294 */ 6295 6296 }, { 6297 key: "closeSubMenu", 6298 6299 /** 6300 * Close the sub-menu 6301 */ 6302 value: function closeSubMenu() { 6303 this.item.classList.remove('active'); 6304 this.subMenu.isActive = false; 6305 6306 if (this.submenuToggle) { 6307 this.submenuToggle.setAttribute('aria-expanded', 'false'); 6308 } // close all child sub-menus as well 6309 6310 6311 this.subMenu.closeChildSubMenus(); // check the parent for open sub-menus 6312 // if there are open sub menus, the parent will add the appropriate class 6313 6314 this.menu.checkForSubMenu(); 6315 } 6316 /** 6317 * handle keys on sub-menu toggle button 6318 * When opened, should focus inside sub-menu 6319 */ 6320 6321 }, { 6322 key: "handleDown", 6323 value: function handleDown() {} 6324 }, { 6325 key: "handleUp", 6326 value: function handleUp() {} 6327 }, { 6328 key: "handleLeft", 6329 value: function handleLeft() {} 6330 }, { 6331 key: "handleRight", 6332 value: function handleRight() {} 6333 }, { 6334 key: "handleSpace", 6335 value: function handleSpace() {} 6336 }, { 6337 key: "handleEscape", 6338 value: function handleEscape() {} 6339 }, { 6340 key: "handleToggleDown", 6341 value: function handleToggleDown() { 6342 this.menu.focusNext(); 6343 } 6344 }, { 6345 key: "handleToggleUp", 6346 value: function handleToggleUp() { 6347 this.menu.focusPrevious(); 6348 } 6349 }, { 6350 key: "handleToggleLeft", 6351 value: function handleToggleLeft() { 6352 this.focus(); 6353 } 6354 }, { 6355 key: "handleToggleRight", 6356 value: function handleToggleRight() {} 6357 }, { 6358 key: "focusabilityOn", 6359 value: function focusabilityOn() { 6360 if (this.link) { 6361 this.link.setAttribute('tabindex', '0'); 6362 } else { 6363 this.item.setAttribute('tabindex', '0'); 6364 } 6365 } 6366 }, { 6367 key: "focusabilityOff", 6368 value: function focusabilityOff() { 6369 if (this.link) { 6370 this.link.setAttribute('tabindex', '-1'); 6371 } else { 6372 this.item.setAttribute('tabindex', '-1'); 6373 } 6374 } 6375 /** 6376 * Are we on the mobile view? 6377 * @returns {boolean} 6378 */ 6379 6380 }, { 6381 key: "isMobile", 6382 value: function isMobile() { 6383 return window.innerWidth < 992; 6384 } 6385 }]); 6386
6387 return MenuItem; 6388}(); 6389 6390/* harmony default export */ __webpack_exports__["default"] = (MenuItem); 6391 6392/***/ }), 6393
vendor: 4,337 bytes, lines 6394-6428
6394/***/ "../../../upup-baseline/js/src/menu/verticalMenuController.js": 6395/*!*********************************************************************************************************************************!*\ 6396 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/menu/verticalMenuController.js ***! 6397 \*********************************************************************************************************************************/ 6398/*! exports provided: default */ 6399/***/ (function(module, __webpack_exports__, __webpack_require__) { 6400 6401"use strict"; 6402__webpack_require__.r(__webpack_exports__); 6403/* harmony import */ var _menuController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./menuController */ "../../../upup-baseline/js/src/menu/menuController.js"); 6404/* harmony import */ var _verticalMenuItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./verticalMenuItem */ "../../../upup-baseline/js/src/menu/verticalMenuItem.js"); 6405function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 6406 6407function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6408 6409function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 6410 6411function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 6412 6413function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } 6414 6415function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } 6416 6417function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 6418 6419function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 6420 6421function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 6422 6423function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 6424 6425function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 6426 6427function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 6428
6429function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 6430 6431 6432 6433 6434var verticalMenuController = /*#__PURE__*/function (_MenuController) { 6435 _inherits(verticalMenuController, _MenuController); 6436 6437 var _super = _createSuper(verticalMenuController); 6438 6439 function verticalMenuController() { 6440 _classCallCheck(this, verticalMenuController); 6441 6442 return _super.apply(this, arguments); 6443 } 6444 6445 _createClass(verticalMenuController, [{ 6446 key: "setup", 6447 6448 /** 6449 * set up the menu item objects 6450 */ 6451 value: function setup() { 6452 var _this = this; 6453 6454 this.menuItemObjects = this.menuItems.map(function (item) { 6455 return new _verticalMenuItem__WEBPACK_IMPORTED_MODULE_1__["default"](item, _this); 6456 }); // when setting up top-level, make sure first nav item is focusable to start out with 6457 6458 this.menuItemObjects.forEach(function (item) { 6459 return item.focusabilityOff(); 6460 }); 6461 this.menuItemObjects[0].focusabilityOn(); 6462 } 6463 /** 6464 * When resetting primary menu focus 6465 * Allow the first item to be focused 6466 */ 6467 6468 }, { 6469 key: "resetFocus", 6470 value: function resetFocus() { 6471 _get(_getPrototypeOf(verticalMenuController.prototype), "resetFocus", this).call(this); 6472 6473 this.menuItemObjects[0].focusabilityOn(); 6474 } 6475 /** 6476 * Turn focusability off 6477 */ 6478 6479 }, { 6480 key: "focusOff", 6481 value: function focusOff() { 6482 _get(_getPrototypeOf(verticalMenuController.prototype), "resetFocus", this).call(this); 6483 } 6484 }]); 6485 6486 return verticalMenuController; 6487}(_menuController__WEBPACK_IMPORTED_MODULE_0__["default"]); 6488 6489/* harmony default export */ __webpack_exports__["default"] = (verticalMenuController); 6490 6491/***/ }), 6492
vendor: 4,392 bytes, lines 6493-6556
6493/***/ "../../../upup-baseline/js/src/menu/verticalMenuItem.js": 6494/*!***************************************************************************************************************************!*\ 6495 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/menu/verticalMenuItem.js ***! 6496 \***************************************************************************************************************************/ 6497/*! exports provided: default */ 6498/***/ (function(module, __webpack_exports__, __webpack_require__) { 6499 6500"use strict"; 6501__webpack_require__.r(__webpack_exports__); 6502/* harmony import */ var _menuItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./menuItem */ "../../../upup-baseline/js/src/menu/menuItem.js"); 6503function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 6504 6505function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6506 6507function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 6508 6509function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 6510 6511function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 6512 6513function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 6514 6515function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 6516 6517function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 6518 6519function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 6520 6521function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 6522 6523function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 6524 6525 6526 6527var verticalMenuItem = /*#__PURE__*/function (_menuItem) { 6528 _inherits(verticalMenuItem, _menuItem); 6529 6530 var _super = _createSuper(verticalMenuItem); 6531 6532 function verticalMenuItem() { 6533 _classCallCheck(this, verticalMenuItem); 6534 6535 return _super.apply(this, arguments); 6536 } 6537 6538 _createClass(verticalMenuItem, [{ 6539 key: "handleUp", 6540 value: function handleUp() { 6541 this.menu.focusPrevious(); 6542 } 6543 }, { 6544 key: "handleDown", 6545 value: function handleDown() { 6546 this.menu.focusNext(); 6547 } 6548 }]); 6549 6550 return verticalMenuItem; 6551}(_menuItem__WEBPACK_IMPORTED_MODULE_0__["default"]); 6552 6553/* harmony default export */ __webpack_exports__["default"] = (verticalMenuItem); 6554 6555/***/ }), 6556
6557/***/ "../../../upup-baseline/js/src/utility.js": 6558/*!*************************************************************************************************************!*\ 6559 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/utility.js ***! 6560 \*************************************************************************************************************/ 6561/*! exports provided: setPageHeight, setHeaderHeight, closestPolyfill, trackHeaderBottom, debounce, throttle, containScroll, allowScrollWithinContainedScroll, sleep, preventGhosts, preventClickOnDrag, css, getAttributeStyles, merge, getElOffset, manageClipboardLinks, copyToClipboard */ 6562/***/ (function(module, __webpack_exports__, __webpack_require__) { 6563 6564"use strict"; 6565__webpack_require__.r(__webpack_exports__); 6566/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setPageHeight", function() { return setPageHeight; }); 6567/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setHeaderHeight", function() { return setHeaderHeight; }); 6568/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "closestPolyfill", function() { return closestPolyfill; }); 6569/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trackHeaderBottom", function() { return trackHeaderBottom; }); 6570/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return debounce; }); 6571/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return throttle; }); 6572/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "containScroll", function() { return containScroll; }); 6573/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "allowScrollWithinContainedScroll", function() { return allowScrollWithinContainedScroll; }); 6574/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sleep", function() { return sleep; }); 6575/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "preventGhosts", function() { return preventGhosts; }); 6576/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "preventClickOnDrag", function() { return preventClickOnDrag; }); 6577/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "css", function() { return css; }); 6578/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAttributeStyles", function() { return getAttributeStyles; }); 6579/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return merge; }); 6580/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getElOffset", function() { return getElOffset; }); 6581/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "manageClipboardLinks", function() { return manageClipboardLinks; }); 6582/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return copyToClipboard; }); 6583function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 6584 6585function setPageHeight() { 6586 var vh = window.innerHeight * 0.01; // Then we set the value in the --vh custom property to the root of the document 6587 6588 document.documentElement.style.setProperty('--vh', vh + 'px'); 6589} 6590/** 6591 * Set a variable to reflect the height of the header 6592 */ 6593 6594function setHeaderHeight() { 6595 var header = document.getElementById('site-header'), 6596 headerHeight = header.offsetHeight, 6597 originalHeight = header.dataset.originalHeight; 6598 6599 if (originalHeight) { 6600 headerHeight = originalHeight; 6601 } 6602 6603 document.documentElement.style.setProperty('--headerHeight', headerHeight + 'px'); 6604} 6605function closestPolyfill() { 6606 if (!Element.prototype.matches) { 6607 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 6608 } 6609 6610 if (!Element.prototype.closest) { 6611 Element.prototype.closest = function (s) { 6612 var el = this; 6613 6614 do { 6615 if (el.matches(s)) return el; 6616 el = el.parentElement || el.parentNode; 6617 } while (el !== null && el.nodeType === 1); 6618 6619 return null; 6620 }; 6621 } 6622} 6623/** 6624 * Track the bottom of the header offset from the window 6625 */ 6626 6627function trackHeaderBottom() { 6628 var header = document.getElementById('site-header'), 6629 headerWrap = header.querySelector('.site-header__wrap'), 6630 headerHeight = 0, 6631 headerOffset = null, 6632 headerBottom; 6633 6634 if (headerWrap) { 6635 headerHeight = headerWrap.offsetHeight; 6636 headerOffset = headerWrap.getBoundingClientRect(); 6637 } else { 6638 headerHeight = header.offsetHeight; 6639 headerOffset = header.getBoundingClientRect(); 6640 } 6641 6642 headerBottom = headerOffset.top + headerHeight; 6643 document.documentElement.style.setProperty('--headerBottom', headerBottom + 'px'); 6644} 6645function debounce(callback, threshold, execAsap) { 6646 var timeout; 6647 return function () { 6648 var obj = this, 6649 args = arguments; 6650 6651 function delayed() { 6652 if (!execAsap) callback.apply(obj, args); 6653 clearTimeout(timeout); 6654 timeout = null; 6655 } 6656 6657 if (timeout) clearTimeout(timeout);else if (execAsap) callback.apply(obj, args); 6658 timeout = setTimeout(delayed, threshold || 100); 6659 }; 6660} 6661function throttle(callback) { 6662 var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100; 6663 var fire_last = arguments.length > 2 ? arguments[2] : undefined; 6664 var last = Date.now(), 6665 timeout = null; 6666 return function () { 6667 var obj = this, 6668 args = arguments, 6669 now = Date.now(); 6670 6671 function delayed() { 6672 callback.apply(obj, args); 6673 timeout = null; 6674 } //this event is new enough 6675 6676 6677 if (now - last > interval) { 6678 callback.apply(obj, args); 6679 last = now; //can be set up to call the callback one more time at the end of the throttle 6680 6681 if (fire_last) { 6682 clearTimeout(timeout); 6683 timeout = setTimeout(delayed, interval || 100); 6684 } 6685 } 6686 }; 6687} 6688/** 6689 * TODO: improve handling for widthGreaterThan logic - really only relevant if a container should not scroll at a given size 6690 * Handle scrolling issue on iOS where background can be scrolled while menu is open 6691 * @param element 6692 * @param screenSize 6693 */ 6694 6695function containScroll(element) { 6696 var screenSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 6697 x: function x(w) { 6698 return w > 0; 6699 }, 6700 y: function y(h) { 6701 return h > 0; 6702 } 6703 }; 6704 6705 var initialClientY = null, 6706 cancelIfAtBoundary = function cancelIfAtBoundary(deltaY, e) { 6707 if (element.scrollHeight - element.scrollTop <= element.clientHeight && deltaY > 0 || element.scrollTop === 0 && deltaY < 0) { 6708 e.preventDefault(); 6709 } 6710 }, 6711 6712 /** 6713 * Check screen size constraints 6714 * @param e 6715 */ 6716 isScreenCorrectSize = function isScreenCorrectSize() { 6717 return screenSize.x(window.innerWidth) && screenSize.y(window.innerHeight); 6718 }, 6719 handleTouchStart = function handleTouchStart(e) { 6720 if (!isScreenCorrectSize()) { 6721 return false;
6722 } 6723 6724 if (e.targetTouches.length === 1) { 6725 // detect single touch 6726 initialClientY = e.targetTouches[0].clientY; 6727 } 6728 }, 6729 handleTouchMove = function handleTouchMove(e) { 6730 if (!isScreenCorrectSize()) { 6731 return false; 6732 } 6733 6734 var deltaY = e.targetTouches[0].clientY - initialClientY; 6735 6736 if (e.targetTouches.length !== 1) { 6737 return e; 6738 } // invert delat Y here for same logic to work 6739 6740 6741 cancelIfAtBoundary(-deltaY, e); 6742 e.stopPropagation(); 6743 e.stopImmediatePropagation(); 6744 }, 6745 handleWheel = function handleWheel(e) { 6746 var deltaY = e.deltaY; 6747 6748 if (!isScreenCorrectSize()) { 6749 return false; 6750 } 6751 6752 cancelIfAtBoundary(deltaY, e); 6753 e.stopPropagation(); 6754 e.stopImmediatePropagation(); 6755 }; 6756 6757 element.addEventListener('touchstart', handleTouchStart); 6758 element.addEventListener('touchmove', handleTouchMove, { 6759 passive: false 6760 }); 6761 element.addEventListener('wheel', handleWheel, { 6762 passive: false 6763 }); 6764} 6765/** 6766 * way that scrolling can be stopped from propagating if not at boundary, but prop
6766agate up if hits boundary 6767 */ 6768 6769function allowScrollWithinContainedScroll(element) { 6770 var initialClientY = null, 6771 stopPropagationIfWithinBoundary = function stopPropagationIfWithinBoundary(deltaY, e) { 6772 if (element.scrollHeight - element.offsetHeight >= element.scrollTop && !(element.scrollTop === 0 && deltaY < 0 || element.scrollHeight - element.offsetHeight === element.scrollTop && deltaY > 0)) { 6773 e.stopPropagation(); 6774 e.stopImmediatePropagation(); 6775 } 6776 }, 6777 handleTouchStart = function handleTouchStart(e) { 6778 if (e.targetTouches.length === 1) { 6779 // detect single touch 6780 initialClientY = e.targetTouches[0].clientY; 6781 } 6782 }, 6783 handleTouchMove = function handleTouchMove(e) { 6784 var deltaY = e.targetTouches[0].clientY - initialClientY; 6785 6786 if (e.targetTouches.length !== 1) { 6787 return e; 6788 } // invert delat Y here for same logic to work 6789 6790 6791 stopPropagationIfWithinBoundary(-deltaY, e); 6792 }, 6793 handleWheel = function handleWheel(e) { 6794 var deltaY = e.deltaY; 6795 stopPropagationIfWithinBoundary(deltaY, e); 6796 }; 6797 6798 element.addEventListener('touchstart', handleTouchStart); 6799 element.addEventListener('touchmove', handleTouchMove, { 6800 passive: false 6801 }); 6802 element.addEventListener('wheel', handleWheel, { 6803 passive: false 6804 }); 6805} 6806function sleep(ms) { 6807 return new Promise(function (resolve) { 6808 return setTimeout(resolve, ms); 6809 }); 6810} 6811/** 6812 * Props: https://gist.github.com/kosich/23188dd86633b6c2efb7 6813 * @param element 6814 */ 6815 6816function preventGhosts(element) { 6817 var POINTER_TYPE = { 6818 MOUSE: 0, 6819 TOUCH: 1 6820 }, 6821 ANTI_GHOST_DELAY = 2000, 6822 latestInteractionType, 6823 latestInteractionTime, 6824 mouseEvents = ['mousedown', 'mouseup', 'mousemove'], 6825 touchEvents = ['touchstart', 'touchend']; 6826 6827 function handleTap(type, e) { 6828 var now = Date.now(); 6829 6830 if (type !== latestInteractionType) { 6831 if (now - latestInteractionTime <= ANTI_GHOST_DELAY) { 6832 // console.log('!prevented!'); 6833 e.preventDefault(); 6834 e.stopPropagation(); 6835 e.stopImmediatePropagation(); 6836 return false; 6837 } 6838 6839 latestInteractionType = type; 6840 } 6841 6842 latestInteractionTime = now; 6843 } 6844 6845 function attachEvents(eventList, interactionType) { 6846 eventList.forEach(function (eventName) { 6847 element.addEventListener(eventName, handleTap.bind(null, interactionType), true); 6848 }); 6849 } 6850 6851 attachEvents(mouseEvents, POINTER_TYPE.MOUSE); 6852 attachEvents(touchEvents, POINTER_TYPE.TOUCH); 6853} 6854/** 6855 * Prevent a click event on drag 6856 */ 6857 6858function preventClickOnDrag(element) { 6859 var downX = 0, 6860 downY = 0; 6861 6862 function handleDown(e) { 6863 downX = e.screenX; 6864 downY = e.screenY; 6865 } 6866 6867 function handleUp(e) { 6868 var releaseX = e.screenX, 6869 releaseY = e.screenY, 6870 dist = Math.sqrt(Math.pow(releaseX - downX, 2) + Math.pow(releaseY - downY, 2)); 6871 6872 if (dist > 10) { 6873 e.preventDefault(); 6874 e.stopPropagation(); 6875 } 6876 } 6877 6878 element.addEventListener('mousedown', handleDown); 6879 element.addEventListener('mouseup', handleUp); 6880 element.addEventListener('click', handleUp); 6881} 6882/** 6883 * Set the CSS style attribute of an element 6884 * @param el - the element to manipulate 6885 * @param props_to - the properties and values to set 6886 */ 6887 6888function css(el, props_to) { 6889 var styles = getAttributeStyles(el), 6890 updated = merge(styles, props_to), 6891 style_string = ''; 6892 6893 for (var prop in updated) { 6894 if (updated[prop] === null || updated[prop] === '') continue; 6895 style_string += prop + ':' + updated[prop] + '; '; 6896 } 6897 6898 style_string = style_string.replace(/;\s?$/, ''); 6899 el.setAttribute('style', style_string); 6900} 6901function getAttributeStyles(el) { 6902 var string = el.getAttribute('style'), 6903 pairs = string ? string.split(';') : [], 6904 _tmp, 6905 styles = {}; 6906 6907 if (pairs.length <= 0) return styles; 6908 6909 for (var i = 0, il = pairs.length; i < il; i++) { 6910 _tmp = pairs[i].trim().split(/:(.+)?/); //split on first occuence 6911 6912 if (_tmp[0] == '') continue; 6913 styles[_tmp[0].trim()] = _tmp[1].trim(); 6914 } 6915 6916 return styles; 6917} 6918function merge(o1, o2, flat) { 6919 var o3 = {}; 6920 flat = flat === true; 6921 6922 for (var prop in o1) { 6923 if (!o1.hasOwnProperty(prop)) continue; 6924 o3[prop] = o1[prop]; 6925 } 6926 6927 for (prop in o2) { 6928 if (!o2.hasOwnProperty(prop)) continue; 6929 6930 if (_typeof(o2[prop]) == 'object' && _typeof(o3[prop]) == 'object') { 6931 if (!flat) { 6932 o3[prop] = merge(o3[prop], o2[prop]); 6933 } else { 6934 o3[prop] = o2[prop]; 6935 } 6936 } else { 6937 o3[prop] = o2[prop]; 6938 } 6939 } 6940 6941 return o3; 6942} 6943function getElOffset(el) { 6944 var rect = el.getBoundingClientRect(), 6945 width = el.offsetWidth, 6946 height = el.offsetHeight; 6947 return { 6948 left: rect.left + window.scrollX, 6949 top: rect.top + window.pageYOffset, 6950 right: window.innerWidth - rect.left - width, 6951 bottom: rect.top + window.pageYOffset + height 6952 }; 6953} 6954/** 6955 * Find and manage links/ buttons that allow text to be copied to the clipboard 6956 */ 6957 6958function manageClipboardLinks() { 6959 var _this = this; 6960 6961 var clipboardLinks = document.querySelectorAll('.js-clipboard-copy'); 6962 clipboardLinks.forEach(function (link) { 6963 link.addEventListener('click', copyToClipboard.bind(_this, link)); 6964 }); 6965} 6966/** 6967 * Copy some text to the clipboard 6968 * The target needs to carry the specific text as a data attribute 6969 */ 6970 6971function copyToClipboard(link, e) { 6972 var copyable = link.getAttribute('data-copy'); 6973 e.preventDefault(); 6974 6975 if (!navigator || !navigator.clipboard) { 6976 console.error("Could not copy - navigator object not available"); 6977 return false;
6978 } 6979 6980 navigator.clipboard.writeText(copyable).then(function () { 6981 link.classList.add('copied'); 6982 setTimeout(function () { 6983 link.classList.remove('copied'); 6984 }, 2000); 6985 }); 6986} 6987 6988/***/ }), 6989
6990/***/ "../../../upup-baseline/js/src/youtube-player.js": 6991/*!********************************************************************************************************************!*\ 6992 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/upup-baseline/js/src/youtube-player.js ***! 6993 \********************************************************************************************************************/ 6994/*! exports provided: default */ 6995/***/ (function(module, __webpack_exports__, __webpack_require__) { 6996 6997"use strict"; 6998__webpack_require__.r(__webpack_exports__); 6999function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 7000 7001function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 7002 7003function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 7004 7005/** 7006 * Manages one youtube player 7007 * Gets it set up and then just provides an interface to interact with the player object 7008 */ 7009var youtubePlayer = /*#__PURE__*/function () { 7010 /** 7011 * Constructor shoudl receive the video ID 7012 * @param videoID 7013 */ 7014 function youtubePlayer(el) { 7015 var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 7016 7017 _classCallCheck(this, youtubePlayer); 7018 7019 this.el = el; 7020 this.props = props; 7021 this.parent = el.parentNode; 7022 this.iframe = null; 7023 this.videoID = el.dataset.videoId || el.id; 7024 this.apiTimeout = null; 7025 this.isSetup = false; 7026 this.player = null; //check for API 7027 7028 if (window.YT && window.YT.loaded) { 7029 this.setupPlayer(); 7030 } else { 7031 this.apiCheck(); 7032 } 7033 } 7034 /** 7035 * Check to see if the youtube API has been loaded 7036 * This is included once by another script. 7037 */ 7038 7039 7040 _createClass(youtubePlayer, [{ 7041 key: "apiCheck", 7042 value: function apiCheck() { 7043 var _this = this; 7044 7045 this.apiTimeout = setTimeout(function () { 7046 if (window.YT && window.YT.loaded) { 7047 _this.setupPlayer(); 7048 7049 clearTimeout(_this.apiTimeout); 7050 } else { 7051 _this.apiCheck(); 7052 } 7053 }, 100); 7054 } 7055 /** 7056 * Set up the youtube player using the youtube API 7057 * Will return an interface to interact with the player 7058 */ 7059 7060 }, { 7061 key: "setupPlayer", 7062 value: function setupPlayer() { 7063 this.player = new YT.Player(this.el.id, { 7064 height: '390', 7065 width: '640', 7066 allow: 'encrypted-media', 7067 playerVars: this.props.playerVars ? this.props.playerVars : { 7068 poster: false, 7069 thumbnail: false, 7070 modestbranding: 1, 7071 rel: 0, 7072 showinfo: 0, 7073 autoplay: 0 7074 }, 7075 videoId: this.videoID, 7076 events: { 7077 'onReady': this.onPlayerReady.bind(this), 7078 'onStateChange': this.onPlayerStateChange.bind(this) 7079 } 7080 }); 7081 } 7082 /** 7083 * When the player is ready 7084 */ 7085 7086 }, { 7087 key: "onPlayerReady", 7088 value: function onPlayerReady() { 7089 this.isSetup = true; 7090 this.iframe = this.parent.querySelector('iframe'); //call the ready callback if there is one 7091 7092 if (this.props.onReady) { 7093 this.props.onReady.call(); 7094 } 7095 } 7096 /** 7097 * When the player changes states 7098 */ 7099 7100 }, { 7101 key: "onPlayerStateChange", 7102 value: function onPlayerStateChange(e) { 7103 if (this.props.onChange) { 7104 this.props.onChange(e); 7105 } 7106 } 7107 }]); 7108 7109 return youtubePlayer; 7110}(); 7111 7112/* harmony default export */ __webpack_exports__["default"] = (youtubePlayer); 7113 7114/***/ }), 7115
vendor: 4,024 bytes, lines 7116-7301
7116/***/ "../../node_modules/component-emitter/index.js": 7117/*!****************************************************************************************************************************************!*\ 7118 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/component-emitter/index.js ***! 7119 \****************************************************************************************************************************************/ 7120/*! no static exports found */ 7121/***/ (function(module, exports, __webpack_require__) { 7122 7123 7124/** 7125 * Expose `Emitter`. 7126 */ 7127 7128if (true) { 7129 module.exports = Emitter; 7130} 7131 7132/** 7133 * Initialize a new `Emitter`. 7134 * 7135 * @api public 7136 */ 7137 7138function Emitter(obj) { 7139 if (obj) return mixin(obj); 7140}; 7141 7142/** 7143 * Mixin the emitter properties. 7144 * 7145 * @param {Object} obj 7146 * @return {Object} 7147 * @api private 7148 */ 7149 7150function mixin(obj) { 7151 for (var key in Emitter.prototype) { 7152 obj[key] = Emitter.prototype[key]; 7153 } 7154 return obj; 7155} 7156 7157/** 7158 * Listen on the given `event` with `fn`. 7159 * 7160 * @param {String} event 7161 * @param {Function} fn 7162 * @return {Emitter} 7163 * @api public 7164 */ 7165 7166Emitter.prototype.on = 7167Emitter.prototype.addEventListener = function(event, fn){ 7168 this._callbacks = this._callbacks || {}; 7169 (this._callbacks['$' + event] = this._callbacks['$' + event] || []) 7170 .push(fn); 7171 return this; 7172}; 7173 7174/** 7175 * Adds an `event` listener that will be invoked a single 7176 * time then automatically removed. 7177 * 7178 * @param {String} event 7179 * @param {Function} fn 7180 * @return {Emitter} 7181 * @api public 7182 */ 7183 7184Emitter.prototype.once = function(event, fn){ 7185 function on() { 7186 this.off(event, on); 7187 fn.apply(this, arguments); 7188 } 7189 7190 on.fn = fn; 7191 this.on(event, on); 7192 return this; 7193}; 7194 7195/** 7196 * Remove the given callback for `event` or all 7197 * registered callbacks. 7198 * 7199 * @param {String} event 7200 * @param {Function} fn 7201 * @return {Emitter} 7202 * @api public 7203 */ 7204 7205Emitter.prototype.off = 7206Emitter.prototype.removeListener = 7207Emitter.prototype.removeAllListeners = 7208Emitter.prototype.removeEventListener = function(event, fn){ 7209 this._callbacks = this._callbacks || {}; 7210 7211 // all 7212 if (0 == arguments.length) { 7213 this._callbacks = {}; 7214 return this; 7215 } 7216 7217 // specific event 7218 var callbacks = this._callbacks['$' + event]; 7219 if (!callbacks) return this; 7220 7221 // remove all handlers 7222 if (1 == arguments.length) { 7223 delete this._callbacks['$' + event]; 7224 return this; 7225 } 7226 7227 // remove specific handler 7228 var cb; 7229 for (var i = 0; i < callbacks.length; i++) { 7230 cb = callbacks[i]; 7231 if (cb === fn || cb.fn === fn) { 7232 callbacks.splice(i, 1); 7233 break; 7234 } 7235 } 7236 7237 // Remove event specific arrays for event types that no 7238 // one is subscribed for to avoid memory leak. 7239 if (callbacks.length === 0) { 7240 delete this._callbacks['$' + event]; 7241 } 7242 7243 return this; 7244}; 7245 7246/** 7247 * Emit `event` with the given args. 7248 * 7249 * @param {String} event 7250 * @param {Mixed} ... 7251 * @return {Emitter} 7252 */ 7253 7254Emitter.prototype.emit = function(event){ 7255 this._callbacks = this._callbacks || {}; 7256 7257 var args = new Array(arguments.length - 1) 7258 , callbacks = this._callbacks['$' + event]; 7259 7260 for (var i = 1; i < arguments.length; i++) { 7261 args[i - 1] = arguments[i]; 7262 } 7263 7264 if (callbacks) { 7265 callbacks = callbacks.slice(0); 7266 for (var i = 0, len = callbacks.length; i < len; ++i) { 7267 callbacks[i].apply(this, args); 7268 } 7269 } 7270 7271 return this; 7272}; 7273 7274/** 7275 * Return array of callbacks for `event`. 7276 * 7277 * @param {String} event 7278 * @return {Array} 7279 * @api public 7280 */ 7281 7282Emitter.prototype.listeners = function(event){ 7283 this._callbacks = this._callbacks || {}; 7284 return this._callbacks['$' + event] || []; 7285}; 7286 7287/** 7288 * Check if this emitter has `event` handlers. 7289 * 7290 * @param {String} event 7291 * @return {Boolean} 7292 * @api public 7293 */ 7294 7295Emitter.prototype.hasListeners = function(event){ 7296 return !! this.listeners(event).length; 7297}; 7298 7299 7300/***/ }), 7301
vendor: 5,264 bytes, lines 7302-7430
7302/***/ "../../node_modules/element-scroll-polyfill/index.js": 7303/*!**********************************************************************************************************************************************!*\ 7304 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/element-scroll-polyfill/index.js ***! 7305 \**********************************************************************************************************************************************/ 7306/*! no static exports found */ 7307/***/ (function(module, exports) { 7308 7309(function() { 7310 var normalizeNonFiniteValue = function (value) { 7311 value = +value; 7312 return (isNaN(value) || value == Infinity || value == -Infinity) ? 0 : value; 7313 } 7314 7315 var isBodyPotentiallyScrollable = function (body) { 7316 body = body ? body : document.getElementsByTagName("BODY")[0]; 7317 7318 var bodyComputedStyle = window.getComputedStyle(body); 7319 var parentComputedStyle = window.getComputedStyle(body.parent); 7320 var bodyComputedOverflowX = bodyComputedStyle.overflowX; 7321 var bodyComputedOverflowY = bodyComputedStyle.overflowY; 7322 var parentComputedOverflowX = parentComputedStyle.overflowX; 7323 var parentComputedOverflowY = parentComputedStyle.overflowY; 7324 7325 return ( 7326 ( 7327 bodyComputedStyle.display == "table-column" || 7328 bodyComputedStyle.display == "table-column-group" 7329 ) && ( 7330 parentComputedOverflowX != "visible" && 7331 parentComputedOverflowX != "clip" && 7332 parentComputedOverflowY != "visible" && 7333 parentComputedOverflowY != "clip" 7334 ) && ( 7335 bodyComputedOverflowX != "visible" && 7336 bodyComputedOverflowX != "clip" && 7337 bodyComputedOverflowY != "visible" && 7338 bodyComputedOverflowY != "clip" 7339 ) 7340 ); 7341 } 7342 7343 if (!Element.prototype.scroll) { 7344 Element.prototype.scroll = function () { 7345 var argsLength = arguments.length; 7346 var doc = this.ownerDocument; 7347 var win = doc.defaultView; 7348 var quirksMode = (doc.compatMode == "BackCompat"); 7349 var body = document.getElementsByTagName("BODY")[0]; 7350 var options = {}; 7351 var x, y; 7352 7353 if (doc != window.document) return; 7354 if (!win) return; 7355 7356 if (argsLength === 0) { 7357 return; 7358 } else if (argsLength === 1) { 7359 var arg = arguments[0]; 7360 if (typeof arg != "object") throw "Failed to execute 'scrollBy' on 'Element': parameter 1 ('options') is not an object."; 7361 7362 if ('left' in arg) { 7363 options.left = normalizeNonFiniteValue(arg.left); 7364 } 7365 7366 if ('top' in arg) { 7367 options.top = normalizeNonFiniteValue(arg.top); 7368 } 7369 7370 x = (('left' in options) ? options.left : this.scrollLeft); 7371 y = (('top' in options) ? options.top : this.scrollTop); 7372 } else { 7373 options.left = x = normalizeNonFiniteValue(arguments[0]); 7374 options.top = y = normalizeNonFiniteValue(arguments[1]); 7375 } 7376 7377 if (this == document.documentElement) { 7378 if (quirksMode) return; 7379 7380 win.scroll(('scrollX' in win) ? win.scrollX : (('pageXOffset' in win) ? win.pageXOffset : this.scrollLeft), y); 7381 return; 7382 } 7383 7384 if (this == body && quirksMode && !isBodyPotentiallyScrollable(body)) { 7385 win.scroll(options.left, options.top); 7386 return; 7387 } 7388 7389 this.scrollLeft = x; 7390 this.scrollTop = y; 7391 }; 7392 } 7393 7394 if (!Element.prototype.scrollTo) { 7395 Element.prototype.scrollTo = Element.prototype.scroll; 7396 } 7397 7398 if (!Element.prototype.scrollBy) { 7399 Element.prototype.scrollBy = function () { 7400 var argsLength = arguments.length; 7401 var options = {}; 7402 7403 if (argsLength === 0) { 7404 return; 7405 } else if (argsLength === 1) { 7406 var arg = arguments[0]; 7407 if (typeof arg != "object") throw "Failed to execute 'scrollBy' on 'Element': parameter 1 ('options') is not an object."; 7408 7409 if ('left' in arg) { 7410 options.left = normalizeNonFiniteValue(arg.left); 7411 } 7412 7413 if ('top' in arg) { 7414 options.top = normalizeNonFiniteValue(arg.top); 7415 } 7416 } else { 7417 options.left = normalizeNonFiniteValue(arguments[0]); 7418 options.top = normalizeNonFiniteValue(arguments[1]); 7419 } 7420 7421 options.left = (('left' in options) ? options.left + this.scrollLeft : this.scrollLeft); 7422 options.top = (('top' in options) ? options.top + this.scrollTop : this.scrollTop); 7423 this.scroll(options); 7424 }; 7425 } 7426})(); 7427 7428 7429/***/ }), 7430
vendor: 4,989 bytes, lines 7431-7602
7431/***/ "../../node_modules/fast-safe-stringify/index.js": 7432/*!******************************************************************************************************************************************!*\ 7433 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/fast-safe-stringify/index.js ***! 7434 \******************************************************************************************************************************************/ 7435/*! no static exports found */ 7436/***/ (function(module, exports) { 7437 7438module.exports = stringify 7439stringify.default = stringify 7440stringify.stable = deterministicStringify 7441stringify.stableStringify = deterministicStringify 7442 7443var arr = [] 7444var replacerStack = [] 7445 7446// Regular stringify 7447function stringify (obj, replacer, spacer) { 7448 decirc(obj, '', [], undefined) 7449 var res 7450 if (replacerStack.length === 0) { 7451 res = JSON.stringify(obj, replacer, spacer) 7452 } else { 7453 res = JSON.stringify(obj, replaceGetterValues(replacer), spacer) 7454 } 7455 while (arr.length !== 0) { 7456 var part = arr.pop() 7457 if (part.length === 4) { 7458 Object.defineProperty(part[0], part[1], part[3]) 7459 } else { 7460 part[0][part[1]] = part[2] 7461 } 7462 } 7463 return res 7464} 7465function decirc (val, k, stack, parent) { 7466 var i 7467 if (typeof val === 'object' && val !== null) { 7468 for (i = 0; i < stack.length; i++) { 7469 if (stack[i] === val) { 7470 var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k) 7471 if (propertyDescriptor.get !== undefined) { 7472 if (propertyDescriptor.configurable) { 7473 Object.defineProperty(parent, k, { value: '[Circular]' }) 7474 arr.push([parent, k, val, propertyDescriptor]) 7475 } else { 7476 replacerStack.push([val, k]) 7477 } 7478 } else { 7479 parent[k] = '[Circular]' 7480 arr.push([parent, k, val]) 7481 } 7482 return 7483 } 7484 } 7485 stack.push(val) 7486 // Optimize for Arrays. Big arrays could kill the performance otherwise! 7487 if (Array.isArray(val)) { 7488 for (i = 0; i < val.length; i++) { 7489 decirc(val[i], i, stack, val) 7490 } 7491 } else { 7492 var keys = Object.keys(val) 7493 for (i = 0; i < keys.length; i++) { 7494 var key = keys[i] 7495 decirc(val[key], key, stack, val) 7496 } 7497 } 7498 stack.pop() 7499 } 7500} 7501 7502// Stable-stringify 7503function compareFunction (a, b) { 7504 if (a < b) { 7505 return -1 7506 } 7507 if (a > b) { 7508 return 1 7509 } 7510 return 0 7511} 7512 7513function deterministicStringify (obj, replacer, spacer) { 7514 var tmp = deterministicDecirc(obj, '', [], undefined) || obj 7515 var res 7516 if (replacerStack.length === 0) { 7517 res = JSON.stringify(tmp, replacer, spacer) 7518 } else { 7519 res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer) 7520 } 7521 while (arr.length !== 0) { 7522 var part = arr.pop() 7523 if (part.length === 4) { 7524 Object.defineProperty(part[0], part[1], part[3]) 7525 } else { 7526 part[0][part[1]] = part[2] 7527 } 7528 } 7529 return res 7530} 7531 7532function deterministicDecirc (val, k, stack, parent) { 7533 var i 7534 if (typeof val === 'object' && val !== null) { 7535 for (i = 0; i < stack.length; i++) { 7536 if (stack[i] === val) { 7537 var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k) 7538 if (propertyDescriptor.get !== undefined) { 7539 if (propertyDescriptor.configurable) { 7540 Object.defineProperty(parent, k, { value: '[Circular]' }) 7541 arr.push([parent, k, val, propertyDescriptor]) 7542 } else { 7543 replacerStack.push([val, k]) 7544 } 7545 } else { 7546 parent[k] = '[Circular]' 7547 arr.push([parent, k, val]) 7548 } 7549 return 7550 } 7551 } 7552 if (typeof val.toJSON === 'function') { 7553 return 7554 } 7555 stack.push(val) 7556 // Optimize for Arrays. Big arrays could kill the performance otherwise! 7557 if (Array.isArray(val)) { 7558 for (i = 0; i < val.length; i++) { 7559 deterministicDecirc(val[i], i, stack, val) 7560 } 7561 } else { 7562 // Create a temporary object in the required way 7563 var tmp = {} 7564 var keys = Object.keys(val).sort(compareFunction) 7565 for (i = 0; i < keys.length; i++) { 7566 var key = keys[i] 7567 deterministicDecirc(val[key], key, stack, val) 7568 tmp[key] = val[key] 7569 } 7570 if (parent !== undefined) { 7571 arr.push([parent, k, val]) 7572 parent[k] = tmp 7573 } else { 7574 return tmp 7575 } 7576 } 7577 stack.pop() 7578 } 7579} 7580 7581// wraps replacer function to handle values we couldn't replace 7582// and mark them as [Circular] 7583function replaceGetterValues (replacer) { 7584 replacer = replacer !== undefined ? replacer : function (k, v) { return v } 7585 return function (key, val) { 7586 if (replacerStack.length > 0) { 7587 for (var i = 0; i < replacerStack.length; i++) { 7588 var part = replacerStack[i] 7589 if (part[1] === key && part[0] === val) { 7590 val = '[Circular]' 7591 replacerStack.splice(i, 1) 7592 break 7593 } 7594 } 7595 } 7596 return replacer.call(this, key, val) 7597 } 7598} 7599 7600 7601/***/ }), 7602
vendor: 2,674 bytes, lines 7603-7704
7603/***/ "../../node_modules/object-assign/index.js": 7604/*!************************************************************************************************************************************!*\ 7605 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/object-assign/index.js ***! 7606 \************************************************************************************************************************************/ 7607/*! no static exports found */ 7608/***/ (function(module, exports, __webpack_require__) { 7609 7610"use strict"; 7611/* 7612object-assign 7613(c) Sindre Sorhus 7614@license MIT 7615*/ 7616 7617 7618/* eslint-disable no-unused-vars */ 7619var getOwnPropertySymbols = Object.getOwnPropertySymbols; 7620var hasOwnProperty = Object.prototype.hasOwnProperty; 7621var propIsEnumerable = Object.prototype.propertyIsEnumerable; 7622 7623function toObject(val) { 7624 if (val === null || val === undefined) { 7625 throw new TypeError('Object.assign cannot be called with null or undefined'); 7626 } 7627 7628 return Object(val); 7629} 7630 7631function shouldUseNative() { 7632 try { 7633 if (!Object.assign) { 7634 return false; 7635 } 7636 7637 // Detect buggy property enumeration order in older V8 versions. 7638 7639 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 7640 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 7641 test1[5] = 'de'; 7642 if (Object.getOwnPropertyNames(test1)[0] === '5') { 7643 return false; 7644 } 7645 7646 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 7647 var test2 = {}; 7648 for (var i = 0; i < 10; i++) { 7649 test2['_' + String.fromCharCode(i)] = i; 7650 } 7651 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 7652 return test2[n]; 7653 }); 7654 if (order2.join('') !== '0123456789') { 7655 return false; 7656 } 7657 7658 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 7659 var test3 = {}; 7660 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 7661 test3[letter] = letter; 7662 }); 7663 if (Object.keys(Object.assign({}, test3)).join('') !== 7664 'abcdefghijklmnopqrst') { 7665 return false; 7666 } 7667 7668 return true; 7669 } catch (err) { 7670 // We don't expect any of the above to throw, but better to be safe. 7671 return false; 7672 } 7673} 7674 7675module.exports = shouldUseNative() ? Object.assign : function (target, source) { 7676 var from; 7677 var to = toObject(target); 7678 var symbols; 7679 7680 for (var s = 1; s < arguments.length; s++) { 7681 from = Object(arguments[s]); 7682 7683 for (var key in from) { 7684 if (hasOwnProperty.call(from, key)) { 7685 to[key] = from[key]; 7686 } 7687 } 7688 7689 if (getOwnPropertySymbols) { 7690 symbols = getOwnPropertySymbols(from); 7691 for (var i = 0; i < symbols.length; i++) { 7692 if (propIsEnumerable.call(from, symbols[i])) { 7693 to[symbols[i]] = from[symbols[i]]; 7694 } 7695 } 7696 } 7697 } 7698 7699 return to; 7700}; 7701 7702 7703/***/ }), 7704
vendor: 4,349 bytes, lines 7705-7818
7705/***/ "../../node_modules/prop-types/checkPropTypes.js": 7706/*!******************************************************************************************************************************************!*\ 7707 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/prop-types/checkPropTypes.js ***! 7708 \******************************************************************************************************************************************/ 7709/*! no static exports found */ 7710/***/ (function(module, exports, __webpack_require__) { 7711 7712"use strict"; 7713/** 7714 * Copyright (c) 2013-present, Facebook, Inc. 7715 * 7716 * This source code is licensed under the MIT license found in the 7717 * LICENSE file in the root directory of this source tree. 7718 */ 7719 7720 7721 7722var printWarning = function() {}; 7723 7724if (true) { 7725 var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js"); 7726 var loggedTypeFailures = {}; 7727 var has = Function.call.bind(Object.prototype.hasOwnProperty); 7728 7729 printWarning = function(text) { 7730 var message = 'Warning: ' + text; 7731 if (typeof console !== 'undefined') { 7732 console.error(message); 7733 } 7734 try { 7735 // --- Welcome to debugging React --- 7736 // This error was thrown as a convenience so that you can use this stack 7737 // to find the callsite that caused this warning to fire. 7738 throw new Error(message); 7739 } catch (x) {} 7740 }; 7741} 7742 7743/** 7744 * Assert that the values match with the type specs. 7745 * Error messages are memorized and will only be shown once. 7746 * 7747 * @param {object} typeSpecs Map of name to a ReactPropType 7748 * @param {object} values Runtime values that need to be type-checked 7749 * @param {string} location e.g. "prop", "context", "child context" 7750 * @param {string} componentName Name of the component for error messages. 7751 * @param {?Function} getStack Returns the component stack. 7752 * @private 7753 */ 7754function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 7755 if (true) { 7756 for (var typeSpecName in typeSpecs) { 7757 if (has(typeSpecs, typeSpecName)) { 7758 var error; 7759 // Prop type validation may throw. In case they do, we don't want to 7760 // fail the render phase where it didn't fail before. So we log it. 7761 // After these have been cleaned up, we'll let them throw. 7762 try { 7763 // This is intentionally an invariant that gets caught. It's the same 7764 // behavior as without this statement except with a better message. 7765 if (typeof typeSpecs[typeSpecName] !== 'function') { 7766 var err = Error( 7767 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 7768 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' 7769 ); 7770 err.name = 'Invariant Violation'; 7771 throw err; 7772 } 7773 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 7774 } catch (ex) { 7775 error = ex; 7776 } 7777 if (error && !(error instanceof Error)) { 7778 printWarning( 7779 (componentName || 'React class') + ': type specification of ' + 7780 location + ' `' + typeSpecName + '` is invalid; the type checker ' + 7781 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 7782 'You may have forgotten to pass an argument to the type checker ' + 7783 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 7784 'shape all require an argument).' 7785 ); 7786 } 7787 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 7788 // Only monitor this failure once because there tends to be a lot of the 7789 // same error. 7790 loggedTypeFailures[error.message] = true; 7791 7792 var stack = getStack ? getStack() : ''; 7793 7794 printWarning( 7795 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') 7796 ); 7797 } 7798 } 7799 } 7800 } 7801} 7802 7803/** 7804 * Resets warning cache when testing. 7805 * 7806 * @private 7807 */ 7808checkPropTypes.resetWarningCache = function() { 7809 if (true) { 7810 loggedTypeFailures = {}; 7811 } 7812} 7813 7814module.exports = checkPropTypes; 7815 7816 7817/***/ }), 7818
vendor: 944 bytes, lines 7819-7842
7819/***/ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js": 7820/*!****************************************************************************************************************************************************!*\ 7821 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/prop-types/lib/ReactPropTypesSecret.js ***! 7822 \****************************************************************************************************************************************************/ 7823/*! no static exports found */ 7824/***/ (function(module, exports, __webpack_require__) { 7825 7826"use strict"; 7827/** 7828 * Copyright (c) 2013-present, Facebook, Inc. 7829 * 7830 * This source code is licensed under the MIT license found in the 7831 * LICENSE file in the root directory of this source tree. 7832 */ 7833 7834 7835 7836var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 7837 7838module.exports = ReactPropTypesSecret; 7839 7840 7841/***/ }), 7842
vendor: 859,709 bytes, lines 7843-32866
7843/***/ "../../node_modules/react-dom/cjs/react-dom.development.js": 7844/*!****************************************************************************************************************************************************!*\ 7845 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/react-dom/cjs/react-dom.development.js ***! 7846 \****************************************************************************************************************************************************/ 7847/*! no static exports found */ 7848/***/ (function(module, exports, __webpack_require__) { 7849 7850"use strict"; 7851/** @license React v16.13.1 7852 * react-dom.development.js 7853 * 7854 * Copyright (c) Facebook, Inc. and its affiliates. 7855 * 7856 * This source code is licensed under the MIT license found in the 7857 * LICENSE file in the root directory of this source tree. 7858 */ 7859 7860 7861 7862 7863 7864if (true) { 7865 (function() { 7866'use strict'; 7867 7868var React = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 7869var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js"); 7870var Scheduler = __webpack_require__(/*! scheduler */ "../../node_modules/scheduler/index.js"); 7871var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js"); 7872var tracing = __webpack_require__(/*! scheduler/tracing */ "../../node_modules/scheduler/tracing.js"); 7873 7874var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. 7875// Current owner and dispatcher used to share the same ref, 7876// but PR #14548 split them out to better support the react-debug-tools package. 7877 7878if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { 7879 ReactSharedInternals.ReactCurrentDispatcher = { 7880 current: null 7881 }; 7882} 7883 7884if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { 7885 ReactSharedInternals.ReactCurrentBatchConfig = { 7886 suspense: null 7887 }; 7888} 7889 7890// by calls to these methods by a Babel plugin. 7891// 7892// In PROD (or in packages without access to React internals), 7893// they are left as they are instead. 7894 7895function warn(format) { 7896 { 7897 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 7898 args[_key - 1] = arguments[_key]; 7899 } 7900 7901 printWarning('warn', format, args); 7902 } 7903} 7904function error(format) { 7905 { 7906 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 7907 args[_key2 - 1] = arguments[_key2]; 7908 } 7909 7910 printWarning('error', format, args); 7911 } 7912} 7913 7914function printWarning(level, format, args) { 7915 // When changing this logic, you might want to also 7916 // update consoleWithStackDev.www.js as well. 7917 { 7918 var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; 7919 7920 if (!hasExistingStack) { 7921 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 7922 var stack = ReactDebugCurrentFrame.getStackAddendum(); 7923 7924 if (stack !== '') { 7925 format += '%s'; 7926 args = args.concat([stack]); 7927 } 7928 } 7929 7930 var argsWithFormat = args.map(function (item) { 7931 return '' + item; 7932 }); // Careful: RN currently depends on this prefix 7933 7934 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 7935 // breaks IE9: https://github.com/facebook/react/issues/13610 7936 // eslint-disable-next-line react-internal/no-production-logging 7937 7938 Function.prototype.apply.call(console[level], console, argsWithFormat); 7939 7940 try { 7941 // --- Welcome to debugging React --- 7942 // This error was thrown as a convenience so that you can use this stack 7943 // to find the callsite that caused this warning to fire. 7944 var argIndex = 0; 7945 var message = 'Warning: ' + format.replace(/%s/g, function () { 7946 return args[argIndex++]; 7947 }); 7948 throw new Error(message); 7949 } catch (x) {} 7950 } 7951} 7952 7953if (!React) { 7954 { 7955 throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); 7956 } 7957} 7958 7959var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { 7960 var funcArgs = Array.prototype.slice.call(arguments, 3); 7961 7962 try { 7963 func.apply(context, funcArgs); 7964 } catch (error) { 7965 this.onError(error); 7966 } 7967}; 7968 7969{ 7970 // In DEV mode, we swap out invokeGuardedCallback for a special version 7971 // that plays more nicely with the browser's DevTools. The idea is to preserve 7972 // "Pause on exceptions" behavior. Because React wraps all user-provided 7973 // functions in invokeGuardedCallback, and the production version of 7974 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 7975 // like caught exceptions, and the DevTools won't pause unless the developer 7976 // takes the extra step of enabling pause on caught exceptions. This is 7977 // unintuitive, though, because even though React has caught the error, from 7978 // the developer's perspective, the error is uncaught. 7979 // 7980 // To preserve the expected "Pause on exceptions" behavior, we don't use a 7981 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 7982 // DOM node, and call the user-provided callback from inside an event handler 7983 // for that fake event. If the callback throws, the error is "captured" using 7984 // a global event handler. But because the error happens in a different 7985 // event loop context, it does not interrupt the normal program flow. 7986 // Effectively, this gives us try-catch behavior without actually using 7987 // try-catch. Neat! 7988 // Check that the browser supports the APIs we need to implement our special 7989 // DEV version of invokeGuardedCallback 7990 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 7991 var fakeNode = document.createElement('react'); 7992 7993 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { 7994 // If document doesn't exist we know for sure we will crash in this method 7995 // when we call document.createEvent(). However this can cause confusing 7996 // errors: https://github.com/facebookincubator/create-react-app/issues/3482 7997 // So we preemptively throw with a better message instead. 7998 if (!(typeof document !== 'undefined')) { 7999 { 8000 throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." ); 8001 } 8002 } 8003 8004 var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We 8005 // set this to true at the beginning, then set it to false right after 8006 // calling the function. If the function errors, `didError` will never be 8007 // set to false. This strategy works even if the browser is flaky and 8008 // fails to call our global error handler, because it doesn't rely on 8009 // the error event at all. 8010 8011 var didError = true; // Keeps track of the value of window.event so that we can reset it 8012 // during the callback to let user code access window.event in the 8013 // browsers that support it. 8014 8015 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event 8016 // dispatching: https://github.com/facebook/react/issues/13688 8017 8018 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously 8019 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 8020 // call the user-provided callback. 8021 8022 var funcArgs = Array.prototype.slice.call(arguments, 3); 8023 8024 function callCallback() { 8025 // We immediately remove the callback from event listeners so that 8026 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 8027 // nested call would trigger the fake event handlers of any call higher 8028 // in the stack. 8029 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the 8030 // window.event assignment in both IE <= 10 as they throw an error 8031 // "Member not found" in strict mode, and in Firefox which does not 8032 // support window.event. 8033 8034 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { 8035 window.event = windowEvent; 8036 } 8037 8038 func.apply(context, funcArgs); 8039 didError = false; 8040 } // Create a global error event handler. We use this to capture the value 8041 // that was thrown. It's possible that this error handler will fire more 8042 // than once; for example, if non-React code also calls `dispatchEvent` 8043 // and a handler for that event throws. We should be resilient to most of 8044 // those cases. Even if our error event handler fires more than once, the 8045 // last error event is always used. If the callback actually does error, 8046 // we know that the last error event is the correct one, because it's not 8047 // possible for anything else to have happened in between our callback 8048 // erroring and the code that follows the `dispatchEvent` call below. If 8049 // the callback doesn't error, but the error event was fired, we know to 8050 // ignore it because `didError` will be false, as described above. 8051 8052 8053 var error; // Use this to track whether the error event is ever called. 8054 8055 var didSetError = false; 8056 var isCrossOriginError = false; 8057 8058 function handleWindowError(event) { 8059 error = event.error; 8060 didSetError = true; 8061 8062 if (error === null && event.colno === 0 && event.lineno === 0) { 8063 isCrossOriginError = true; 8064 } 8065 8066 if (event.defaultPrevented) { 8067 // Some other error handler has prevented default. 8068 // Browsers silence the error report if this happens. 8069 // We'll remember this to later decide whether to log it or not. 8070 if (error != null && typeof error === 'object') { 8071 try { 8072 error._suppressLogging = true; 8073 } catch (inner) {// Ignore. 8074 } 8075 } 8076 } 8077 } // Create a fake event type. 8078 8079 8080 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers 8081 8082 window.addEventListener('error', handleWindowError); 8083 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function 8084 // errors, it will trigger our global error handler. 8085 8086 evt.initEvent(evtType, false, false); 8087 fakeNode.dispatchEvent(evt); 8088 8089 if (windowEventDescriptor) { 8090 Object.defineProperty(window, 'event', windowEventDescriptor); 8091 } 8092 8093 if (didError) { 8094 if (!didSetError) { 8095 // The callback errored, but the error event never fired. 8096 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.'); 8097 } else if (isCrossOriginError) { 8098 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.'); 8099 } 8100 8101 this.onError(error); 8102 } // Remove our event listeners 8103 8104 8105 window.removeEventListener('error', handleWindowError); 8106 }; 8107 8108 invokeGuardedCallbackImpl = invokeGuardedCallbackDev; 8109 } 8110} 8111 8112var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; 8113 8114var hasError = false; 8115var caughtError = null; // Used by event system to capture/rethrow the first error. 8116 8117var hasRethrowError = false; 8118var rethrowError = null; 8119var reporter = { 8120 onError: function (error) { 8121 hasError = true; 8122 caughtError = error; 8123 } 8124}; 8125/** 8126 * Call a function while guarding against errors that happens within it. 8127 * Returns an error if it throws, otherwise null. 8128 * 8129 * In production, this is implemented using a try-catch. The reason we don't 8130 * use a try-catch directly is so that we can swap out a different 8131 * implementation in DEV mode. 8132 * 8133 * @param {String} name of the guard to use for logging or debugging 8134 * @param {Function} func The function to invoke 8135 * @param {*} context The context to use when calling the function 8136 * @param {...*} args Arguments for function 8137 */ 8138 8139function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { 8140 hasError = false; 8141 caughtError = null; 8142 invokeGuardedCallbackImpl$1.apply(reporter, arguments); 8143} 8144/** 8145 * Same as invokeGuardedCallback, but instead of returning an error, it stores 8146 * it in a global so it can be rethrown by `rethrowCaughtError` later. 8147 * TODO: See if caughtError and rethrowError can be unified. 8148 * 8149 * @param {String} name of the guard to use for logging or debugging 8150 * @param {Function} func The function to invoke 8151 * @param {*} context The context to use when calling the function 8152 * @param {...*} args Arguments for function 8153 */ 8154 8155function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { 8156 invokeGuardedCallback.apply(this, arguments); 8157 8158 if (hasError) { 8159 var error = clearCaughtError(); 8160 8161 if (!hasRethrowError) { 8162 hasRethrowError = true; 8163 rethrowError = error; 8164 } 8165 } 8166} 8167/** 8168 * During execution of guarded functions we will capture the first error which 8169 * we will rethrow to be handled by the top level error handler. 8170 */ 8171 8172function rethrowCaughtError() { 8173 if (hasRethrowError) { 8174 var error = rethrowError; 8175 hasRethrowError = false; 8176 rethrowError = null; 8177 throw error; 8178 } 8179} 8180function hasCaughtError() { 8181 return hasError; 8182} 8183function clearCaughtError() { 8184 if (hasError) { 8185 var error = caughtError; 8186 hasError = false; 8187 caughtError = null; 8188 return error; 8189 } else { 8190 { 8191 { 8192 throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); 8193 } 8194 } 8195 } 8196} 8197 8198var getFiberCurrentPropsFromNode = null; 8199var getInstanceFromNode = null; 8200var getNodeFromInstance = null; 8201function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { 8202 getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; 8203 getInstanceFromNode = getInstanceFromNodeImpl; 8204 getNodeFromInstance = getNodeFromInstanceImpl; 8205 8206 { 8207 if (!getNodeFromInstance || !getInstanceFromNode) { 8208 error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); 8209 } 8210 } 8211} 8212var validateEventDispatches; 8213 8214{ 8215 validateEventDispatches = function (event) { 8216 var dispatchListeners = event._dispatchListeners; 8217 var dispatchInstances = event._dispatchInstances; 8218 var listenersIsArr = Array.isArray(dispatchListeners); 8219 var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; 8220 var instancesIsArr = Array.isArray(dispatchInstances); 8221 var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; 8222 8223 if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { 8224 error('EventPluginUtils: Invalid `event`.'); 8225 } 8226 }; 8227} 8228/** 8229 * Dispatch the event to the listener. 8230 * @param {SyntheticEvent} event SyntheticEvent to handle 8231 * @param {function} listener Application-level callback 8232 * @param {*} inst Internal component instance 8233 */ 8234 8235 8236function executeDispatch(event, listener, inst) { 8237 var type = event.type || 'unknown-event'; 8238 event.currentTarget = getNodeFromInstance(inst); 8239 invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 8240 event.currentTarget = null; 8241} 8242/** 8243 * Standard/simple iteration through an event's collected dispatches. 8244 */ 8245 8246function executeDispatchesInOrder(event) { 8247 var dispatchListeners = event._dispatchListeners; 8248 var dispatchInstances = event._dispatchInstances; 8249 8250 { 8251 validateEventDispatches(event); 8252 } 8253 8254 if (Array.isArray(dispatchListeners)) { 8255 for (var i = 0; i < dispatchListeners.length; i++) { 8256 if (event.isPropagationStopped()) { 8257 break; 8258 } // Listeners and Instances are two parallel arrays that are always in sync. 8259 8260 8261 executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); 8262 } 8263 } else if (dispatchListeners) { 8264 executeDispatch(event, dispatchListeners, dispatchInstances); 8265 } 8266 8267 event._dispatchListeners = null; 8268 event._dispatchInstances = null; 8269} 8270 8271var FunctionComponent = 0; 8272var ClassComponent = 1; 8273var IndeterminateComponent = 2; // Before we know whether it is function or class 8274 8275var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 8276 8277var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 8278 8279var HostComponent = 5; 8280var HostText = 6; 8281var Fragment = 7; 8282var Mode = 8; 8283var ContextConsumer = 9; 8284var ContextProvider = 10; 8285var ForwardRef = 11; 8286var Profiler = 12; 8287var SuspenseComponent = 13; 8288var MemoComponent = 14; 8289var SimpleMemoComponent = 15; 8290var LazyComponent = 16; 8291var IncompleteClassComponent = 17; 8292var DehydratedFragment = 18; 8293var SuspenseListComponent = 19; 8294var FundamentalComponent = 20; 8295var ScopeComponent = 21; 8296var Block = 22; 8297 8298/** 8299 * Injectable ordering of event plugins. 8300 */ 8301var eventPluginOrder = null; 8302/** 8303 * Injectable mapping from names to event plugin modules. 8304 */ 8305 8306var namesToPlugins = {}; 8307/** 8308 * Recomputes the plugin list using the injected plugins and plugin ordering. 8309 * 8310 * @private 8311 */ 8312 8313function recomputePluginOrdering() { 8314 if (!eventPluginOrder) { 8315 // Wait until an `eventPluginOrder` is injected. 8316 return; 8317 } 8318 8319 for (var pluginName in namesToPlugins) { 8320 var pluginModule = namesToPlugins[pluginName]; 8321 var pluginIndex = eventPluginOrder.indexOf(pluginName); 8322 8323 if (!(pluginIndex > -1)) { 8324 { 8325 throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." ); 8326 } 8327 } 8328 8329 if (plugins[pluginIndex]) { 8330 continue; 8331 } 8332 8333 if (!pluginModule.extractEvents) { 8334 { 8335 throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." ); 8336 } 8337 } 8338 8339 plugins[pluginIndex] = pluginModule; 8340 var publishedEvents = pluginModule.eventTypes; 8341 8342 for (var eventName in publishedEvents) { 8343 if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { 8344 { 8345 throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." ); 8346 } 8347 } 8348 } 8349 } 8350} 8351/** 8352 * Publishes an event so that it can be dispatched by the supplied plugin. 8353 * 8354 * @param {object} dispatchConfig Dispatch configuration for the event. 8355 * @param {object} PluginModule Plugin publishing the event. 8356 * @return {boolean} True if the event was successfully published. 8357 * @private 8358 */ 8359 8360 8361function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { 8362 if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { 8363 { 8364 throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + eventName + "`." ); 8365 } 8366 } 8367 8368 eventNameDispatchConfigs[eventName] = dispatchConfig; 8369 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; 8370 8371 if (phasedRegistrationNames) { 8372 for (var phaseName in phasedRegistrationNames) { 8373 if (phasedRegistrationNames.hasOwnProperty(phaseName)) { 8374 var phasedRegistrationName = phasedRegistrationNames[phaseName]; 8375 publishRegistrationName(phasedRegistrationName, pluginModule, eventName); 8376 } 8377 } 8378 8379 return true; 8380 } else if (dispatchConfig.registrationName) { 8381 publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); 8382 return true; 8383 } 8384 8385 return false; 8386} 8387/** 8388 * Publishes a registration name that is used to identify dispatched events. 8389 * 8390 * @param {string} registrationName Registration name to add. 8391 * @param {object} PluginModule Plugin publishing the event. 8392 * @private 8393 */ 8394 8395 8396function publishRegistrationName(registrationName, pluginModule, eventName) { 8397 if (!!registrationNameModules[registrationName]) { 8398 { 8399 throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + registrationName + "`." ); 8400 } 8401 } 8402 8403 registrationNameModules[registrationName] = pluginModule; 8404 registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; 8405 8406 { 8407 var lowerCasedName = registrationName.toLowerCase(); 8408 possibleRegistrationNames[lowerCasedName] = registrationName; 8409 8410 if (registrationName === 'onDoubleClick') { 8411 possibleRegistrationNames.ondblclick = registrationName; 8412 } 8413 } 8414} 8415/** 8416 * Registers plugins so that they can extract and dispatch events. 8417 */ 8418 8419/** 8420 * Ordered list of injected plugins. 8421 */ 8422 8423 8424var plugins = []; 8425/** 8426 * Mapping from event name to dispatch config 8427 */ 8428 8429var eventNameDispatchConfigs = {}; 8430/** 8431 * Mapping from registration name to plugin module 8432 */ 8433 8434var registrationNameModules = {}; 8435/** 8436 * Mapping from registration name to event name 8437 */ 8438 8439var registrationNameDependencies = {}; 8440/** 8441 * Mapping from lowercase registration names to the properly cased version, 8442 * used to warn in the case of missing event handlers. Available 8443 * only in true. 8444 * @type {Object} 8445 */ 8446 8447var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true 8448 8449/** 8450 * Injects an ordering of plugins (by plugin name). This allows the ordering 8451 * to be decoupled from injection of the actual plugins so that ordering is 8452 * always deterministic regardless of packaging, on-the-fly injection, etc. 8453 * 8454 * @param {array} InjectedEventPluginOrder 8455 * @internal 8456 */ 8457 8458function injectEventPluginOrder(injectedEventPluginOrder) { 8459 if (!!eventPluginOrder) { 8460 { 8461 throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); 8462 } 8463 } // Clone the ordering so it cannot be dynamically mutated. 8464 8465 8466 eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); 8467 recomputePluginOrdering(); 8468} 8469/** 8470 * Injects plugins to be used by plugin event system. The plugin names must be 8471 * in the ordering injected by `injectEventPluginOrder`. 8472 * 8473 * Plugins can be injected as part of page initialization or on-the-fly. 8474 * 8475 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 8476 * @internal 8477 */ 8478 8479function injectEventPluginsByName(injectedNamesToPlugins) { 8480 var isOrderingDirty = false; 8481 8482 for (var pluginName in injectedNamesToPlugins) { 8483 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { 8484 continue; 8485 } 8486 8487 var pluginModule = injectedNamesToPlugins[pluginName]; 8488 8489 if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { 8490 if (!!namesToPlugins[pluginName]) { 8491 { 8492 throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`." ); 8493 } 8494 } 8495 8496 namesToPlugins[pluginName] = pluginModule; 8497 isOrderingDirty = true; 8498 } 8499 } 8500 8501 if (isOrderingDirty) { 8502 recomputePluginOrdering(); 8503 } 8504} 8505 8506var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); 8507 8508var PLUGIN_EVENT_SYSTEM = 1; 8509var IS_REPLAYED = 1 << 5; 8510var IS_FIRST_ANCESTOR = 1 << 6; 8511 8512var restoreImpl = null; 8513var restoreTarget = null; 8514var restoreQueue = null; 8515 8516function restoreStateOfTarget(target) { 8517 // We perform this translation at the end of the event loop so that we 8518 // always receive the correct fiber here 8519 var internalInstance = getInstanceFromNode(target); 8520 8521 if (!internalInstance) { 8522 // Unmounted 8523 return; 8524 } 8525 8526 if (!(typeof restoreImpl === 'function')) { 8527 { 8528 throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); 8529 } 8530 } 8531 8532 var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. 8533 8534 if (stateNode) { 8535 var _props = getFiberCurrentPropsFromNode(stateNode); 8536 8537 restoreImpl(internalInstance.stateNode, internalInstance.type, _props); 8538 } 8539} 8540 8541function setRestoreImplementation(impl) { 8542 restoreImpl = impl; 8543} 8544function enqueueStateRestore(target) { 8545 if (restoreTarget) { 8546 if (restoreQueue) { 8547 restoreQueue.push(target); 8548 } else { 8549 restoreQueue = [target]; 8550 } 8551 } else { 8552 restoreTarget = target; 8553 } 8554} 8555function needsStateRestore() { 8556 return restoreTarget !== null || restoreQueue !== null; 8557} 8558function restoreStateIfNeeded() { 8559 if (!restoreTarget) { 8560 return; 8561 } 8562 8563 var target = restoreTarget; 8564 var queuedTargets = restoreQueue; 8565 restoreTarget = null; 8566 restoreQueue = null; 8567 restoreStateOfTarget(target); 8568 8569 if (queuedTargets) { 8570 for (var i = 0; i < queuedTargets.length; i++) { 8571 restoreStateOfTarget(queuedTargets[i]); 8572 } 8573 } 8574} 8575 8576var enableProfilerTimer = true; // Trace which interactions trigger each commit. 8577 8578var enableDeprecatedFlareAPI = false; // Experimental Host Component support. 8579 8580var enableFundamentalAPI = false; // Experimental Scope support. 8581var warnAboutStringRefs = false; 8582 8583// the renderer. Such as when we're dispatching events or if third party 8584// libraries need to call batchedUpdates. Eventually, this API will go away when 8585// everything is batched by default. We'll then have a similar API to opt-out of 8586// scheduled work and instead do synchronous work. 8587// Defaults 8588 8589var batchedUpdatesImpl = function (fn, bookkeeping) { 8590 return fn(bookkeeping); 8591}; 8592 8593var discreteUpdatesImpl = function (fn, a, b, c, d) { 8594 return fn(a, b, c, d); 8595}; 8596 8597var flushDiscreteUpdatesImpl = function () {}; 8598 8599var batchedEventUpdatesImpl = batchedUpdatesImpl; 8600var isInsideEventHandler = false; 8601var isBatchingEventUpdates = false; 8602 8603function finishEventHandler() { 8604 // Here we wait until all updates have propagated, which is important 8605 // when using controlled components within layers: 8606 // https://github.com/facebook/react/issues/1698 8607 // Then we restore state of any controlled component. 8608 var controlledComponentsHavePendingUpdates = needsStateRestore(); 8609 8610 if (controlledComponentsHavePendingUpdates) { 8611 // If a controlled event was fired, we may need to restore the state of 8612 // the DOM node back to the controlled value. This is necessary when React 8613 // bails out of the update without touching the DOM. 8614 flushDiscreteUpdatesImpl(); 8615 restoreStateIfNeeded(); 8616 } 8617} 8618 8619function batchedUpdates(fn, bookkeeping) { 8620 if (isInsideEventHandler) { 8621 // If we are currently inside another batch, we need to wait until it 8622 // fully completes before restoring state. 8623 return fn(bookkeeping); 8624 } 8625 8626 isInsideEventHandler = true; 8627 8628 try { 8629 return batchedUpdatesImpl(fn, bookkeeping); 8630 } finally { 8631 isInsideEventHandler = false; 8632 finishEventHandler(); 8633 } 8634} 8635function batchedEventUpdates(fn, a, b) { 8636 if (isBatchingEventUpdates) { 8637 // If we are currently inside another batch, we need to wait until it 8638 // fully completes before restoring state. 8639 return fn(a, b); 8640 } 8641 8642 isBatchingEventUpdates = true; 8643 8644 try { 8645 return batchedEventUpdatesImpl(fn, a, b); 8646 } finally { 8647 isBatchingEventUpdates = false; 8648 finishEventHandler(); 8649 } 8650} // This is for the React Flare event system 8651function discreteUpdates(fn, a, b, c, d) { 8652 var prevIsInsideEventHandler = isInsideEventHandler; 8653 isInsideEventHandler = true; 8654 8655 try { 8656 return discreteUpdatesImpl(fn, a, b, c, d); 8657 } finally { 8658 isInsideEventHandler = prevIsInsideEventHandler; 8659 8660 if (!isInsideEventHandler) { 8661 finishEventHandler(); 8662 } 8663 } 8664} 8665function flushDiscreteUpdatesIfNeeded(timeStamp) { 8666 // event.timeStamp isn't overly reliable due to inconsistencies in 8667 // how different browsers have historically provided the time stamp. 8668 // Some browsers provide high-resolution time stamps for all events, 8669 // some provide low-resolution time stamps for all events. FF < 52 8670 // even mixes both time stamps together. Some browsers even report 8671 // negative time stamps or time stamps that are 0 (iOS9) in some cases. 8672 // Given we are only comparing two time stamps with equality (!==), 8673 // we are safe from the resolution differences. If the time stamp is 0 8674 // we bail-out of preventing the flush, which can affect semantics, 8675 // such as if an earlier flush removes or adds event listeners that 8676 // are fired in the subsequent flush. However, this is the same 8677 // behaviour as we had before this change, so the risks are low. 8678 if (!isInsideEventHandler && (!enableDeprecatedFlareAPI )) { 8679 flushDiscreteUpdatesImpl(); 8680 } 8681} 8682function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { 8683 batchedUpdatesImpl = _batchedUpdatesImpl; 8684 discreteUpdatesImpl = _discreteUpdatesImpl; 8685 flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; 8686 batchedEventUpdatesImpl = _batchedEventUpdatesImpl; 8687} 8688 8689var DiscreteEvent = 0; 8690var UserBlockingEvent = 1; 8691var ContinuousEvent = 2; 8692 8693// A reserved attribute. 8694// It is handled by React separately and shouldn't be written to the DOM. 8695var RESERVED = 0; // A simple string attribute. 8696// Attributes that aren't in the whitelist are presumed to have this type. 8697 8698var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called 8699// "enumerated" attributes with "true" and "false" as possible values. 8700// When true, it should be set to a "true" string. 8701// When false, it should be set to a "false" string. 8702 8703var BOOLEANISH_STRING = 2; // A real boolean attribute. 8704// When true, it should be present (set either to an empty string or its name). 8705// When false, it should be omitted. 8706 8707var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. 8708// When true, it should be present (set either to an empty string or its name). 8709// When false, it should be omitted. 8710// For any other value, should be present with that value. 8711 8712var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. 8713// When falsy, it should be removed. 8714 8715var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. 8716// When falsy, it should be removed. 8717 8718var POSITIVE_NUMERIC = 6; 8719 8720/* eslint-disable max-len */ 8721var 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"; 8722/* eslint-enable max-len */ 8723 8724var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; 8725var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 8726var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 8727var hasOwnProperty = Object.prototype.hasOwnProperty; 8728var illegalAttributeNameCache = {}; 8729var validatedAttributeNameCache = {}; 8730function isAttributeNameSafe(attributeName) { 8731 if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { 8732 return true; 8733 } 8734 8735 if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { 8736 return false; 8737 } 8738 8739 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 8740 validatedAttributeNameCache[attributeName] = true; 8741 return true; 8742 } 8743 8744 illegalAttributeNameCache[attributeName] = true; 8745 8746 { 8747 error('Invalid attribute name: `%s`', attributeName); 8748 } 8749 8750 return false; 8751} 8752function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { 8753 if (propertyInfo !== null) { 8754 return propertyInfo.type === RESERVED; 8755 } 8756 8757 if (isCustomComponentTag) { 8758 return false; 8759 } 8760 8761 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 8762 return true; 8763 } 8764 8765 return false; 8766} 8767function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { 8768 if (propertyInfo !== null && propertyInfo.type === RESERVED) { 8769 return false; 8770 } 8771 8772 switch (typeof value) { 8773 case 'function': // $FlowIssue symbol is perfectly valid here 8774 8775 case 'symbol': 8776 // eslint-disable-line 8777 return true; 8778 8779 case 'boolean': 8780 { 8781 if (isCustomComponentTag) { 8782 return false; 8783 } 8784 8785 if (propertyInfo !== null) { 8786 return !propertyInfo.acceptsBooleans; 8787 } else { 8788 var prefix = name.toLowerCase().slice(0, 5); 8789 return prefix !== 'data-' && prefix !== 'aria-'; 8790 } 8791 } 8792 8793 default: 8794 return false; 8795 } 8796} 8797function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { 8798 if (value === null || typeof value === 'undefined') { 8799 return true; 8800 } 8801 8802 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { 8803 return true; 8804 } 8805 8806 if (isCustomComponentTag) { 8807 return false; 8808 } 8809 8810 if (propertyInfo !== null) { 8811 switch (propertyInfo.type) { 8812 case BOOLEAN: 8813 return !value; 8814 8815 case OVERLOADED_BOOLEAN: 8816 return value === false; 8817 8818 case NUMERIC: 8819 return isNaN(value); 8820 8821 case POSITIVE_NUMERIC: 8822 return isNaN(value) || value < 1; 8823 } 8824 } 8825 8826 return false; 8827} 8828function getPropertyInfo(name) { 8829 return properties.hasOwnProperty(name) ? properties[name] : null; 8830} 8831 8832function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { 8833 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; 8834 this.attributeName = attributeName; 8835 this.attributeNamespace = attributeNamespace; 8836 this.mustUseProperty = mustUseProperty; 8837 this.propertyName = name; 8838 this.type = type; 8839 this.sanitizeURL = sanitizeURL; 8840} // When adding attributes to this list, be sure to also add them to 8841// the `possibleStandardNames` module to ensure casing and incorrect 8842// name warnings. 8843 8844 8845var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. 8846 8847var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular 8848// elements (not just inputs). Now that ReactDOMInput assigns to the 8849// defaultValue property -- do we need this? 8850'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; 8851 8852reservedProps.forEach(function (name) { 8853 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty 8854 name, // attributeName 8855 null, // attributeNamespace 8856 false); 8857}); // A few React string attributes have a different name. 8858// This is a mapping from React prop names to the attribute names. 8859 8860[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { 8861 var name = _ref[0], 8862 attributeName = _ref[1]; 8863 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 8864 attributeName, // attributeName 8865 null, // attributeNamespace 8866 false); 8867}); // These are "enumerated" HTML attributes that accept "true" and "false". 8868// In React, we let users pass `true` and `false` even though technically 8869// these aren't boolean attributes (they are coerced to strings). 8870 8871['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { 8872 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 8873 name.toLowerCase(), // attributeName 8874 null, // attributeNamespace 8875 false); 8876}); // These are "enumerated" SVG attributes that accept "true" and "false". 8877// In React, we let users pass `true` and `false` even though technically 8878// these aren't boolean attributes (they are coerced to strings). 8879// Since these are SVG attributes, their attribute names are case-sensitive. 8880 8881['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { 8882 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 8883 name, // attributeName 8884 null, // attributeNamespace 8885 false); 8886}); // These are HTML boolean attributes. 8887 8888['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM 8889// on the client side because the browsers are inconsistent. Instead we call focus(). 8890'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata 8891'itemScope'].forEach(function (name) { 8892 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty 8893 name.toLowerCase(), // attributeName 8894 null, // attributeNamespace 8895 false); 8896}); // These are the few React props that we set as DOM properties 8897// rather than attributes. These are all booleans. 8898 8899['checked', // Note: `option.selected` is not updated if `select.multiple` is 8900// disabled with `removeAttribute`. We have special logic for handling this. 8901'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, 8902// you'll need to set attributeName to name.toLowerCase() 8903// instead in the assignment below. 8904].forEach(function (name) { 8905 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty 8906 name, // attributeName 8907 null, // attributeNamespace 8908 false); 8909}); // These are HTML attributes that are "overloaded booleans": they behave like 8910// booleans, but can also accept a string value. 8911 8912['capture', 'download' // NOTE: if you add a camelCased prop to this list, 8913// you'll need to set attributeName to name.toLowerCase() 8914// instead in the assignment below. 8915].forEach(function (name) { 8916 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty 8917 name, // attributeName 8918 null, // attributeNamespace 8919 false); 8920}); // These are HTML attributes that must be positive numbers. 8921 8922['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, 8923// you'll need to set attributeName to name.toLowerCase() 8924// instead in the assignment below. 8925].forEach(function (name) { 8926 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty 8927 name, // attributeName 8928 null, // attributeNamespace 8929 false); 8930}); // These are HTML attributes that must be numbers. 8931 8932['rowSpan', 'start'].forEach(function (name) { 8933 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty 8934 name.toLowerCase(), // attributeName 8935 null, // attributeNamespace 8936 false); 8937}); 8938var CAMELIZE = /[\-\:]([a-z])/g; 8939 8940var capitalize = function (token) { 8941 return token[1].toUpperCase(); 8942}; // This is a list of all SVG attributes that need special casing, namespacing, 8943// or boolean value assignment. Regular attributes that just accept strings 8944// and have the same names are omitted, just like in the HTML whitelist. 8945// Some of these attributes can be hard to find. This list was created by 8946// scraping the MDN documentation. 8947 8948 8949['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', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list, 8950// you'll need to set attributeName to name.toLowerCase() 8951// instead in the assignment below. 8952].forEach(function (attributeName) { 8953 var name = attributeName.replace(CAMELIZE, capitalize); 8954 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 8955 attributeName, null, // attributeNamespace 8956 false); 8957}); // String SVG attributes with the xlink namespace. 8958 8959['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, 8960// you'll need to set attributeName to name.toLowerCase() 8961// instead in the assignment below. 8962].forEach(function (attributeName) { 8963 var name = attributeName.replace(CAMELIZE, capitalize); 8964 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 8965 attributeName, 'http://www.w3.org/1999/xlink', false); 8966}); // String SVG attributes with the xml namespace. 8967 8968['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, 8969// you'll need to set attributeName to name.toLowerCase() 8970// instead in the assignment below. 8971].forEach(function (attributeName) { 8972 var name = attributeName.replace(CAMELIZE, capitalize); 8973 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 8974 attributeName, 'http://www.w3.org/XML/1998/namespace', false); 8975}); // These attribute exists both in HTML and SVG. 8976// The attribute name is case-sensitive in SVG so we can't just use 8977// the React name like we do for attributes that exist only in HTML. 8978 8979['tabIndex', 'crossOrigin'].forEach(function (attributeName) { 8980 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 8981 attributeName.toLowerCase(), // attributeName 8982 null, // attributeNamespace 8983 false); 8984}); // These attributes accept URLs. These must not allow javascript: URLS. 8985// These will also need to accept Trusted Types object in the future. 8986 8987var xlinkHref = 'xlinkHref'; 8988properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty 8989'xlink:href', 'http://www.w3.org/1999/xlink', true); 8990['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { 8991 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 8992 attributeName.toLowerCase(), // attributeName 8993 null, // attributeNamespace 8994 true); 8995}); 8996 8997var ReactDebugCurrentFrame = null; 8998 8999{ 9000 ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 9001} // A javascript: URL can contain leading C0 control or \u0020 SPACE, 9002// and any newline or tab are filtered out as if they're not part of the URL. 9003// https://url.spec.whatwg.org/#url-parsing 9004// Tab or newline are defined as \r\n\t: 9005// https://infra.spec.whatwg.org/#ascii-tab-or-newline 9006// A C0 control is a code point in the range \u0000 NULL to \u001F 9007// INFORMATION SEPARATOR ONE, inclusive: 9008// https://infra.spec.whatwg.org/#c0-control-or-space 9009 9010/* eslint-disable max-len */ 9011 9012 9013var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; 9014var didWarn = false; 9015 9016function sanitizeURL(url) { 9017 { 9018 if (!didWarn && isJavaScriptProtocol.test(url)) { 9019 didWarn = true; 9020 9021 error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); 9022 } 9023 } 9024} 9025 9026/** 9027 * Get the value for a property on a node. Only used in DEV for SSR validation. 9028 * The "expected" argument is used as a hint of what the expected value is. 9029 * Some properties have multiple equivalent values. 9030 */ 9031function getValueForProperty(node, name, expected, propertyInfo) { 9032 { 9033 if (propertyInfo.mustUseProperty) { 9034 var propertyName = propertyInfo.propertyName; 9035 return node[propertyName]; 9036 } else { 9037 if ( propertyInfo.sanitizeURL) { 9038 // If we haven't fully disabled javascript: URLs, and if 9039 // the hydration is successful of a javascript: URL, we 9040 // still want to warn on the client. 9041 sanitizeURL('' + expected); 9042 } 9043 9044 var attributeName = propertyInfo.attributeName; 9045 var stringValue = null; 9046 9047 if (propertyInfo.type === OVERLOADED_BOOLEAN) { 9048 if (node.hasAttribute(attributeName)) { 9049 var value = node.getAttribute(attributeName); 9050 9051 if (value === '') { 9052 return true; 9053 } 9054 9055 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 9056 return value; 9057 } 9058 9059 if (value === '' + expected) { 9060 return expected; 9061 } 9062 9063 return value; 9064 } 9065 } else if (node.hasAttribute(attributeName)) { 9066 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 9067 // We had an attribute but shouldn't have had one, so read it 9068 // for the error message. 9069 return node.getAttribute(attributeName); 9070 } 9071 9072 if (propertyInfo.type === BOOLEAN) { 9073 // If this was a boolean, it doesn't matter what the value is 9074 // the fact that we have it is the same as the expected. 9075 return expected; 9076 } // Even if this property uses a namespace we use getAttribute 9077 // because we assume its namespaced name is the same as our config. 9078 // To use getAttributeNS we need the local name which we don't have 9079 // in our config atm. 9080 9081 9082 stringValue = node.getAttribute(attributeName); 9083 } 9084 9085 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 9086 return stringValue === null ? expected : stringValue; 9087 } else if (stringValue === '' + expected) { 9088 return expected; 9089 } else { 9090 return stringValue; 9091 } 9092 } 9093 } 9094} 9095/** 9096 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 9097 * The third argument is used as a hint of what the expected value is. Some 9098 * attributes have multiple equivalent values. 9099 */ 9100 9101function getValueForAttribute(node, name, expected) { 9102 { 9103 if (!isAttributeNameSafe(name)) { 9104 return; 9105 } 9106 9107 if (!node.hasAttribute(name)) { 9108 return expected === undefined ? undefined : null; 9109 } 9110 9111 var value = node.getAttribute(name); 9112 9113 if (value === '' + expected) { 9114 return expected; 9115 } 9116 9117 return value; 9118 } 9119} 9120/** 9121 * Sets the value for a property on a node. 9122 * 9123 * @param {DOMElement} node 9124 * @param {string} name 9125 * @param {*} value 9126 */ 9127 9128function setValueForProperty(node, name, value, isCustomComponentTag) { 9129 var propertyInfo = getPropertyInfo(name); 9130 9131 if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { 9132 return; 9133 } 9134 9135 if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { 9136 value = null; 9137 } // If the prop isn't in the special list, treat it as a simple attribute. 9138 9139 9140 if (isCustomComponentTag || propertyInfo === null) { 9141 if (isAttributeNameSafe(name)) { 9142 var _attributeName = name; 9143 9144 if (value === null) { 9145 node.removeAttribute(_attributeName); 9146 } else { 9147 node.setAttribute(_attributeName, '' + value); 9148 } 9149 } 9150 9151 return; 9152 } 9153 9154 var mustUseProperty = propertyInfo.mustUseProperty; 9155 9156 if (mustUseProperty) { 9157 var propertyName = propertyInfo.propertyName; 9158 9159 if (value === null) { 9160 var type = propertyInfo.type; 9161 node[propertyName] = type === BOOLEAN ? false : ''; 9162 } else { 9163 // Contrary to `setAttribute`, object properties are properly 9164 // `toString`ed by IE8/9. 9165 node[propertyName] = value; 9166 } 9167 9168 return; 9169 } // The rest are treated as attributes with special cases. 9170 9171 9172 var attributeName = propertyInfo.attributeName, 9173 attributeNamespace = propertyInfo.attributeNamespace; 9174 9175 if (value === null) { 9176 node.removeAttribute(attributeName); 9177 } else { 9178 var _type = propertyInfo.type; 9179 var attributeValue; 9180 9181 if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { 9182 // If attribute type is boolean, we know for sure it won't be an execution sink 9183 // and we won't require Trusted Type here. 9184 attributeValue = ''; 9185 } else { 9186 // `setAttribute` with objects becomes only `[object]` in IE8/9, 9187 // ('' + value) makes it output the correct toString()-value. 9188 { 9189 attributeValue = '' + value; 9190 } 9191 9192 if (propertyInfo.sanitizeURL) { 9193 sanitizeURL(attributeValue.toString()); 9194 } 9195 } 9196 9197 if (attributeNamespace) { 9198 node.setAttributeNS(attributeNamespace, attributeName, attributeValue); 9199 } else { 9200 node.setAttribute(attributeName, attributeValue); 9201 } 9202 } 9203} 9204 9205var BEFORE_SLASH_RE = /^(.*)[\\\/]/; 9206function describeComponentFrame (name, source, ownerName) { 9207 var sourceInfo = ''; 9208 9209 if (source) { 9210 var path = source.fileName; 9211 var fileName = path.replace(BEFORE_SLASH_RE, ''); 9212 9213 { 9214 // In DEV, include code for a common special case: 9215 // prefer "folder/index.js" instead of just "index.js". 9216 if (/^index\./.test(fileName)) { 9217 var match = path.match(BEFORE_SLASH_RE); 9218 9219 if (match) { 9220 var pathBeforeSlash = match[1]; 9221 9222 if (pathBeforeSlash) { 9223 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); 9224 fileName = folderName + '/' + fileName; 9225 } 9226 } 9227 } 9228 } 9229 9230 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; 9231 } else if (ownerName) { 9232 sourceInfo = ' (created by ' + ownerName + ')'; 9233 } 9234 9235 return '\n in ' + (name || 'Unknown') + sourceInfo; 9236} 9237 9238// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 9239// nor polyfill, then a plain number is used for performance. 9240var hasSymbol = typeof Symbol === 'function' && Symbol.for; 9241var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 9242var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 9243var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 9244var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 9245var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 9246var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 9247var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary 9248var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; 9249var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 9250var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; 9251var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; 9252var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; 9253var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; 9254var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; 9255var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 9256var FAUX_ITERATOR_SYMBOL = '@@iterator'; 9257function getIteratorFn(maybeIterable) { 9258 if (maybeIterable === null || typeof maybeIterable !== 'object') { 9259 return null; 9260 } 9261 9262 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 9263 9264 if (typeof maybeIterator === 'function') { 9265 return maybeIterator; 9266 } 9267 9268 return null; 9269} 9270 9271var Uninitialized = -1; 9272var Pending = 0; 9273var Resolved = 1; 9274var Rejected = 2; 9275function refineResolvedLazyComponent(lazyComponent) { 9276 return lazyComponent._status === Resolved ? lazyComponent._result : null; 9277} 9278function initializeLazyComponentType(lazyComponent) { 9279 if (lazyComponent._status === Uninitialized) { 9280 lazyComponent._status = Pending; 9281 var ctor = lazyComponent._ctor; 9282 var thenable = ctor(); 9283 lazyComponent._result = thenable; 9284 thenable.then(function (moduleObject) { 9285 if (lazyComponent._status === Pending) { 9286 var defaultExport = moduleObject.default; 9287 9288 { 9289 if (defaultExport === undefined) { 9290 error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); 9291 } 9292 } 9293 9294 lazyComponent._status = Resolved; 9295 lazyComponent._result = defaultExport; 9296 } 9297 }, function (error) { 9298 if (lazyComponent._status === Pending) { 9299 lazyComponent._status = Rejected; 9300 lazyComponent._result = error; 9301 } 9302 }); 9303 } 9304} 9305 9306function getWrappedName(outerType, innerType, wrapperName) { 9307 var functionName = innerType.displayName || innerType.name || ''; 9308 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 9309} 9310 9311function getComponentName(type) { 9312 if (type == null) { 9313 // Host root, text node or just invalid type. 9314 return null; 9315 } 9316 9317 { 9318 if (typeof type.tag === 'number') { 9319 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 9320 } 9321 } 9322 9323 if (typeof type === 'function') { 9324 return type.displayName || type.name || null; 9325 } 9326 9327 if (typeof type === 'string') { 9328 return type; 9329 } 9330 9331 switch (type) { 9332 case REACT_FRAGMENT_TYPE: 9333 return 'Fragment'; 9334 9335 case REACT_PORTAL_TYPE: 9336 return 'Portal'; 9337 9338 case REACT_PROFILER_TYPE: 9339 return "Profiler"; 9340 9341 case REACT_STRICT_MODE_TYPE: 9342 return 'StrictMode'; 9343 9344 case REACT_SUSPENSE_TYPE: 9345 return 'Suspense'; 9346 9347 case REACT_SUSPENSE_LIST_TYPE: 9348 return 'SuspenseList'; 9349 } 9350 9351 if (typeof type === 'object') { 9352 switch (type.$$typeof) { 9353 case REACT_CONTEXT_TYPE: 9354 return 'Context.Consumer'; 9355 9356 case REACT_PROVIDER_TYPE: 9357 return 'Context.Provider'; 9358 9359 case REACT_FORWARD_REF_TYPE: 9360 return getWrappedName(type, type.render, 'ForwardRef'); 9361 9362 case REACT_MEMO_TYPE: 9363 return getComponentName(type.type); 9364 9365 case REACT_BLOCK_TYPE: 9366 return getComponentName(type.render); 9367 9368 case REACT_LAZY_TYPE: 9369 { 9370 var thenable = type; 9371 var resolvedThenable = refineResolvedLazyComponent(thenable); 9372 9373 if (resolvedThenable) { 9374 return getComponentName(resolvedThenable); 9375 } 9376 9377 break; 9378 } 9379 } 9380 } 9381 9382 return null; 9383} 9384 9385var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 9386 9387function describeFiber(fiber) { 9388 switch (fiber.tag) { 9389 case HostRoot: 9390 case HostPortal: 9391 case HostText: 9392 case Fragment: 9393 case ContextProvider: 9394 case ContextConsumer: 9395 return ''; 9396 9397 default: 9398 var owner = fiber._debugOwner; 9399 var source = fiber._debugSource; 9400 var name = getComponentName(fiber.type); 9401 var ownerName = null; 9402 9403 if (owner) { 9404 ownerName = getComponentName(owner.type); 9405 } 9406 9407 return describeComponentFrame(name, source, ownerName); 9408 } 9409} 9410 9411function getStackByFiberInDevAndProd(workInProgress) { 9412 var info = ''; 9413 var node = workInProgress; 9414 9415 do { 9416 info += describeFiber(node); 9417 node = node.return; 9418 } while (node); 9419 9420 return info; 9421} 9422var current = null; 9423var isRendering = false; 9424function getCurrentFiberOwnerNameInDevOrNull() { 9425 { 9426 if (current === null) { 9427 return null; 9428 } 9429 9430 var owner = current._debugOwner; 9431 9432 if (owner !== null && typeof owner !== 'undefined') { 9433 return getComponentName(owner.type); 9434 } 9435 } 9436 9437 return null; 9438} 9439function getCurrentFiberStackInDev() { 9440 { 9441 if (current === null) { 9442 return ''; 9443 } // Safe because if current fiber exists, we are reconciling, 9444 // and it is guaranteed to be the work-in-progress version. 9445 9446 9447 return getStackByFiberInDevAndProd(current); 9448 } 9449} 9450function resetCurrentFiber() { 9451 { 9452 ReactDebugCurrentFrame$1.getCurrentStack = null; 9453 current = null; 9454 isRendering = false; 9455 } 9456} 9457function setCurrentFiber(fiber) { 9458 { 9459 ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; 9460 current = fiber; 9461 isRendering = false; 9462 } 9463} 9464function setIsRendering(rendering) { 9465 { 9466 isRendering = rendering; 9467 } 9468} 9469 9470// Flow does not allow string concatenation of most non-string types. To work 9471// around this limitation, we use an opaque type that can only be obtained by 9472// passing the value through getToStringValue first. 9473function toString(value) { 9474 return '' + value; 9475} 9476function getToStringValue(value) { 9477 switch (typeof value) { 9478 case 'boolean': 9479 case 'number': 9480 case 'object': 9481 case 'string': 9482 case 'undefined': 9483 return value; 9484 9485 default: 9486 // function, symbol are assigned as empty strings 9487 return ''; 9488 } 9489} 9490 9491var ReactDebugCurrentFrame$2 = null; 9492var ReactControlledValuePropTypes = { 9493 checkPropTypes: null 9494}; 9495 9496{ 9497 ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; 9498 var hasReadOnlyValue = { 9499 button: true, 9500 checkbox: true, 9501 image: true, 9502 hidden: true, 9503 radio: true, 9504 reset: true, 9505 submit: true 9506 }; 9507 var propTypes = { 9508 value: function (props, propName, componentName) { 9509 if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { 9510 return null; 9511 } 9512 9513 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`.'); 9514 }, 9515 checked: function (props, propName, componentName) { 9516 if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { 9517 return null; 9518 } 9519 9520 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`.'); 9521 } 9522 }; 9523 /** 9524 * Provide a linked `value` attribute for controlled forms. You should not use 9525 * this outside of the ReactDOM controlled form components. 9526 */ 9527 9528 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { 9529 checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); 9530 }; 9531} 9532 9533function isCheckable(elem) { 9534 var type = elem.type; 9535 var nodeName = elem.nodeName; 9536 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 9537} 9538 9539function getTracker(node) { 9540 return node._valueTracker; 9541} 9542 9543function detachTracker(node) { 9544 node._valueTracker = null; 9545} 9546 9547function getValueFromNode(node) { 9548 var value = ''; 9549 9550 if (!node) { 9551 return value; 9552 } 9553 9554 if (isCheckable(node)) { 9555 value = node.checked ? 'true' : 'false'; 9556 } else { 9557 value = node.value; 9558 } 9559 9560 return value; 9561} 9562 9563function trackValueOnNode(node) { 9564 var valueField = isCheckable(node) ? 'checked' : 'value'; 9565 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 9566 var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail 9567 // and don't track value will cause over reporting of changes, 9568 // but it's better then a hard failure 9569 // (needed for certain tests that spyOn input values and Safari) 9570 9571 if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 9572 return; 9573 } 9574 9575 var get = descriptor.get, 9576 set = descriptor.set; 9577 Object.defineProperty(node, valueField, { 9578 configurable: true, 9579 get: function () { 9580 return get.call(this); 9581 }, 9582 set: function (value) { 9583 currentValue = '' + value; 9584 set.call(this, value); 9585 } 9586 }); // We could've passed this the first time 9587 // but it triggers a bug in IE11 and Edge 14/15. 9588 // Calling defineProperty() again should be equivalent. 9589 // https://github.com/facebook/react/issues/11768 9590 9591 Object.defineProperty(node, valueField, { 9592 enumerable: descriptor.enumerable 9593 }); 9594 var tracker = { 9595 getValue: function () { 9596 return currentValue; 9597 }, 9598 setValue: function (value) { 9599 currentValue = '' + value; 9600 }, 9601 stopTracking: function () { 9602 detachTracker(node); 9603 delete node[valueField]; 9604 } 9605 }; 9606 return tracker; 9607} 9608 9609function track(node) { 9610 if (getTracker(node)) { 9611 return; 9612 } // TODO: Once it's just Fiber we can move this to node._wrapperState 9613 9614 9615 node._valueTracker = trackValueOnNode(node); 9616} 9617function updateValueIfChanged(node) { 9618 if (!node) { 9619 return false; 9620 } 9621 9622 var tracker = getTracker(node); // if there is no tracker at this point it's unlikely 9623 // that trying again will succeed 9624 9625 if (!tracker) { 9626 return true; 9627 } 9628 9629 var lastValue = tracker.getValue(); 9630 var nextValue = getValueFromNode(node); 9631 9632 if (nextValue !== lastValue) { 9633 tracker.setValue(nextValue); 9634 return true; 9635 } 9636 9637 return false; 9638} 9639 9640var didWarnValueDefaultValue = false; 9641var didWarnCheckedDefaultChecked = false; 9642var didWarnControlledToUncontrolled = false; 9643var didWarnUncontrolledToControlled = false; 9644 9645function isControlled(props) { 9646 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 9647 return usesChecked ? props.checked != null : props.value != null; 9648} 9649/** 9650 * Implements an <input> host component that allows setting these optional 9651 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 9652 * 9653 * If `checked` or `value` are not supplied (or null/undefined), user actions 9654 * that affect the checked state or value will trigger updates to the element. 9655 * 9656 * If they are supplied (and not null/undefined), the rendered element will not 9657 * trigger updates to the element. Instead, the props must change in order for 9658 * the rendered element to be updated. 9659 * 9660 * The rendered element will be initialized as unchecked (or `defaultChecked`) 9661 * with an empty value (or `defaultValue`). 9662 * 9663 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 9664 */ 9665 9666 9667function getHostProps(element, props) { 9668 var node = element; 9669 var checked = props.checked; 9670 9671 var hostProps = _assign({}, props, { 9672 defaultChecked: undefined, 9673 defaultValue: undefined, 9674 value: undefined, 9675 checked: checked != null ? checked : node._wrapperState.initialChecked 9676 }); 9677 9678 return hostProps; 9679} 9680function initWrapperState(element, props) { 9681 { 9682 ReactControlledValuePropTypes.checkPropTypes('input', props); 9683 9684 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 9685 error('%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', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 9686 9687 didWarnCheckedDefaultChecked = true; 9688 } 9689 9690 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 9691 error('%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', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 9692 9693 didWarnValueDefaultValue = true; 9694 } 9695 } 9696 9697 var node = element; 9698 var defaultValue = props.defaultValue == null ? '' : props.defaultValue; 9699 node._wrapperState = { 9700 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 9701 initialValue: getToStringValue(props.value != null ? props.value : defaultValue), 9702 controlled: isControlled(props) 9703 }; 9704} 9705function updateChecked(element, props) { 9706 var node = element; 9707 var checked = props.checked; 9708 9709 if (checked != null) { 9710 setValueForProperty(node, 'checked', checked, false); 9711 } 9712} 9713function updateWrapper(element, props) { 9714 var node = element; 9715 9716 { 9717 var controlled = isControlled(props); 9718 9719 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { 9720 error('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', props.type); 9721 9722 didWarnUncontrolledToControlled = true; 9723 } 9724 9725 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { 9726 error('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', props.type); 9727 9728 didWarnControlledToUncontrolled = true; 9729 } 9730 } 9731 9732 updateChecked(element, props); 9733 var value = getToStringValue(props.value); 9734 var type = props.type; 9735 9736 if (value != null) { 9737 if (type === 'number') { 9738 if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. 9739 // eslint-disable-next-line 9740 node.value != value) { 9741 node.value = toString(value); 9742 } 9743 } else if (node.value !== toString(value)) { 9744 node.value = toString(value); 9745 } 9746 } else if (type === 'submit' || type === 'reset') { 9747 // Submit/reset inputs need the attribute removed completely to avoid 9748 // blank-text buttons. 9749 node.removeAttribute('value'); 9750 return; 9751 } 9752 9753 { 9754 // When syncing the value attribute, the value comes from a cascade of 9755 // properties: 9756 // 1. The value React property 9757 // 2. The defaultValue React property 9758 // 3. Otherwise there should be no change 9759 if (props.hasOwnProperty('value')) { 9760 setDefaultValue(node, props.type, value); 9761 } else if (props.hasOwnProperty('defaultValue')) { 9762 setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); 9763 } 9764 } 9765 9766 { 9767 // When syncing the checked attribute, it only changes when it needs 9768 // to be removed, such as transitioning from a checkbox into a text input 9769 if (props.checked == null && props.defaultChecked != null) { 9770 node.defaultChecked = !!props.defaultChecked; 9771 } 9772 } 9773} 9774function postMountWrapper(element, props, isHydrating) { 9775 var node = element; // Do not assign value if it is already set. This prevents user text input 9776 // from being lost during SSR hydration. 9777 9778 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { 9779 var type = props.type; 9780 var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the 9781 // default value provided by the browser. See: #12872 9782 9783 if (isButton && (props.value === undefined || props.value === null)) { 9784 return; 9785 } 9786 9787 var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input 9788 // from being lost during SSR hydration. 9789 9790 if (!isHydrating) { 9791 { 9792 // When syncing the value attribute, the value property should use 9793 // the wrapperState._initialValue property. This uses: 9794 // 9795 // 1. The value React property when present 9796 // 2. The defaultValue React property when present 9797 // 3. An empty string 9798 if (initialValue !== node.value) { 9799 node.value = initialValue; 9800 } 9801 } 9802 } 9803 9804 { 9805 // Otherwise, the value attribute is synchronized to the property, 9806 // so we assign defaultValue to the same thing as the value property 9807 // assignment step above. 9808 node.defaultValue = initialValue; 9809 } 9810 } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 9811 // this is needed to work around a chrome bug where setting defaultChecked 9812 // will sometimes influence the value of checked (even after detachment). 9813 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 9814 // We need to temporarily unset name to avoid disrupting radio button groups. 9815 9816 9817 var name = node.name; 9818 9819 if (name !== '') { 9820 node.name = ''; 9821 } 9822 9823 { 9824 // When syncing the checked attribute, both the checked property and 9825 // attribute are assigned at the same time using defaultChecked. This uses: 9826 // 9827 // 1. The checked React property when present 9828 // 2. The defaultChecked React property when present 9829 // 3. Otherwise, false 9830 node.defaultChecked = !node.defaultChecked; 9831 node.defaultChecked = !!node._wrapperState.initialChecked; 9832 } 9833 9834 if (name !== '') { 9835 node.name = name; 9836 } 9837} 9838function restoreControlledState(element, props) { 9839 var node = element; 9840 updateWrapper(node, props); 9841 updateNamedCousins(node, props); 9842} 9843 9844function updateNamedCousins(rootNode, props) { 9845 var name = props.name; 9846 9847 if (props.type === 'radio' && name != null) { 9848 var queryRoot = rootNode; 9849 9850 while (queryRoot.parentNode) { 9851 queryRoot = queryRoot.parentNode; 9852 } // If `rootNode.form` was non-null, then we could try `form.elements`, 9853 // but that sometimes behaves strangely in IE8. We could also try using 9854 // `form.getElementsByName`, but that will only return direct children 9855 // and won't include inputs that use the HTML5 `form=` attribute. Since 9856 // the input might not even be in a form. It might not even be in the 9857 // document. Let's just use the local `querySelectorAll` to ensure we don't 9858 // miss anything. 9859 9860 9861 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 9862 9863 for (var i = 0; i < group.length; i++) { 9864 var otherNode = group[i]; 9865 9866 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 9867 continue; 9868 } // This will throw if radio buttons rendered by different copies of React 9869 // and the same name are rendered into the same form (same as #1939). 9870 // That's probably okay; we don't support it just as we don't support 9871 // mixing React radio buttons with non-React ones. 9872 9873 9874 var otherProps = getFiberCurrentPropsFromNode$1(otherNode); 9875 9876 if (!otherProps) { 9877 { 9878 throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); 9879 } 9880 } // We need update the tracked value on the named cousin since the value 9881 // was changed but the input saw no event or value set 9882 9883 9884 updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that 9885 // was previously checked to update will cause it to be come re-checked 9886 // as appropriate. 9887 9888 updateWrapper(otherNode, otherProps); 9889 } 9890 } 9891} // In Chrome, assigning defaultValue to certain input types triggers input validation. 9892// For number inputs, the display value loses trailing decimal points. For email inputs, 9893// Chrome raises "The specified value <x> is not a valid email address". 9894// 9895// Here we check to see if the defaultValue has actually changed, avoiding these problems 9896// when the user is inputting text 9897// 9898// https://github.com/facebook/react/issues/7253 9899 9900 9901function setDefaultValue(node, type, value) { 9902 if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js 9903 type !== 'number' || node.ownerDocument.activeElement !== node) { 9904 if (value == null) { 9905 node.defaultValue = toString(node._wrapperState.initialValue); 9906 } else if (node.defaultValue !== toString(value)) { 9907 node.defaultValue = toString(value); 9908 } 9909 } 9910} 9911 9912var didWarnSelectedSetOnOption = false; 9913var didWarnInvalidChild = false; 9914 9915function flattenChildren(children) { 9916 var content = ''; // Flatten children. We'll warn if they are invalid 9917 // during validateProps() which runs for hydration too. 9918 // Note that this would throw on non-element objects. 9919 // Elements are stringified (which is normally irrelevant 9920 // but matters for <fbt>). 9921 9922 React.Children.forEach(children, function (child) { 9923 if (child == null) { 9924 return; 9925 } 9926 9927 content += child; // Note: we don't warn about invalid children here. 9928 // Instead, this is done separately below so that 9929 // it happens during the hydration codepath too. 9930 }); 9931 return content; 9932} 9933/** 9934 * Implements an <option> host component that warns when `selected` is set. 9935 */ 9936 9937 9938function validateProps(element, props) { 9939 { 9940 // This mirrors the codepath above, but runs for hydration too. 9941 // Warn about invalid children here so that client and hydration are consistent. 9942 // TODO: this seems like it could cause a DEV-only throw for hydration 9943 // if children contains a non-element object. We should try to avoid that. 9944 if (typeof props.children === 'object' && props.children !== null) { 9945 React.Children.forEach(props.children, function (child) { 9946 if (child == null) { 9947 return; 9948 } 9949 9950 if (typeof child === 'string' || typeof child === 'number') { 9951 return; 9952 } 9953 9954 if (typeof child.type !== 'string') { 9955 return; 9956 } 9957 9958 if (!didWarnInvalidChild) { 9959 didWarnInvalidChild = true; 9960 9961 error('Only strings and numbers are supported as <option> children.'); 9962 } 9963 }); 9964 } // TODO: Remove support for `selected` in <option>. 9965 9966 9967 if (props.selected != null && !didWarnSelectedSetOnOption) { 9968 error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 9969 9970 didWarnSelectedSetOnOption = true; 9971 } 9972 } 9973} 9974function postMountWrapper$1(element, props) { 9975 // value="" should make a value attribute (#6219) 9976 if (props.value != null) { 9977 element.setAttribute('value', toString(getToStringValue(props.value))); 9978 } 9979} 9980function getHostProps$1(element, props) { 9981 var hostProps = _assign({ 9982 children: undefined 9983 }, props); 9984 9985 var content = flattenChildren(props.children); 9986 9987 if (content) { 9988 hostProps.children = content; 9989 } 9990 9991 return hostProps; 9992} 9993 9994var didWarnValueDefaultValue$1; 9995 9996{ 9997 didWarnValueDefaultValue$1 = false; 9998} 9999 10000function getDeclarationErrorAddendum() { 10001 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 10002 10003 if (ownerName) { 10004 return '\n\nCheck the render method of `' + ownerName + '`.'; 10005 } 10006 10007 return ''; 10008} 10009 10010var valuePropNames = ['value', 'defaultValue']; 10011/** 10012 * Validation function for `value` and `defaultValue`. 10013 */ 10014 10015function checkSelectPropTypes(props) { 10016 { 10017 ReactControlledValuePropTypes.checkPropTypes('select', props); 10018 10019 for (var i = 0; i < valuePropNames.length; i++) { 10020 var propName = valuePropNames[i]; 10021 10022 if (props[propName] == null) { 10023 continue; 10024 } 10025 10026 var isArray = Array.isArray(props[propName]); 10027 10028 if (props.multiple && !isArray) { 10029 error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 10030 } else if (!props.multiple && isArray) { 10031 error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 10032 } 10033 } 10034 } 10035} 10036 10037function updateOptions(node, multiple, propValue, setDefaultSelected) { 10038 var options = node.options; 10039 10040 if (multiple) { 10041 var selectedValues = propValue; 10042 var selectedValue = {}; 10043 10044 for (var i = 0; i < selectedValues.length; i++) { 10045 // Prefix to avoid chaos with special keys. 10046 selectedValue['$' + selectedValues[i]] = true; 10047 } 10048 10049 for (var _i = 0; _i < options.length; _i++) { 10050 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 10051 10052 if (options[_i].selected !== selected) { 10053 options[_i].selected = selected; 10054 } 10055 10056 if (selected && setDefaultSelected) { 10057 options[_i].defaultSelected = true; 10058 } 10059 } 10060 } else { 10061 // Do not set `select.value` as exact behavior isn't consistent across all 10062 // browsers for all cases. 10063 var _selectedValue = toString(getToStringValue(propValue)); 10064 10065 var defaultSelected = null; 10066 10067 for (var _i2 = 0; _i2 < options.length; _i2++) { 10068 if (options[_i2].value === _selectedValue) { 10069 options[_i2].selected = true; 10070 10071 if (setDefaultSelected) { 10072 options[_i2].defaultSelected = true; 10073 } 10074 10075 return; 10076 } 10077 10078 if (defaultSelected === null && !options[_i2].disabled) { 10079 defaultSelected = options[_i2]; 10080 } 10081 } 10082 10083 if (defaultSelected !== null) { 10084 defaultSelected.selected = true; 10085 } 10086 } 10087} 10088/** 10089 * Implements a <select> host component that allows optionally setting the 10090 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 10091 * stringable. If `multiple` is true, the prop must be an array of stringables. 10092 * 10093 * If `value` is not supplied (or null/undefined), user actions that change the 10094 * selected option will trigger updates to the rendered options. 10095 * 10096 * If it is supplied (and not null/undefined), the rendered options will not 10097 * update in response to user actions. Instead, the `value` prop must change in 10098 * order for the rendered options to update. 10099 * 10100 * If `defaultValue` is provided, any options with the supplied values will be 10101 * selected. 10102 */ 10103 10104 10105function getHostProps$2(element, props) { 10106 return _assign({}, props, { 10107 value: undefined 10108 }); 10109} 10110function initWrapperState$1(element, props) { 10111 var node = element; 10112 10113 { 10114 checkSelectPropTypes(props); 10115 } 10116 10117 node._wrapperState = { 10118 wasMultiple: !!props.multiple 10119 }; 10120 10121 { 10122 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 10123 error('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'); 10124 10125 didWarnValueDefaultValue$1 = true; 10126 } 10127 } 10128} 10129function postMountWrapper$2(element, props) { 10130 var node = element; 10131 node.multiple = !!props.multiple; 10132 var value = props.value; 10133 10134 if (value != null) { 10135 updateOptions(node, !!props.multiple, value, false); 10136 } else if (props.defaultValue != null) { 10137 updateOptions(node, !!props.multiple, props.defaultValue, true); 10138 } 10139} 10140function postUpdateWrapper(element, props) { 10141 var node = element; 10142 var wasMultiple = node._wrapperState.wasMultiple; 10143 node._wrapperState.wasMultiple = !!props.multiple; 10144 var value = props.value; 10145 10146 if (value != null) { 10147 updateOptions(node, !!props.multiple, value, false); 10148 } else if (wasMultiple !== !!props.multiple) { 10149 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 10150 if (props.defaultValue != null) { 10151 updateOptions(node, !!props.multiple, props.defaultValue, true); 10152 } else { 10153 // Revert the select back to its default unselected state. 10154 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 10155 } 10156 } 10157} 10158function restoreControlledState$1(element, props) { 10159 var node = element; 10160 var value = props.value; 10161 10162 if (value != null) { 10163 updateOptions(node, !!props.multiple, value, false); 10164 } 10165} 10166 10167var didWarnValDefaultVal = false; 10168 10169/** 10170 * Implements a <textarea> host component that allows setting `value`, and 10171 * `defaultValue`. This differs from the traditional DOM API because value is 10172 * usually set as PCDATA children. 10173 * 10174 * If `value` is not supplied (or null/undefined), user actions that affect the 10175 * value will trigger updates to the element. 10176 * 10177 * If `value` is supplied (and not null/undefined), the rendered element will 10178 * not trigger updates to the element. Instead, the `value` prop must change in 10179 * order for the rendered element to be updated. 10180 * 10181 * The rendered element will be initialized with an empty value, the prop 10182 * `defaultValue` if specified, or the children content (deprecated). 10183 */ 10184function getHostProps$3(element, props) { 10185 var node = element; 10186 10187 if (!(props.dangerouslySetInnerHTML == null)) { 10188 { 10189 throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); 10190 } 10191 } // Always set children to the same thing. In IE9, the selection range will 10192 // get reset if `textContent` is mutated. We could add a check in setTextContent 10193 // to only set the value if/when the value differs from the node value (which would 10194 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 10195 // solution. The value can be a boolean or object so that's why it's forced 10196 // to be a string. 10197 10198 10199 var hostProps = _assign({}, props, { 10200 value: undefined, 10201 defaultValue: undefined, 10202 children: toString(node._wrapperState.initialValue) 10203 }); 10204 10205 return hostProps; 10206} 10207function initWrapperState$2(element, props) { 10208 var node = element; 10209 10210 { 10211 ReactControlledValuePropTypes.checkPropTypes('textarea', props); 10212 10213 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 10214 error('%s contains a textarea with both value and defaultValue props. ' + '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', getCurrentFiberOwnerNameInDevOrNull() || 'A component'); 10215 10216 didWarnValDefaultVal = true; 10217 } 10218 } 10219 10220 var initialValue = props.value; // Only bother fetching default value if we're going to use it 10221 10222 if (initialValue == null) { 10223 var children = props.children, 10224 defaultValue = props.defaultValue; 10225 10226 if (children != null) { 10227 { 10228 error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 10229 } 10230 10231 { 10232 if (!(defaultValue == null)) { 10233 { 10234 throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); 10235 } 10236 } 10237 10238 if (Array.isArray(children)) { 10239 if (!(children.length <= 1)) { 10240 { 10241 throw Error( "<textarea> can only have at most one child." ); 10242 } 10243 } 10244 10245 children = children[0]; 10246 } 10247 10248 defaultValue = children; 10249 } 10250 } 10251 10252 if (defaultValue == null) { 10253 defaultValue = ''; 10254 } 10255 10256 initialValue = defaultValue; 10257 } 10258 10259 node._wrapperState = { 10260 initialValue: getToStringValue(initialValue) 10261 }; 10262} 10263function updateWrapper$1(element, props) { 10264 var node = element; 10265 var value = getToStringValue(props.value); 10266 var defaultValue = getToStringValue(props.defaultValue); 10267 10268 if (value != null) { 10269 // Cast `value` to a string to ensure the value is set correctly. While 10270 // browsers typically do this as necessary, jsdom doesn't. 10271 var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed 10272 10273 if (newValue !== node.value) { 10274 node.value = newValue; 10275 } 10276 10277 if (props.defaultValue == null && node.defaultValue !== newValue) { 10278 node.defaultValue = newValue; 10279 } 10280 } 10281 10282 if (defaultValue != null) { 10283 node.defaultValue = toString(defaultValue); 10284 } 10285} 10286function postMountWrapper$3(element, props) { 10287 var node = element; // This is in postMount because we need access to the DOM node, which is not 10288 // available until after the component has mounted. 10289 10290 var textContent = node.textContent; // Only set node.value if textContent is equal to the expected 10291 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 10292 // will populate textContent as well. 10293 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 10294 10295 if (textContent === node._wrapperState.initialValue) { 10296 if (textContent !== '' && textContent !== null) { 10297 node.value = textContent; 10298 } 10299 } 10300} 10301function restoreControlledState$2(element, props) { 10302 // DOM component is still mounted; update 10303 updateWrapper$1(element, props); 10304} 10305 10306var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 10307var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 10308var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 10309var Namespaces = { 10310 html: HTML_NAMESPACE, 10311 mathml: MATH_NAMESPACE, 10312 svg: SVG_NAMESPACE 10313}; // Assumes there is no parent namespace. 10314 10315function getIntrinsicNamespace(type) { 10316 switch (type) { 10317 case 'svg': 10318 return SVG_NAMESPACE; 10319 10320 case 'math': 10321 return MATH_NAMESPACE; 10322 10323 default: 10324 return HTML_NAMESPACE; 10325 } 10326} 10327function getChildNamespace(parentNamespace, type) { 10328 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { 10329 // No (or default) parent namespace: potential entry point. 10330 return getIntrinsicNamespace(type); 10331 } 10332 10333 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 10334 // We're leaving SVG. 10335 return HTML_NAMESPACE; 10336 } // By default, pass namespace below. 10337 10338 10339 return parentNamespace; 10340} 10341 10342/* globals MSApp */ 10343 10344/** 10345 * Create a function which has 'unsafe' privileges (required by windows8 apps) 10346 */ 10347var createMicrosoftUnsafeLocalFunction = function (func) { 10348 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 10349 return function (arg0, arg1, arg2, arg3) { 10350 MSApp.execUnsafeLocalFunction(function () { 10351 return func(arg0, arg1, arg2, arg3); 10352 }); 10353 }; 10354 } else { 10355 return func; 10356 } 10357}; 10358 10359var reusableSVGContainer; 10360/** 10361 * Set the innerHTML property of a node 10362 * 10363 * @param {DOMElement} node 10364 * @param {string} html 10365 * @internal 10366 */ 10367 10368var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 10369 if (node.namespaceURI === Namespaces.svg) { 10370 10371 if (!('innerHTML' in node)) { 10372 // IE does not have innerHTML for SVG nodes, so instead we inject the 10373 // new markup in a temp node and then move the child nodes across into 10374 // the target node 10375 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 10376 reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; 10377 var svgNode = reusableSVGContainer.firstChild; 10378 10379 while (node.firstChild) { 10380 node.removeChild(node.firstChild); 10381 } 10382 10383 while (svgNode.firstChild) { 10384 node.appendChild(svgNode.firstChild); 10385 } 10386 10387 return; 10388 } 10389 } 10390 10391 node.innerHTML = html; 10392}); 10393 10394/** 10395 * HTML nodeType values that represent the type of the node 10396 */ 10397var ELEMENT_NODE = 1; 10398var TEXT_NODE = 3; 10399var COMMENT_NODE = 8; 10400var DOCUMENT_NODE = 9; 10401var DOCUMENT_FRAGMENT_NODE = 11; 10402 10403/** 10404 * Set the textContent property of a node. For text updates, it's faster 10405 * to set the `nodeValue` of the Text node directly instead of using 10406 * `.textContent` which will remove the existing node and create a new one. 10407 * 10408 * @param {DOMElement} node 10409 * @param {string} text 10410 * @internal 10411 */ 10412 10413var setTextContent = function (node, text) { 10414 if (text) { 10415 var firstChild = node.firstChild; 10416 10417 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 10418 firstChild.nodeValue = text; 10419 return; 10420 } 10421 } 10422 10423 node.textContent = text; 10424}; 10425 10426// Do not use the below two methods directly! 10427// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM. 10428// (It is the only module that is allowed to access these methods.) 10429function unsafeCastStringToDOMTopLevelType(topLevelType) { 10430 return topLevelType; 10431} 10432function unsafeCastDOMTopLevelTypeToString(topLevelType) { 10433 return topLevelType; 10434} 10435 10436/** 10437 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 10438 * 10439 * @param {string} styleProp 10440 * @param {string} eventName 10441 * @returns {object} 10442 */ 10443 10444function makePrefixMap(styleProp, eventName) { 10445 var prefixes = {}; 10446 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 10447 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 10448 prefixes['Moz' + styleProp] = 'moz' + eventName; 10449 return prefixes; 10450} 10451/** 10452 * A list of event names to a configurable list of vendor prefixes. 10453 */ 10454 10455 10456var vendorPrefixes = { 10457 animationend: makePrefixMap('Animation', 'AnimationEnd'), 10458 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 10459 animationstart: makePrefixMap('Animation', 'AnimationStart'), 10460 transitionend: makePrefixMap('Transition', 'TransitionEnd') 10461}; 10462/** 10463 * Event names that have already been detected and prefixed (if applicable). 10464 */ 10465 10466var prefixedEventNames = {}; 10467/** 10468 * Element to check for prefixes on. 10469 */ 10470 10471var style = {}; 10472/** 10473 * Bootstrap if a DOM exists. 10474 */ 10475 10476if (canUseDOM) { 10477 style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, 10478 // the un-prefixed "animation" and "transition" properties are defined on the 10479 // style object but the events that fire will still be prefixed, so we need 10480 // to check if the un-prefixed events are usable, and if not remove them from the map. 10481 10482 if (!('AnimationEvent' in window)) { 10483 delete vendorPrefixes.animationend.animation; 10484 delete vendorPrefixes.animationiteration.animation; 10485 delete vendorPrefixes.animationstart.animation; 10486 } // Same as above 10487 10488 10489 if (!('TransitionEvent' in window)) { 10490 delete vendorPrefixes.transitionend.transition; 10491 } 10492} 10493/** 10494 * Attempts to determine the correct vendor prefixed event name. 10495 * 10496 * @param {string} eventName 10497 * @returns {string} 10498 */ 10499 10500 10501function getVendorPrefixedEventName(eventName) { 10502 if (prefixedEventNames[eventName]) { 10503 return prefixedEventNames[eventName]; 10504 } else if (!vendorPrefixes[eventName]) { 10505 return eventName; 10506 } 10507 10508 var prefixMap = vendorPrefixes[eventName]; 10509 10510 for (var styleProp in prefixMap) { 10511 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 10512 return prefixedEventNames[eventName] = prefixMap[styleProp]; 10513 } 10514 } 10515 10516 return eventName; 10517} 10518 10519/** 10520 * To identify top level events in ReactDOM, we use constants defined by this 10521 * module. This is the only module that uses the unsafe* methods to express 10522 * that the constants actually correspond to the browser event names. This lets 10523 * us save some bundle size by avoiding a top level type -> event name map. 10524 * The rest of ReactDOM code should import top level types from this file. 10525 */ 10526 10527var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort'); 10528var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend')); 10529var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration')); 10530var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart')); 10531var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur'); 10532var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay'); 10533var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough'); 10534var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel'); 10535var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change'); 10536var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click'); 10537var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close'); 10538var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend'); 10539var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart'); 10540var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate'); 10541var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu'); 10542var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy'); 10543var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut'); 10544var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick'); 10545var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick'); 10546var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag'); 10547var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend'); 10548var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter'); 10549var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit'); 10550var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave'); 10551var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover'); 10552var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart'); 10553var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop'); 10554var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange'); 10555var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied'); 10556var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted'); 10557var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended'); 10558var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error'); 10559var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus'); 10560var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture'); 10561var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input'); 10562var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid'); 10563var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown'); 10564var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress'); 10565var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup'); 10566var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load'); 10567var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart'); 10568var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata'); 10569var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata'); 10570var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture'); 10571var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown'); 10572var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove'); 10573var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout'); 10574var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover'); 10575var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup'); 10576var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste'); 10577var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause'); 10578var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play'); 10579var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing'); 10580var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel'); 10581var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown'); 10582var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove'); 10583var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout'); 10584var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover'); 10585var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup'); 10586var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress'); 10587var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange'); 10588var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset'); 10589var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll'); 10590var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked'); 10591var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking'); 10592var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange'); 10593var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled'); 10594var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit'); 10595var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend'); 10596var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput'); 10597var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate'); 10598var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle'); 10599var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel'); 10600var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend'); 10601var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove'); 10602var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart'); 10603var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend')); 10604var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange'); 10605var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting'); 10606var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements. 10607// Note that events in this list will *not* be listened to at the top level 10608// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`. 10609 10610var mediaEventTypes = [TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_VOLUME_CHANGE, TOP_WAITING]; 10611function getRawEventName(topLevelType) { 10612 return unsafeCastDOMTopLevelTypeToString(topLevelType); 10613} 10614 10615var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // prettier-ignore 10616 10617var elementListenerMap = new PossiblyWeakMap(); 10618function getListenerMapForElement(element) { 10619 var listenerMap = elementListenerMap.get(element); 10620 10621 if (listenerMap === undefined) { 10622 listenerMap = new Map(); 10623 elementListenerMap.set(element, listenerMap); 10624 } 10625 10626 return listenerMap; 10627} 10628 10629/** 10630 * `ReactInstanceMap` maintains a mapping from a public facing stateful 10631 * instance (key) and the internal representation (value). This allows public 10632 * methods to accept the user facing instance as an argument and map them back 10633 * to internal methods. 10634 * 10635 * Note that this module is currently shared and assumed to be stateless. 10636 * If this becomes an actual Map, that will break. 10637 */ 10638function get(key) { 10639 return key._reactInternalFiber; 10640} 10641function has(key) { 10642 return key._reactInternalFiber !== undefined; 10643} 10644function set(key, value) { 10645 key._reactInternalFiber = value; 10646} 10647 10648// Don't change these two values. They're used by React Dev Tools. 10649var NoEffect = 10650/* */ 106510; 10652var PerformedWork = 10653/* */ 106541; // You can change the rest (and add more). 10655 10656var Placement = 10657/* */ 106582; 10659var Update = 10660/* */ 106614; 10662var PlacementAndUpdate = 10663/* */ 106646; 10665var Deletion = 10666/* */ 106678; 10668var ContentReset = 10669/* */ 1067016; 10671var Callback = 10672/* */ 1067332; 10674var DidCapture = 10675/* */ 1067664; 10677var Ref = 10678/* */ 10679128; 10680var Snapshot = 10681/* */ 10682256; 10683var Passive = 10684/* */ 10685512; 10686var Hydrating = 10687/* */ 106881024; 10689var HydratingAndUpdate = 10690/* */ 106911028; // Passive & Update & Callback & Ref & Snapshot 10692 10693var LifecycleEffectMask = 10694/* */ 10695932; // Union of all host effects 10696 10697var HostEffectMask = 10698/* */ 106992047; 10700var Incomplete = 10701/* */ 107022048; 10703var ShouldCapture = 10704/* */ 107054096; 10706 10707var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; 10708function getNearestMountedFiber(fiber) { 10709 var node = fiber; 10710 var nearestMounted = fiber; 10711 10712 if (!fiber.alternate) { 10713 // If there is no alternate, this might be a new tree that isn't inserted 10714 // yet. If it is, then it will have a pending insertion effect on it. 10715 var nextNode = node; 10716 10717 do { 10718 node = nextNode; 10719 10720 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { 10721 // This is an insertion or in-progress hydration. The nearest possible 10722 // mounted fiber is the parent but we need to continue to figure out 10723 // if that one is still mounted. 10724 nearestMounted = node.return; 10725 } 10726 10727 nextNode = node.return; 10728 } while (nextNode); 10729 } else { 10730 while (node.return) { 10731 node = node.return; 10732 } 10733 } 10734 10735 if (node.tag === HostRoot) { 10736 // TODO: Check if this was a nested HostRoot when used with 10737 // renderContainerIntoSubtree. 10738 return nearestMounted; 10739 } // If we didn't hit the root, that means that we're in an disconnected tree 10740 // that has been unmounted. 10741 10742 10743 return null; 10744} 10745function getSuspenseInstanceFromFiber(fiber) { 10746 if (fiber.tag === SuspenseComponent) { 10747 var suspenseState = fiber.memoizedState; 10748 10749 if (suspenseState === null) { 10750 var current = fiber.alternate; 10751 10752 if (current !== null) { 10753 suspenseState = current.memoizedState; 10754 } 10755 } 10756 10757 if (suspenseState !== null) { 10758 return suspenseState.dehydrated; 10759 } 10760 } 10761 10762 return null; 10763} 10764function getContainerFromFiber(fiber) { 10765 return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; 10766} 10767function isFiberMounted(fiber) { 10768 return getNearestMountedFiber(fiber) === fiber; 10769} 10770function isMounted(component) { 10771 { 10772 var owner = ReactCurrentOwner.current; 10773 10774 if (owner !== null && owner.tag === ClassComponent) { 10775 var ownerFiber = owner; 10776 var instance = ownerFiber.stateNode; 10777 10778 if (!instance._warnedAboutRefsInRender) { 10779 error('%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.type) || 'A component'); 10780 } 10781 10782 instance._warnedAboutRefsInRender = true; 10783 } 10784 } 10785 10786 var fiber = get(component); 10787 10788 if (!fiber) { 10789 return false; 10790 } 10791 10792 return getNearestMountedFiber(fiber) === fiber; 10793} 10794 10795function assertIsMounted(fiber) { 10796 if (!(getNearestMountedFiber(fiber) === fiber)) { 10797 { 10798 throw Error( "Unable to find node on an unmounted component." ); 10799 } 10800 } 10801} 10802 10803function findCurrentFiberUsingSlowPath(fiber) { 10804 var alternate = fiber.alternate; 10805 10806 if (!alternate) { 10807 // If there is no alternate, then we only need to check if it is mounted. 10808 var nearestMounted = getNearestMountedFiber(fiber); 10809 10810 if (!(nearestMounted !== null)) { 10811 { 10812 throw Error( "Unable to find node on an unmounted component." ); 10813 } 10814 } 10815 10816 if (nearestMounted !== fiber) { 10817 return null; 10818 } 10819 10820 return fiber; 10821 } // If we have two possible branches, we'll walk backwards up to the root 10822 // to see what path the root points to. On the way we may hit one of the 10823 // special cases and we'll deal with them. 10824 10825 10826 var a = fiber; 10827 var b = alternate; 10828 10829 while (true) { 10830 var parentA = a.return; 10831 10832 if (parentA === null) { 10833 // We're at the root. 10834 break; 10835 } 10836 10837 var parentB = parentA.alternate; 10838 10839 if (parentB === null) { 10840 // There is no alternate. This is an unusual case. Currently, it only 10841 // happens when a Suspense component is hidden. An extra fragment fiber 10842 // is inserted in between the Suspense fiber and its children. Skip 10843 // over this extra fragment fiber and proceed to the next parent. 10844 var nextParent = parentA.return; 10845 10846 if (nextParent !== null) { 10847 a = b = nextParent; 10848 continue; 10849 } // If there's no parent, we're at the root. 10850 10851 10852 break; 10853 } // If both copies of the parent fiber point to the same child, we can 10854 // assume that the child is current. This happens when we bailout on low 10855 // priority: the bailed out fiber's child reuses the current child. 10856 10857 10858 if (parentA.child === parentB.child) { 10859 var child = parentA.child; 10860 10861 while (child) { 10862 if (child === a) { 10863 // We've determined that A is the current branch. 10864 assertIsMounted(parentA); 10865 return fiber; 10866 } 10867 10868 if (child === b) { 10869 // We've determined that B is the current branch. 10870 assertIsMounted(parentA); 10871 return alternate; 10872 } 10873 10874 child = child.sibling; 10875 } // We should never have an alternate for any mounting node. So the only 10876 // way this could possibly happen is if this was unmounted, if at all. 10877 10878 10879 { 10880 { 10881 throw Error( "Unable to find node on an unmounted component." ); 10882 } 10883 } 10884 } 10885 10886 if (a.return !== b.return) { 10887 // The return pointer of A and the return pointer of B point to different 10888 // fibers. We assume that return pointers never criss-cross, so A must 10889 // belong to the child set of A.return, and B must belong to the child 10890 // set of B.return. 10891 a = parentA; 10892 b = parentB; 10893 } else { 10894 // The return pointers point to the same fiber. We'll have to use the 10895 // default, slow path: scan the child sets of each parent alternate to see 10896 // which child belongs to which set. 10897 // 10898 // Search parent A's child set 10899 var didFindChild = false; 10900 var _child = parentA.child; 10901 10902 while (_child) { 10903 if (_child === a) { 10904 didFindChild = true; 10905 a = parentA; 10906 b = parentB; 10907 break; 10908 } 10909 10910 if (_child === b) { 10911 didFindChild = true; 10912 b = parentA; 10913 a = parentB; 10914 break; 10915 } 10916 10917 _child = _child.sibling; 10918 } 10919 10920 if (!didFindChild) { 10921 // Search parent B's child set 10922 _child = parentB.child; 10923 10924 while (_child) { 10925 if (_child === a) { 10926 didFindChild = true; 10927 a = parentB; 10928 b = parentA; 10929 break; 10930 } 10931 10932 if (_child === b) { 10933 didFindChild = true; 10934 b = parentB; 10935 a = parentA; 10936 break; 10937 } 10938 10939 _child = _child.sibling; 10940 } 10941 10942 if (!didFindChild) { 10943 { 10944 throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." ); 10945 } 10946 } 10947 } 10948 } 10949 10950 if (!(a.alternate === b)) { 10951 { 10952 throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); 10953 } 10954 } 10955 } // If the root is not a host container, we're in a disconnected tree. I.e. 10956 // unmounted. 10957 10958 10959 if (!(a.tag === HostRoot)) { 10960 { 10961 throw Error( "Unable to find node on an unmounted component." ); 10962 } 10963 } 10964 10965 if (a.stateNode.current === a) { 10966 // We've determined that A is the current branch. 10967 return fiber; 10968 } // Otherwise B has to be current branch. 10969 10970 10971 return alternate; 10972} 10973function findCurrentHostFiber(parent) { 10974 var currentParent = findCurrentFiberUsingSlowPath(parent); 10975 10976 if (!currentParent) { 10977 return null; 10978 } // Next we'll drill down this component to find the first HostComponent/Text. 10979 10980 10981 var node = currentParent; 10982 10983 while (true) { 10984 if (node.tag === HostComponent || node.tag === HostText) { 10985 return node; 10986 } else if (node.child) { 10987 node.child.return = node; 10988 node = node.child; 10989 continue; 10990 } 10991 10992 if (node === currentParent) { 10993 return null; 10994 } 10995 10996 while (!node.sibling) { 10997 if (!node.return || node.return === currentParent) { 10998 return null; 10999 } 11000 11001 node = node.return; 11002 } 11003 11004 node.sibling.return = node.return; 11005 node = node.sibling; 11006 } // Flow needs the return null here, but ESLint complains about it. 11007 // eslint-disable-next-line no-unreachable 11008 11009 11010 return null; 11011} 11012function findCurrentHostFiberWithNoPortals(parent) { 11013 var currentParent = findCurrentFiberUsingSlowPath(parent); 11014 11015 if (!currentParent) { 11016 return null; 11017 } // Next we'll drill down this component to find the first HostComponent/Text. 11018 11019 11020 var node = currentParent; 11021 11022 while (true) { 11023 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { 11024 return node; 11025 } else if (node.child && node.tag !== HostPortal) { 11026 node.child.return = node; 11027 node = node.child; 11028 continue; 11029 } 11030 11031 if (node === currentParent) { 11032 return null; 11033 } 11034 11035 while (!node.sibling) { 11036 if (!node.return || node.return === currentParent) { 11037 return null; 11038 } 11039 11040 node = node.return; 11041 } 11042 11043 node.sibling.return = node.return; 11044 node = node.sibling; 11045 } // Flow needs the return null here, but ESLint complains about it. 11046 // eslint-disable-next-line no-unreachable 11047 11048 11049 return null; 11050} 11051 11052/** 11053 * Accumulates items that must not be null or undefined into the first one. This 11054 * is used to conserve memory by avoiding array allocations, and thus sacrifices 11055 * API cleanness. Since `current` can be null before being passed in and not 11056 * null after this function, make sure to assign it back to `current`: 11057 * 11058 * `a = accumulateInto(a, b);` 11059 * 11060 * This API should be sparingly used. Try `accumulate` for something cleaner. 11061 * 11062 * @return {*|array<*>} An accumulation of items. 11063 */ 11064 11065function accumulateInto(current, next) { 11066 if (!(next != null)) { 11067 { 11068 throw Error( "accumulateInto(...): Accumulated items must not be null or undefined." ); 11069 } 11070 } 11071 11072 if (current == null) { 11073 return next; 11074 } // Both are not empty. Warning: Never call x.concat(y) when you are not 11075 // certain that x is an Array (x could be a string with concat method). 11076 11077 11078 if (Array.isArray(current)) { 11079 if (Array.isArray(next)) { 11080 current.push.apply(current, next); 11081 return current; 11082 } 11083 11084 current.push(next); 11085 return current; 11086 } 11087 11088 if (Array.isArray(next)) { 11089 // A bit too dangerous to mutate `next`. 11090 return [current].concat(next); 11091 } 11092 11093 return [current, next]; 11094} 11095 11096/** 11097 * @param {array} arr an "accumulation" of items which is either an Array or 11098 * a single item. Useful when paired with the `accumulate` module. This is a 11099 * simple utility that allows us to reason about a collection of items, but 11100 * handling the case when there is exactly one item (and we do not need to 11101 * allocate an array). 11102 * @param {function} cb Callback invoked with each element or a collection. 11103 * @param {?} [scope] Scope used as `this` in a callback. 11104 */ 11105function forEachAccumulated(arr, cb, scope) { 11106 if (Array.isArray(arr)) { 11107 arr.forEach(cb, scope); 11108 } else if (arr) { 11109 cb.call(scope, arr); 11110 } 11111} 11112 11113/** 11114 * Internal queue of events that have accumulated their dispatches and are 11115 * waiting to have their dispatches executed. 11116 */ 11117 11118var eventQueue = null; 11119/** 11120 * Dispatches an event and releases it back into the pool, unless persistent. 11121 * 11122 * @param {?object} event Synthetic event to be dispatched. 11123 * @private 11124 */ 11125 11126var executeDispatchesAndRelease = function (event) { 11127 if (event) { 11128 executeDispatchesInOrder(event); 11129 11130 if (!event.isPersistent()) { 11131 event.constructor.release(event); 11132 } 11133 } 11134}; 11135 11136var executeDispatchesAndReleaseTopLevel = function (e) { 11137 return executeDispatchesAndRelease(e); 11138}; 11139 11140function runEventsInBatch(events) { 11141 if (events !== null) { 11142 eventQueue = accumulateInto(eventQueue, events); 11143 } // Set `eventQueue` to null before processing it so that we can tell if more 11144 // events get enqueued while processing. 11145 11146 11147 var processingEventQueue = eventQueue; 11148 eventQueue = null; 11149 11150 if (!processingEventQueue) { 11151 return; 11152 } 11153 11154 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); 11155 11156 if (!!eventQueue) { 11157 { 11158 throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); 11159 } 11160 } // This would be a good time to rethrow if any of the event handlers threw. 11161 11162 11163 rethrowCaughtError(); 11164} 11165 11166/** 11167 * Gets the target node from a native browser event by accounting for 11168 * inconsistencies in browser DOM APIs. 11169 * 11170 * @param {object} nativeEvent Native browser event. 11171 * @return {DOMEventTarget} Target node. 11172 */ 11173 11174function getEventTarget(nativeEvent) { 11175 // Fallback to nativeEvent.srcElement for IE9 11176 // https://github.com/facebook/react/issues/12506 11177 var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 11178 11179 if (target.correspondingUseElement) { 11180 target = target.correspondingUseElement; 11181 } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 11182 // @see http://www.quirksmode.org/js/events_properties.html 11183 11184 11185 return target.nodeType === TEXT_NODE ? target.parentNode : target; 11186} 11187 11188/** 11189 * Checks if an event is supported in the current execution environment. 11190 * 11191 * NOTE: This will not work correctly for non-generic events such as `change`, 11192 * `reset`, `load`, `error`, and `select`. 11193 * 11194 * Borrows from Modernizr. 11195 * 11196 * @param {string} eventNameSuffix Event name, e.g. "click". 11197 * @return {boolean} True if the event is supported. 11198 * @internal 11199 * @license Modernizr 3.0.0pre (Custom Build) | MIT 11200 */ 11201 11202function isEventSupported(eventNameSuffix) { 11203 if (!canUseDOM) { 11204 return false; 11205 } 11206 11207 var eventName = 'on' + eventNameSuffix; 11208 var isSupported = eventName in document; 11209 11210 if (!isSupported) { 11211 var element = document.createElement('div'); 11212 element.setAttribute(eventName, 'return;'); 11213 isSupported = typeof element[eventName] === 'function'; 11214 } 11215 11216 return isSupported; 11217} 11218 11219/** 11220 * Summary of `DOMEventPluginSystem` event handling: 11221 * 11222 * - Top-level delegation is used to trap most native browser events. This 11223 * may only occur in the main thread and is the responsibility of 11224 * ReactDOMEventListener, which is injected and can therefore support 11225 * pluggable event sources. This is the only work that occurs in the main 11226 * thread. 11227 * 11228 * - We normalize and de-duplicate events to account for browser quirks. This 11229 * may be done in the worker thread. 11230 * 11231 * - Forward these native events (with the associated top-level type used to 11232 * trap it) to `EventPluginRegistry`, which in turn will ask plugins if they want 11233 * to extract any synthetic events. 11234 * 11235 * - The `EventPluginRegistry` will then process each event by annotating them with 11236 * "dispatches", a sequence of listeners and IDs that care about that event. 11237 * 11238 * - The `EventPluginRegistry` then dispatches the events. 11239 * 11240 * Overview of React and the event system: 11241 * 11242 * +------------+ . 11243 * | DOM | . 11244 * +------------+ . 11245 * | . 11246 * v . 11247 * +------------+ . 11248 * | ReactEvent | . 11249 * | Listener | . 11250 * +------------+ . +-----------+ 11251 * | . +--------+|SimpleEvent| 11252 * | . | |Plugin | 11253 * +-----|------+ . v +-----------+ 11254 * | | | . +--------------+ +------------+ 11255 * | +-----------.--->|PluginRegistry| | Event | 11256 * | | . | | +-----------+ | Propagators| 11257 * | ReactEvent | . | | |TapEvent | |------------| 11258 * | Emitter | . | |<---+|Plugin | |other plugin| 11259 * | | . | | +-----------+ | utilities | 11260 * | +-----------.--->| | +------------+ 11261 * | | | . +--------------+ 11262 * +-----|------+ . ^ +-----------+ 11263 * | . | |Enter/Leave| 11264 * + . +-------+|Plugin | 11265 * +-------------+ . +-----------+ 11266 * | application | . 11267 * |-------------| . 11268 * | | . 11269 * | | . 11270 * +-------------+ . 11271 * . 11272 * React Core . General Purpose Event Plugin System 11273 */ 11274 11275var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; 11276var callbackBookkeepingPool = []; 11277 11278function releaseTopLevelCallbackBookKeeping(instance) { 11279 instance.topLevelType = null; 11280 instance.nativeEvent = null; 11281 instance.targetInst = null; 11282 instance.ancestors.length = 0; 11283 11284 if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { 11285 callbackBookkeepingPool.push(instance); 11286 } 11287} // Used to store ancestor hierarchy in top level callback 11288 11289 11290function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) { 11291 if (callbackBookkeepingPool.length) { 11292 var instance = callbackBookkeepingPool.pop(); 11293 instance.topLevelType = topLevelType; 11294 instance.eventSystemFlags = eventSystemFlags; 11295 instance.nativeEvent = nativeEvent; 11296 instance.targetInst = targetInst; 11297 return instance; 11298 } 11299 11300 return { 11301 topLevelType: topLevelType, 11302 eventSystemFlags: eventSystemFlags, 11303 nativeEvent: nativeEvent, 11304 targetInst: targetInst, 11305 ancestors: [] 11306 }; 11307} 11308/** 11309 * Find the deepest React component completely containing the root of the 11310 * passed-in instance (for use when entire React trees are nested within each 11311 * other). If React trees are not nested, returns null. 11312 */ 11313 11314 11315function findRootContainerNode(inst) { 11316 if (inst.tag === HostRoot) { 11317 return inst.stateNode.containerInfo; 11318 } // TODO: It may be a good idea to cache this to prevent unnecessary DOM 11319 // traversal, but caching is difficult to do correctly without using a 11320 // mutation observer to listen for all DOM changes. 11321 11322 11323 while (inst.return) { 11324 inst = inst.return; 11325 } 11326 11327 if (inst.tag !== HostRoot) { 11328 // This can happen if we're in a detached tree. 11329 return null; 11330 } 11331 11332 return inst.stateNode.containerInfo; 11333} 11334/** 11335 * Allows registered plugins an opportunity to extract events from top-level 11336 * native browser events. 11337 * 11338 * @return {*} An accumulation of synthetic events. 11339 * @internal 11340 */ 11341 11342 11343function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 11344 var events = null; 11345 11346 for (var i = 0; i < plugins.length; i++) { 11347 // Not every plugin in the ordering may be loaded at runtime. 11348 var possiblePlugin = plugins[i]; 11349 11350 if (possiblePlugin) { 11351 var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 11352 11353 if (extractedEvents) { 11354 events = accumulateInto(events, extractedEvents); 11355 } 11356 } 11357 } 11358 11359 return events; 11360} 11361 11362function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 11363 var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 11364 runEventsInBatch(events); 11365} 11366 11367function handleTopLevel(bookKeeping) { 11368 var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components. 11369 // It's important that we build the array of ancestors before calling any 11370 // event handlers, because event handlers can modify the DOM, leading to 11371 // inconsistencies with ReactMount's node cache. See #1105. 11372 11373 var ancestor = targetInst; 11374 11375 do { 11376 if (!ancestor) { 11377 var ancestors = bookKeeping.ancestors; 11378 ancestors.push(ancestor); 11379 break; 11380 } 11381 11382 var root = findRootContainerNode(ancestor); 11383 11384 if (!root) { 11385 break; 11386 } 11387 11388 var tag = ancestor.tag; 11389 11390 if (tag === HostComponent || tag === HostText) { 11391 bookKeeping.ancestors.push(ancestor); 11392 } 11393 11394 ancestor = getClosestInstanceFromNode(root); 11395 } while (ancestor); 11396 11397 for (var i = 0; i < bookKeeping.ancestors.length; i++) { 11398 targetInst = bookKeeping.ancestors[i]; 11399 var eventTarget = getEventTarget(bookKeeping.nativeEvent); 11400 var topLevelType = bookKeeping.topLevelType; 11401 var nativeEvent = bookKeeping.nativeEvent; 11402 var eventSystemFlags = bookKeeping.eventSystemFlags; // If this is the first ancestor, we mark it on the system flags 11403 11404 if (i === 0) { 11405 eventSystemFlags |= IS_FIRST_ANCESTOR; 11406 } 11407 11408 runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, eventSystemFlags); 11409 } 11410} 11411 11412function dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) { 11413 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags); 11414 11415 try { 11416 // Event queue being processed in the same cycle allows 11417 // `preventDefault`. 11418 batchedEventUpdates(handleTopLevel, bookKeeping); 11419 } finally { 11420 releaseTopLevelCallbackBookKeeping(bookKeeping); 11421 } 11422} 11423/** 11424 * We listen for bubbled touch events on the document object. 11425 * 11426 * Firefox v8.01 (and possibly others) exhibited strange behavior when 11427 * mounting `onmousemove` events at some node that was not the document 11428 * element. The symptoms were that if your mouse is not moving over something 11429 * contained within that mount point (for example on the background) the 11430 * top-level listeners for `onmousemove` won't be called. However, if you 11431 * register the `mousemove` on the document object, then it will of course 11432 * catch all `mousemove`s. This along with iOS quirks, justifies restricting 11433 * top-level listeners to the document object only, at least for these 11434 * movement types of events and possibly all events. 11435 * 11436 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 11437 * 11438 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but 11439 * they bubble to document. 11440 * 11441 * @param {string} registrationName Name of listener (e.g. `onClick`). 11442 * @param {object} mountAt Container where to mount the listener 11443 */ 11444 11445function legacyListenToEvent(registrationName, mountAt) { 11446 var listenerMap = getListenerMapForElement(mountAt); 11447 var dependencies = registrationNameDependencies[registrationName]; 11448 11449 for (var i = 0; i < dependencies.length; i++) { 11450 var dependency = dependencies[i]; 11451 legacyListenToTopLevelEvent(dependency, mountAt, listenerMap); 11452 } 11453} 11454function legacyListenToTopLevelEvent(topLevelType, mountAt, listenerMap) { 11455 if (!listenerMap.has(topLevelType)) { 11456 switch (topLevelType) { 11457 case TOP_SCROLL: 11458 trapCapturedEvent(TOP_SCROLL, mountAt); 11459 break; 11460 11461 case TOP_FOCUS: 11462 case TOP_BLUR: 11463 trapCapturedEvent(TOP_FOCUS, mountAt); 11464 trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function, 11465 // but this ensures we mark both as attached rather than just one. 11466 11467 listenerMap.set(TOP_BLUR, null); 11468 listenerMap.set(TOP_FOCUS, null); 11469 break; 11470 11471 case TOP_CANCEL: 11472 case TOP_CLOSE: 11473 if (isEventSupported(getRawEventName(topLevelType))) { 11474 trapCapturedEvent(topLevelType, mountAt); 11475 } 11476 11477 break; 11478 11479 case TOP_INVALID: 11480 case TOP_SUBMIT: 11481 case TOP_RESET: 11482 // We listen to them on the target DOM elements. 11483 // Some of them bubble so we don't want them to fire twice. 11484 break; 11485 11486 default: 11487 // By default, listen on the top level to all non-media events. 11488 // Media events don't bubble so adding the listener wouldn't do anything. 11489 var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1; 11490 11491 if (!isMediaEvent) { 11492 trapBubbledEvent(topLevelType, mountAt); 11493 } 11494 11495 break; 11496 } 11497 11498 listenerMap.set(topLevelType, null); 11499 } 11500} 11501function isListeningToAllDependencies(registrationName, mountAt) { 11502 var listenerMap = getListenerMapForElement(mountAt); 11503 var dependencies = registrationNameDependencies[registrationName]; 11504 11505 for (var i = 0; i < dependencies.length; i++) { 11506 var dependency = dependencies[i]; 11507 11508 if (!listenerMap.has(dependency)) { 11509 return false; 11510 } 11511 } 11512 11513 return true; 11514} 11515 11516var attemptUserBlockingHydration; 11517function setAttemptUserBlockingHydration(fn) { 11518 attemptUserBlockingHydration = fn; 11519} 11520var attemptContinuousHydration; 11521function setAttemptContinuousHydration(fn) { 11522 attemptContinuousHydration = fn; 11523} 11524var attemptHydrationAtCurrentPriority; 11525function setAttemptHydrationAtCurrentPriority(fn) { 11526 attemptHydrationAtCurrentPriority = fn; 11527} // TODO: Upgrade this definition once we're on a newer version of Flow that 11528var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. 11529 11530var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. 11531// if the last target was dehydrated. 11532 11533var queuedFocus = null; 11534var queuedDrag = null; 11535var queuedMouse = null; // For pointer events there can be one latest event per pointerId. 11536 11537var queuedPointers = new Map(); 11538var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. 11539 11540var queuedExplicitHydrationTargets = []; 11541function hasQueuedDiscreteEvents() { 11542 return queuedDiscreteEvents.length > 0; 11543} 11544var discreteReplayableEvents = [TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_START, TOP_AUX_CLICK, TOP_DOUBLE_CLICK, TOP_POINTER_CANCEL, TOP_POINTER_DOWN, TOP_POINTER_UP, TOP_DRAG_END, TOP_DRAG_START, TOP_DROP, TOP_COMPOSITION_END, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_INPUT, TOP_TEXT_INPUT, TOP_CLOSE, TOP_CANCEL, TOP_COPY, TOP_CUT, TOP_PASTE, TOP_CLICK, TOP_CHANGE, TOP_CONTEXT_MENU, TOP_RESET, TOP_SUBMIT]; 11545var continuousReplayableEvents = [TOP_FOCUS, TOP_BLUR, TOP_DRAG_ENTER, TOP_DRAG_LEAVE, TOP_MOUSE_OVER, TOP_MOUSE_OUT, TOP_POINTER_OVER, TOP_POINTER_OUT, TOP_GOT_POINTER_CAPTURE, TOP_LOST_POINTER_CAPTURE]; 11546function isReplayableDiscreteEvent(eventType) { 11547 return discreteReplayableEvents.indexOf(eventType) > -1; 11548} 11549 11550function trapReplayableEventForDocument(topLevelType, document, listenerMap) { 11551 legacyListenToTopLevelEvent(topLevelType, document, listenerMap); 11552} 11553 11554function eagerlyTrapReplayableEvents(container, document) { 11555 var listenerMapForDoc = getListenerMapForElement(document); // Discrete 11556 11557 discreteReplayableEvents.forEach(function (topLevelType) { 11558 trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); 11559 }); // Continuous 11560 11561 continuousReplayableEvents.forEach(function (topLevelType) { 11562 trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); 11563 }); 11564} 11565 11566function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 11567 return { 11568 blockedOn: blockedOn, 11569 topLevelType: topLevelType, 11570 eventSystemFlags: eventSystemFlags | IS_REPLAYED, 11571 nativeEvent: nativeEvent, 11572 container: container 11573 }; 11574} 11575 11576function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 11577 var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 11578 queuedDiscreteEvents.push(queuedEvent); 11579} // Resets the replaying for this type of continuous event to no event. 11580 11581function clearIfContinuousEvent(topLevelType, nativeEvent) { 11582 switch (topLevelType) { 11583 case TOP_FOCUS: 11584 case TOP_BLUR: 11585 queuedFocus = null; 11586 break; 11587 11588 case TOP_DRAG_ENTER: 11589 case TOP_DRAG_LEAVE: 11590 queuedDrag = null; 11591 break; 11592 11593 case TOP_MOUSE_OVER: 11594 case TOP_MOUSE_OUT: 11595 queuedMouse = null; 11596 break; 11597 11598 case TOP_POINTER_OVER: 11599 case TOP_POINTER_OUT: 11600 { 11601 var pointerId = nativeEvent.pointerId; 11602 queuedPointers.delete(pointerId); 11603 break; 11604 } 11605 11606 case TOP_GOT_POINTER_CAPTURE: 11607 case TOP_LOST_POINTER_CAPTURE: 11608 { 11609 var _pointerId = nativeEvent.pointerId; 11610 queuedPointerCaptures.delete(_pointerId); 11611 break; 11612 } 11613 } 11614} 11615 11616function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 11617 if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { 11618 var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 11619 11620 if (blockedOn !== null) { 11621 var _fiber2 = getInstanceFromNode$1(blockedOn); 11622 11623 if (_fiber2 !== null) { 11624 // Attempt to increase the priority of this target. 11625 attemptContinuousHydration(_fiber2); 11626 } 11627 } 11628 11629 return queuedEvent; 11630 } // If we have already queued this exact event, then it's because 11631 // the different event systems have different DOM event listeners. 11632 // We can accumulate the flags and store a single event to be 11633 // replayed. 11634 11635 11636 existingQueuedEvent.eventSystemFlags |= eventSystemFlags; 11637 return existingQueuedEvent; 11638} 11639 11640function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 11641 // These set relatedTarget to null because the replayed event will be treated as if we 11642 // moved from outside the window (no target) onto the target once it hydrates. 11643 // Instead of mutating we could clone the event. 11644 switch (topLevelType) { 11645 case TOP_FOCUS: 11646 { 11647 var focusEvent = nativeEvent; 11648 queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, container, focusEvent); 11649 return true; 11650 } 11651 11652 case TOP_DRAG_ENTER: 11653 { 11654 var dragEvent = nativeEvent; 11655 queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, container, dragEvent); 11656 return true; 11657 } 11658 11659 case TOP_MOUSE_OVER: 11660 { 11661 var mouseEvent = nativeEvent; 11662 queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, container, mouseEvent); 11663 return true; 11664 } 11665 11666 case TOP_POINTER_OVER: 11667 { 11668 var pointerEvent = nativeEvent; 11669 var pointerId = pointerEvent.pointerId; 11670 queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, container, pointerEvent)); 11671 return true; 11672 } 11673 11674 case TOP_GOT_POINTER_CAPTURE: 11675 { 11676 var _pointerEvent = nativeEvent; 11677 var _pointerId2 = _pointerEvent.pointerId; 11678 queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, container, _pointerEvent)); 11679 return true; 11680 } 11681 } 11682 11683 return false; 11684} // Check if this target is unblocked. Returns true if it's unblocked. 11685 11686function attemptExplicitHydrationTarget(queuedTarget) { 11687 // TODO: This function shares a lot of logic with attemptToDispatchEvent. 11688 // Try to unify them. It's a bit tricky since it would require two return 11689 // values. 11690 var targetInst = getClosestInstanceFromNode(queuedTarget.target); 11691 11692 if (targetInst !== null) { 11693 var nearestMounted = getNearestMountedFiber(targetInst); 11694 11695 if (nearestMounted !== null) { 11696 var tag = nearestMounted.tag; 11697 11698 if (tag === SuspenseComponent) { 11699 var instance = getSuspenseInstanceFromFiber(nearestMounted); 11700 11701 if (instance !== null) { 11702 // We're blocked on hydrating this boundary. 11703 // Increase its priority. 11704 queuedTarget.blockedOn = instance; 11705 Scheduler.unstable_runWithPriority(queuedTarget.priority, function () { 11706 attemptHydrationAtCurrentPriority(nearestMounted); 11707 }); 11708 return; 11709 } 11710 } else if (tag === HostRoot) { 11711 var root = nearestMounted.stateNode; 11712 11713 if (root.hydrate) { 11714 queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of 11715 // a root other than sync. 11716 11717 return; 11718 } 11719 } 11720 } 11721 } 11722 11723 queuedTarget.blockedOn = null; 11724} 11725 11726function attemptReplayContinuousQueuedEvent(queuedEvent) { 11727 if (queuedEvent.blockedOn !== null) { 11728 return false; 11729 } 11730 11731 var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.container, queuedEvent.nativeEvent); 11732 11733 if (nextBlockedOn !== null) { 11734 // We're still blocked. Try again later. 11735 var _fiber3 = getInstanceFromNode$1(nextBlockedOn); 11736 11737 if (_fiber3 !== null) { 11738 attemptContinuousHydration(_fiber3); 11739 } 11740 11741 queuedEvent.blockedOn = nextBlockedOn; 11742 return false; 11743 } 11744 11745 return true; 11746} 11747 11748function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { 11749 if (attemptReplayContinuousQueuedEvent(queuedEvent)) { 11750 map.delete(key); 11751 } 11752} 11753 11754function replayUnblockedEvents() { 11755 hasScheduledReplayAttempt = false; // First replay discrete events. 11756 11757 while (queuedDiscreteEvents.length > 0) { 11758 var nextDiscreteEvent = queuedDiscreteEvents[0]; 11759 11760 if (nextDiscreteEvent.blockedOn !== null) { 11761 // We're still blocked. 11762 // Increase the priority of this boundary to unblock 11763 // the next discrete event. 11764 var _fiber4 = getInstanceFromNode$1(nextDiscreteEvent.blockedOn); 11765 11766 if (_fiber4 !== null) { 11767 attemptUserBlockingHydration(_fiber4); 11768 } 11769 11770 break; 11771 } 11772 11773 var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.container, nextDiscreteEvent.nativeEvent); 11774 11775 if (nextBlockedOn !== null) { 11776 // We're still blocked. Try again later. 11777 nextDiscreteEvent.blockedOn = nextBlockedOn; 11778 } else { 11779 // We've successfully replayed the first event. Let's try the next one. 11780 queuedDiscreteEvents.shift(); 11781 } 11782 } // Next replay any continuous events. 11783 11784 11785 if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { 11786 queuedFocus = null; 11787 } 11788 11789 if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { 11790 queuedDrag = null; 11791 } 11792 11793 if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { 11794 queuedMouse = null; 11795 } 11796 11797 queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); 11798 queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); 11799} 11800 11801function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { 11802 if (queuedEvent.blockedOn === unblocked) { 11803 queuedEvent.blockedOn = null; 11804 11805 if (!hasScheduledReplayAttempt) { 11806 hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are 11807 // now unblocked. This first might not actually be unblocked yet. 11808 // We could check it early to avoid scheduling an unnecessary callback. 11809 11810 Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents); 11811 } 11812 } 11813} 11814 11815function retryIfBlockedOn(unblocked) { 11816 // Mark anything that was blocked on this as no longer blocked 11817 // and eligible for a replay. 11818 if (queuedDiscreteEvents.length > 0) { 11819 scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's 11820 // worth it because we expect very few discrete events to queue up and once 11821 // we are actually fully unblocked it will be fast to replay them. 11822 11823 for (var i = 1; i < queuedDiscreteEvents.length; i++) { 11824 var queuedEvent = queuedDiscreteEvents[i]; 11825 11826 if (queuedEvent.blockedOn === unblocked) { 11827 queuedEvent.blockedOn = null; 11828 } 11829 } 11830 } 11831 11832 if (queuedFocus !== null) { 11833 scheduleCallbackIfUnblocked(queuedFocus, unblocked); 11834 } 11835 11836 if (queuedDrag !== null) { 11837 scheduleCallbackIfUnblocked(queuedDrag, unblocked); 11838 } 11839 11840 if (queuedMouse !== null) { 11841 scheduleCallbackIfUnblocked(queuedMouse, unblocked); 11842 } 11843 11844 var unblock = function (queuedEvent) { 11845 return scheduleCallbackIfUnblocked(queuedEvent, unblocked); 11846 }; 11847 11848 queuedPointers.forEach(unblock); 11849 queuedPointerCaptures.forEach(unblock); 11850 11851 for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { 11852 var queuedTarget = queuedExplicitHydrationTargets[_i]; 11853 11854 if (queuedTarget.blockedOn === unblocked) { 11855 queuedTarget.blockedOn = null; 11856 } 11857 } 11858 11859 while (queuedExplicitHydrationTargets.length > 0) { 11860 var nextExplicitTarget = queuedExplicitHydrationTargets[0]; 11861 11862 if (nextExplicitTarget.blockedOn !== null) { 11863 // We're still blocked. 11864 break; 11865 } else { 11866 attemptExplicitHydrationTarget(nextExplicitTarget); 11867 11868 if (nextExplicitTarget.blockedOn === null) { 11869 // We're unblocked. 11870 queuedExplicitHydrationTargets.shift(); 11871 } 11872 } 11873 } 11874} 11875 11876function addEventBubbleListener(element, eventType, listener) { 11877 element.addEventListener(eventType, listener, false); 11878} 11879function addEventCaptureListener(element, eventType, listener) { 11880 element.addEventListener(eventType, listener, true); 11881} 11882 11883// do it in two places, which duplicates logic 11884// and increases the bundle size, we do it all 11885// here once. If we remove or refactor the 11886// SimpleEventPlugin, we should also remove or 11887// update the below line. 11888 11889var simpleEventPluginEventTypes = {}; 11890var topLevelEventsToDispatchConfig = new Map(); 11891var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use 11892// the code required to apply the same logic for event prioritization and that of the 11893// SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code 11894// duplication (for which there would be quite a bit). For the events that are not needed 11895// for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an 11896// array of top level events. 11897// Lastly, we ignore prettier so we can keep the formatting sane. 11898// prettier-ignore 11899 11900var discreteEventPairsForSimpleEventPlugin = [TOP_BLUR, 'blur', TOP_CANCEL, 'cancel', TOP_CLICK, 'click', TOP_CLOSE, 'close', TOP_CONTEXT_MENU, 'contextMenu', TOP_COPY, 'copy', TOP_CUT, 'cut', TOP_AUX_CLICK, 'auxClick', TOP_DOUBLE_CLICK, 'doubleClick', TOP_DRAG_END, 'dragEnd', TOP_DRAG_START, 'dragStart', TOP_DROP, 'drop', TOP_FOCUS, 'focus', TOP_INPUT, 'input', TOP_INVALID, 'invalid', TOP_KEY_DOWN, 'keyDown', TOP_KEY_PRESS, 'keyPress', TOP_KEY_UP, 'keyUp', TOP_MOUSE_DOWN, 'mouseDown', TOP_MOUSE_UP, 'mouseUp', TOP_PASTE, 'paste', TOP_PAUSE, 'pause', TOP_PLAY, 'play', TOP_POINTER_CANCEL, 'pointerCancel', TOP_POINTER_DOWN, 'pointerDown', TOP_POINTER_UP, 'pointerUp', TOP_RATE_CHANGE, 'rateChange', TOP_RESET, 'reset', TOP_SEEKED, 'seeked', TOP_SUBMIT, 'submit', TOP_TOUCH_CANCEL, 'touchCancel', TOP_TOUCH_END, 'touchEnd', TOP_TOUCH_START, 'touchStart', TOP_VOLUME_CHANGE, 'volumeChange']; 11901var otherDiscreteEvents = [TOP_CHANGE, TOP_SELECTION_CHANGE, TOP_TEXT_INPUT, TOP_COMPOSITION_START, TOP_COMPOSITION_END, TOP_COMPOSITION_UPDATE]; // prettier-ignore 11902 11903var userBlockingPairsForSimpleEventPlugin = [TOP_DRAG, 'drag', TOP_DRAG_ENTER, 'dragEnter', TOP_DRAG_EXIT, 'dragExit', TOP_DRAG_LEAVE, 'dragLeave', TOP_DRAG_OVER, 'dragOver', TOP_MOUSE_MOVE, 'mouseMove', TOP_MOUSE_OUT, 'mouseOut', TOP_MOUSE_OVER, 'mouseOver', TOP_POINTER_MOVE, 'pointerMove', TOP_POINTER_OUT, 'pointerOut', TOP_POINTER_OVER, 'pointerOver', TOP_SCROLL, 'scroll', TOP_TOGGLE, 'toggle', TOP_TOUCH_MOVE, 'touchMove', TOP_WHEEL, 'wheel']; // prettier-ignore 11904 11905var continuousPairsForSimpleEventPlugin = [TOP_ABORT, 'abort', TOP_ANIMATION_END, 'animationEnd', TOP_ANIMATION_ITERATION, 'animationIteration', TOP_ANIMATION_START, 'animationStart', TOP_CAN_PLAY, 'canPlay', TOP_CAN_PLAY_THROUGH, 'canPlayThrough', TOP_DURATION_CHANGE, 'durationChange', TOP_EMPTIED, 'emptied', TOP_ENCRYPTED, 'encrypted', TOP_ENDED, 'ended', TOP_ERROR, 'error', TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', TOP_LOAD, 'load', TOP_LOADED_DATA, 'loadedData', TOP_LOADED_METADATA, 'loadedMetadata', TOP_LOAD_START, 'loadStart', TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', TOP_PLAYING, 'playing', TOP_PROGRESS, 'progress', TOP_SEEKING, 'seeking', TOP_STALLED, 'stalled', TOP_SUSPEND, 'suspend', TOP_TIME_UPDATE, 'timeUpdate', TOP_TRANSITION_END, 'transitionEnd', TOP_WAITING, 'waiting']; 11906/** 11907 * Turns 11908 * ['abort', ...] 11909 * into 11910 * eventTypes = { 11911 * 'abort': { 11912 * phasedRegistrationNames: { 11913 * bubbled: 'onAbort', 11914 * captured: 'onAbortCapture', 11915 * }, 11916 * dependencies: [TOP_ABORT], 11917 * }, 11918 * ... 11919 * }; 11920 * topLevelEventsToDispatchConfig = new Map([ 11921 * [TOP_ABORT, { sameConfig }], 11922 * ]); 11923 */ 11924 11925function processSimpleEventPluginPairsByPriority(eventTypes, priority) { 11926 // As the event types are in pairs of two, we need to iterate 11927 // through in twos. The events are in pairs of two to save code 11928 // and improve init perf of processing this array, as it will 11929 // result in far fewer object allocations and property accesses 11930 // if we only use three arrays to process all the categories of 11931 // instead of tuples. 11932 for (var i = 0; i < eventTypes.length; i += 2) { 11933 var topEvent = eventTypes[i]; 11934 var event = eventTypes[i + 1]; 11935 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 11936 var onEvent = 'on' + capitalizedEvent; 11937 var config = { 11938 phasedRegistrationNames: { 11939 bubbled: onEvent, 11940 captured: onEvent + 'Capture' 11941 }, 11942 dependencies: [topEvent], 11943 eventPriority: priority 11944 }; 11945 eventPriorities.set(topEvent, priority); 11946 topLevelEventsToDispatchConfig.set(topEvent, config); 11947 simpleEventPluginEventTypes[event] = config; 11948 } 11949} 11950 11951function processTopEventPairsByPriority(eventTypes, priority) { 11952 for (var i = 0; i < eventTypes.length; i++) { 11953 eventPriorities.set(eventTypes[i], priority); 11954 } 11955} // SimpleEventPlugin 11956 11957 11958processSimpleEventPluginPairsByPriority(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); 11959processSimpleEventPluginPairsByPriority(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); 11960processSimpleEventPluginPairsByPriority(continuousPairsForSimpleEventPlugin, ContinuousEvent); // Not used by SimpleEventPlugin 11961 11962processTopEventPairsByPriority(otherDiscreteEvents, DiscreteEvent); 11963function getEventPriorityForPluginSystem(topLevelType) { 11964 var priority = eventPriorities.get(topLevelType); // Default to a ContinuousEvent. Note: we might 11965 // want to warn if we can't detect the priority 11966 // for the event. 11967 11968 return priority === undefined ? ContinuousEvent : priority; 11969} 11970 11971// Intentionally not named imports because Rollup would use dynamic dispatch for 11972var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 11973 runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these? 11974 11975var _enabled = true; 11976function setEnabled(enabled) { 11977 _enabled = !!enabled; 11978} 11979function isEnabled() { 11980 return _enabled; 11981} 11982function trapBubbledEvent(topLevelType, element) { 11983 trapEventForPluginEventSystem(element, topLevelType, false); 11984} 11985function trapCapturedEvent(topLevelType, element) { 11986 trapEventForPluginEventSystem(element, topLevelType, true); 11987} 11988 11989function trapEventForPluginEventSystem(container, topLevelType, capture) { 11990 var listener; 11991 11992 switch (getEventPriorityForPluginSystem(topLevelType)) { 11993 case DiscreteEvent: 11994 listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 11995 break; 11996 11997 case UserBlockingEvent: 11998 listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 11999 break; 12000 12001 case ContinuousEvent: 12002 default: 12003 listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 12004 break; 12005 } 12006 12007 var rawEventName = getRawEventName(topLevelType); 12008 12009 if (capture) { 12010 addEventCaptureListener(container, rawEventName, listener); 12011 } else { 12012 addEventBubbleListener(container, rawEventName, listener); 12013 } 12014} 12015 12016function dispatchDiscreteEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 12017 flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); 12018 discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, container, nativeEvent); 12019} 12020 12021function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, container, nativeEvent) { 12022 runWithPriority(UserBlockingPriority, dispatchEvent.bind(null, topLevelType, eventSystemFlags, container, nativeEvent)); 12023} 12024 12025function dispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 12026 if (!_enabled) { 12027 return; 12028 } 12029 12030 if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) { 12031 // If we already have a queue of discrete events, and this is another discrete 12032 // event, then we can't dispatch it regardless of its target, since they 12033 // need to dispatch in order. 12034 queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. 12035 topLevelType, eventSystemFlags, container, nativeEvent); 12036 return; 12037 } 12038 12039 var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent); 12040 12041 if (blockedOn === null) { 12042 // We successfully dispatched this event. 12043 clearIfContinuousEvent(topLevelType, nativeEvent); 12044 return; 12045 } 12046 12047 if (isReplayableDiscreteEvent(topLevelType)) { 12048 // This this to be replayed later once the target is available. 12049 queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 12050 return; 12051 } 12052 12053 if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent)) { 12054 return; 12055 } // We need to clear only if we didn't queue because 12056 // queueing is accummulative. 12057 12058 12059 clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target, 12060 // in case the event system needs to trace it. 12061 12062 { 12063 dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null); 12064 } 12065} // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. 12066 12067function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 12068 // TODO: Warn if _enabled is false. 12069 var nativeEventTarget = getEventTarget(nativeEvent); 12070 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 12071 12072 if (targetInst !== null) { 12073 var nearestMounted = getNearestMountedFiber(targetInst); 12074 12075 if (nearestMounted === null) { 12076 // This tree has been unmounted already. Dispatch without a target. 12077 targetInst = null; 12078 } else { 12079 var tag = nearestMounted.tag; 12080 12081 if (tag === SuspenseComponent) { 12082 var instance = getSuspenseInstanceFromFiber(nearestMounted); 12083 12084 if (instance !== null) { 12085 // Queue the event to be replayed later. Abort dispatching since we 12086 // don't want this event dispatched twice through the event system. 12087 // TODO: If this is the first discrete event in the queue. Schedule an increased 12088 // priority for this boundary. 12089 return instance; 12090 } // This shouldn't happen, something went wrong but to avoid blocking 12091 // the whole system, dispatch the event without a target. 12092 // TODO: Warn. 12093 12094 12095 targetInst = null; 12096 } else if (tag === HostRoot) { 12097 var root = nearestMounted.stateNode; 12098 12099 if (root.hydrate) { 12100 // If this happens during a replay something went wrong and it might block 12101 // the whole system. 12102 return getContainerFromFiber(nearestMounted); 12103 } 12104 12105 targetInst = null; 12106 } else if (nearestMounted !== targetInst) { 12107 // If we get an event (ex: img onload) before committing that 12108 // component's mount, ignore it for now (that is, treat it as if it was an 12109 // event on a non-React tree). We might also consider queueing events and 12110 // dispatching them after the mount. 12111 targetInst = null; 12112 } 12113 } 12114 } 12115 12116 { 12117 dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst); 12118 } // We're not blocked on anything. 12119 12120 12121 return null; 12122} 12123 12124// List derived from Gecko source code: 12125// https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js 12126var shorthandToLonghand = { 12127 animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], 12128 background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], 12129 backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], 12130 border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], 12131 borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], 12132 borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], 12133 borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], 12134 borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], 12135 borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], 12136 borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], 12137 borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], 12138 borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], 12139 borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], 12140 borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], 12141 borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], 12142 borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], 12143 borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], 12144 columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], 12145 columns: ['columnCount', 'columnWidth'], 12146 flex: ['flexBasis', 'flexGrow', 'flexShrink'], 12147 flexFlow: ['flexDirection', 'flexWrap'], 12148 font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], 12149 fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], 12150 gap: ['columnGap', 'rowGap'], 12151 grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 12152 gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], 12153 gridColumn: ['gridColumnEnd', 'gridColumnStart'], 12154 gridColumnGap: ['columnGap'], 12155 gridGap: ['columnGap', 'rowGap'], 12156 gridRow: ['gridRowEnd', 'gridRowStart'], 12157 gridRowGap: ['rowGap'], 12158 gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 12159 listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], 12160 margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], 12161 marker: ['markerEnd', 'markerMid', 'markerStart'], 12162 mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], 12163 maskPosition: ['maskPositionX', 'maskPositionY'], 12164 outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], 12165 overflow: ['overflowX', 'overflowY'], 12166 padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], 12167 placeContent: ['alignContent', 'justifyContent'], 12168 placeItems: ['alignItems', 'justifyItems'], 12169 placeSelf: ['alignSelf', 'justifySelf'], 12170 textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], 12171 textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], 12172 transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], 12173 wordWrap: ['overflowWrap'] 12174}; 12175 12176/** 12177 * CSS properties which accept numbers but are not in units of "px". 12178 */ 12179var isUnitlessNumber = { 12180 animationIterationCount: true, 12181 borderImageOutset: true, 12182 borderImageSlice: true, 12183 borderImageWidth: true, 12184 boxFlex: true, 12185 boxFlexGroup: true, 12186 boxOrdinalGroup: true, 12187 columnCount: true, 12188 columns: true, 12189 flex: true, 12190 flexGrow: true, 12191 flexPositive: true, 12192 flexShrink: true, 12193 flexNegative: true, 12194 flexOrder: true, 12195 gridArea: true, 12196 gridRow: true, 12197 gridRowEnd: true, 12198 gridRowSpan: true, 12199 gridRowStart: true, 12200 gridColumn: true, 12201 gridColumnEnd: true, 12202 gridColumnSpan: true, 12203 gridColumnStart: true, 12204 fontWeight: true, 12205 lineClamp: true, 12206 lineHeight: true, 12207 opacity: true, 12208 order: true, 12209 orphans: true, 12210 tabSize: true, 12211 widows: true, 12212 zIndex: true, 12213 zoom: true, 12214 // SVG-related properties 12215 fillOpacity: true, 12216 floodOpacity: true, 12217 stopOpacity: true, 12218 strokeDasharray: true, 12219 strokeDashoffset: true, 12220 strokeMiterlimit: true, 12221 strokeOpacity: true, 12222 strokeWidth: true 12223}; 12224/** 12225 * @param {string} prefix vendor-specific prefix, eg: Webkit 12226 * @param {string} key style name, eg: transitionDuration 12227 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 12228 * WebkitTransitionDuration 12229 */ 12230 12231function prefixKey(prefix, key) { 12232 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 12233} 12234/** 12235 * Support style names that may come passed in prefixed by adding permutations 12236 * of vendor prefixes. 12237 */ 12238 12239 12240var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 12241// infinite loop, because it iterates over the newly added props too. 12242 12243Object.keys(isUnitlessNumber).forEach(function (prop) { 12244 prefixes.forEach(function (prefix) { 12245 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 12246 }); 12247}); 12248 12249/** 12250 * Convert a value into the proper css writable value. The style name `name` 12251 * should be logical (no hyphens), as specified 12252 * in `CSSProperty.isUnitlessNumber`. 12253 * 12254 * @param {string} name CSS property name such as `topMargin`. 12255 * @param {*} value CSS property value such as `10px`. 12256 * @return {string} Normalized style value with dimensions applied. 12257 */ 12258 12259function dangerousStyleValue(name, value, isCustomProperty) { 12260 // Note that we've removed escapeTextForBrowser() calls here since the 12261 // whole string will be escaped when the attribute is injected into 12262 // the markup. If you provide unsafe user data here they can inject 12263 // arbitrary CSS which may be problematic (I couldn't repro this): 12264 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 12265 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 12266 // This is not an XSS hole but instead a potential CSS injection issue 12267 // which has lead to a greater discussion about how we're going to 12268 // trust URLs moving forward. See #2115901 12269 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 12270 12271 if (isEmpty) { 12272 return ''; 12273 } 12274 12275 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 12276 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 12277 } 12278 12279 return ('' + value).trim(); 12280} 12281 12282var uppercasePattern = /([A-Z])/g; 12283var msPattern = /^ms-/; 12284/** 12285 * Hyphenates a camelcased CSS property name, for example: 12286 * 12287 * > hyphenateStyleName('backgroundColor') 12288 * < "background-color" 12289 * > hyphenateStyleName('MozTransition') 12290 * < "-moz-transition" 12291 * > hyphenateStyleName('msTransition') 12292 * < "-ms-transition" 12293 * 12294 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 12295 * is converted to `-ms-`. 12296 */ 12297 12298function hyphenateStyleName(name) { 12299 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); 12300} 12301 12302var warnValidStyle = function () {}; 12303 12304{ 12305 // 'msTransform' is correct, but the other prefixes should be capitalized 12306 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 12307 var msPattern$1 = /^-ms-/; 12308 var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon 12309 12310 var badStyleValueWithSemicolonPattern = /;\s*$/; 12311 var warnedStyleNames = {}; 12312 var warnedStyleValues = {}; 12313 var warnedForNaNValue = false; 12314 var warnedForInfinityValue = false; 12315 12316 var camelize = function (string) { 12317 return string.replace(hyphenPattern, function (_, character) { 12318 return character.toUpperCase(); 12319 }); 12320 }; 12321 12322 var warnHyphenatedStyleName = function (name) { 12323 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 12324 return; 12325 } 12326 12327 warnedStyleNames[name] = true; 12328 12329 error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests 12330 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 12331 // is converted to lowercase `ms`. 12332 camelize(name.replace(msPattern$1, 'ms-'))); 12333 }; 12334 12335 var warnBadVendoredStyleName = function (name) { 12336 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 12337 return; 12338 } 12339 12340 warnedStyleNames[name] = true; 12341 12342 error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); 12343 }; 12344 12345 var warnStyleValueWithSemicolon = function (name, value) { 12346 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 12347 return; 12348 } 12349 12350 warnedStyleValues[value] = true; 12351 12352 error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); 12353 }; 12354 12355 var warnStyleValueIsNaN = function (name, value) { 12356 if (warnedForNaNValue) { 12357 return; 12358 } 12359 12360 warnedForNaNValue = true; 12361 12362 error('`NaN` is an invalid value for the `%s` css style property.', name); 12363 }; 12364 12365 var warnStyleValueIsInfinity = function (name, value) { 12366 if (warnedForInfinityValue) { 12367 return; 12368 } 12369 12370 warnedForInfinityValue = true; 12371 12372 error('`Infinity` is an invalid value for the `%s` css style property.', name); 12373 }; 12374 12375 warnValidStyle = function (name, value) { 12376 if (name.indexOf('-') > -1) { 12377 warnHyphenatedStyleName(name); 12378 } else if (badVendoredStyleNamePattern.test(name)) { 12379 warnBadVendoredStyleName(name); 12380 } else if (badStyleValueWithSemicolonPattern.test(value)) { 12381 warnStyleValueWithSemicolon(name, value); 12382 } 12383 12384 if (typeof value === 'number') { 12385 if (isNaN(value)) { 12386 warnStyleValueIsNaN(name, value); 12387 } else if (!isFinite(value)) { 12388 warnStyleValueIsInfinity(name, value); 12389 } 12390 } 12391 }; 12392} 12393 12394var warnValidStyle$1 = warnValidStyle; 12395 12396/** 12397 * Operations for dealing with CSS properties. 12398 */ 12399 12400/** 12401 * This creates a string that is expected to be equivalent to the style 12402 * attribute generated by server-side rendering. It by-passes warnings and 12403 * security checks so it's not safe to use this value for anything other than 12404 * comparison. It is only used in DEV for SSR validation. 12405 */ 12406 12407function createDangerousStringForStyles(styles) { 12408 { 12409 var serialized = ''; 12410 var delimiter = ''; 12411 12412 for (var styleName in styles) { 12413 if (!styles.hasOwnProperty(styleName)) { 12414 continue; 12415 } 12416 12417 var styleValue = styles[styleName]; 12418 12419 if (styleValue != null) { 12420 var isCustomProperty = styleName.indexOf('--') === 0; 12421 serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; 12422 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 12423 delimiter = ';'; 12424 } 12425 } 12426 12427 return serialized || null; 12428 } 12429} 12430/** 12431 * Sets the value for multiple styles on a node. If a value is specified as 12432 * '' (empty string), the corresponding style property will be unset. 12433 * 12434 * @param {DOMElement} node 12435 * @param {object} styles 12436 */ 12437 12438function setValueForStyles(node, styles) { 12439 var style = node.style; 12440 12441 for (var styleName in styles) { 12442 if (!styles.hasOwnProperty(styleName)) { 12443 continue; 12444 } 12445 12446 var isCustomProperty = styleName.indexOf('--') === 0; 12447 12448 { 12449 if (!isCustomProperty) { 12450 warnValidStyle$1(styleName, styles[styleName]); 12451 } 12452 } 12453 12454 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 12455 12456 if (styleName === 'float') { 12457 styleName = 'cssFloat'; 12458 } 12459 12460 if (isCustomProperty) { 12461 style.setProperty(styleName, styleValue); 12462 } else { 12463 style[styleName] = styleValue; 12464 } 12465 } 12466} 12467 12468function isValueEmpty(value) { 12469 return value == null || typeof value === 'boolean' || value === ''; 12470} 12471/** 12472 * Given {color: 'red', overflow: 'hidden'} returns { 12473 * color: 'color', 12474 * overflowX: 'overflow', 12475 * overflowY: 'overflow', 12476 * }. This can be read as "the overflowY property was set by the overflow 12477 * shorthand". That is, the values are the property that each was derived from. 12478 */ 12479 12480 12481function expandShorthandMap(styles) { 12482 var expanded = {}; 12483 12484 for (var key in styles) { 12485 var longhands = shorthandToLonghand[key] || [key]; 12486 12487 for (var i = 0; i < longhands.length; i++) { 12488 expanded[longhands[i]] = key; 12489 } 12490 } 12491 12492 return expanded; 12493} 12494/** 12495 * When mixing shorthand and longhand property names, we warn during updates if 12496 * we expect an incorrect result to occur. In particular, we warn for: 12497 * 12498 * Updating a shorthand property (longhand gets overwritten): 12499 * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} 12500 * becomes .style.font = 'baz' 12501 * Removing a shorthand property (longhand gets lost too): 12502 * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} 12503 * becomes .style.font = '' 12504 * Removing a longhand property (should revert to shorthand; doesn't): 12505 * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} 12506 * becomes .style.fontVariant = '' 12507 */ 12508 12509 12510function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { 12511 { 12512 12513 if (!nextStyles) { 12514 return; 12515 } 12516 12517 var expandedUpdates = expandShorthandMap(styleUpdates); 12518 var expandedStyles = expandShorthandMap(nextStyles); 12519 var warnedAbout = {}; 12520 12521 for (var key in expandedUpdates) { 12522 var originalKey = expandedUpdates[key]; 12523 var correctOriginalKey = expandedStyles[key]; 12524 12525 if (correctOriginalKey && originalKey !== correctOriginalKey) { 12526 var warningKey = originalKey + ',' + correctOriginalKey; 12527 12528 if (warnedAbout[warningKey]) { 12529 continue; 12530 } 12531 12532 warnedAbout[warningKey] = true; 12533 12534 error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey); 12535 } 12536 } 12537 } 12538} 12539 12540// For HTML, certain tags should omit their close tag. We keep a whitelist for 12541// those special-case tags. 12542var omittedCloseTags = { 12543 area: true, 12544 base: true, 12545 br: true, 12546 col: true, 12547 embed: true, 12548 hr: true, 12549 img: true, 12550 input: true, 12551 keygen: true, 12552 link: true, 12553 meta: true, 12554 param: true, 12555 source: true, 12556 track: true, 12557 wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. 12558 12559}; 12560 12561// `omittedCloseTags` except that `menuitem` should still have its closing tag. 12562 12563var voidElementTags = _assign({ 12564 menuitem: true 12565}, omittedCloseTags); 12566 12567var HTML = '__html'; 12568var ReactDebugCurrentFrame$3 = null; 12569 12570{ 12571 ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame; 12572} 12573 12574function assertValidProps(tag, props) { 12575 if (!props) { 12576 return; 12577 } // Note the use of `==` which checks for null or undefined. 12578 12579 12580 if (voidElementTags[tag]) { 12581 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { 12582 { 12583 throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); 12584 } 12585 } 12586 } 12587 12588 if (props.dangerouslySetInnerHTML != null) { 12589 if (!(props.children == null)) { 12590 { 12591 throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); 12592 } 12593 } 12594 12595 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { 12596 { 12597 throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information." ); 12598 } 12599 } 12600 } 12601 12602 { 12603 if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { 12604 error('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.'); 12605 } 12606 } 12607 12608 if (!(props.style == null || typeof props.style === 'object')) { 12609 { 12610 throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); 12611 } 12612 } 12613} 12614 12615function isCustomComponent(tagName, props) { 12616 if (tagName.indexOf('-') === -1) { 12617 return typeof props.is === 'string'; 12618 } 12619 12620 switch (tagName) { 12621 // These are reserved SVG and MathML elements. 12622 // We don't mind this whitelist too much because we expect it to never grow. 12623 // The alternative is to track the namespace in a few places which is convoluted. 12624 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 12625 case 'annotation-xml': 12626 case 'color-profile': 12627 case 'font-face': 12628 case 'font-face-src': 12629 case 'font-face-uri': 12630 case 'font-face-format': 12631 case 'font-face-name': 12632 case 'missing-glyph': 12633 return false; 12634 12635 default: 12636 return true; 12637 } 12638} 12639 12640// When adding attributes to the HTML or SVG whitelist, be sure to 12641// also add them to this module to ensure casing and incorrect name 12642// warnings. 12643var possibleStandardNames = { 12644 // HTML 12645 accept: 'accept', 12646 acceptcharset: 'acceptCharset', 12647 'accept-charset': 'acceptCharset', 12648 accesskey: 'accessKey', 12649 action: 'action', 12650 allowfullscreen: 'allowFullScreen', 12651 alt: 'alt', 12652 as: 'as', 12653 async: 'async', 12654 autocapitalize: 'autoCapitalize', 12655 autocomplete: 'autoComplete', 12656 autocorrect: 'autoCorrect', 12657 autofocus: 'autoFocus', 12658 autoplay: 'autoPlay', 12659 autosave: 'autoSave', 12660 capture: 'capture', 12661 cellpadding: 'cellPadding', 12662 cellspacing: 'cellSpacing', 12663 challenge: 'challenge', 12664 charset: 'charSet', 12665 checked: 'checked', 12666 children: 'children', 12667 cite: 'cite', 12668 class: 'className', 12669 classid: 'classID', 12670 classname: 'className', 12671 cols: 'cols', 12672 colspan: 'colSpan', 12673 content: 'content', 12674 contenteditable: 'contentEditable', 12675 contextmenu: 'contextMenu', 12676 controls: 'controls', 12677 controlslist: 'controlsList', 12678 coords: 'coords', 12679 crossorigin: 'crossOrigin', 12680 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 12681 data: 'data', 12682 datetime: 'dateTime', 12683 default: 'default', 12684 defaultchecked: 'defaultChecked', 12685 defaultvalue: 'defaultValue', 12686 defer: 'defer', 12687 dir: 'dir', 12688 disabled: 'disabled', 12689 disablepictureinpicture: 'disablePictureInPicture', 12690 download: 'download', 12691 draggable: 'draggable', 12692 enctype: 'encType', 12693 for: 'htmlFor', 12694 form: 'form', 12695 formmethod: 'formMethod', 12696 formaction: 'formAction', 12697 formenctype: 'formEncType', 12698 formnovalidate: 'formNoValidate', 12699 formtarget: 'formTarget', 12700 frameborder: 'frameBorder', 12701 headers: 'headers', 12702 height: 'height', 12703 hidden: 'hidden', 12704 high: 'high', 12705 href: 'href', 12706 hreflang: 'hrefLang', 12707 htmlfor: 'htmlFor', 12708 httpequiv: 'httpEquiv', 12709 'http-equiv': 'httpEquiv', 12710 icon: 'icon', 12711 id: 'id', 12712 innerhtml: 'innerHTML', 12713 inputmode: 'inputMode', 12714 integrity: 'integrity', 12715 is: 'is', 12716 itemid: 'itemID', 12717 itemprop: 'itemProp', 12718 itemref: 'itemRef', 12719 itemscope: 'itemScope', 12720 itemtype: 'itemType', 12721 keyparams: 'keyParams', 12722 keytype: 'keyType', 12723 kind: 'kind', 12724 label: 'label', 12725 lang: 'lang', 12726 list: 'list', 12727 loop: 'loop', 12728 low: 'low', 12729 manifest: 'manifest', 12730 marginwidth: 'marginWidth', 12731 marginheight: 'marginHeight', 12732 max: 'max', 12733 maxlength: 'maxLength', 12734 media: 'media', 12735 mediagroup: 'mediaGroup', 12736 method: 'method', 12737 min: 'min', 12738 minlength: 'minLength', 12739 multiple: 'multiple', 12740 muted: 'muted', 12741 name: 'name', 12742 nomodule: 'noModule', 12743 nonce: 'nonce', 12744 novalidate: 'noValidate', 12745 open: 'open', 12746 optimum: 'optimum', 12747 pattern: 'pattern', 12748 placeholder: 'placeholder', 12749 playsinline: 'playsInline', 12750 poster: 'poster', 12751 preload: 'preload', 12752 profile: 'profile', 12753 radiogroup: 'radioGroup', 12754 readonly: 'readOnly', 12755 referrerpolicy: 'referrerPolicy', 12756 rel: 'rel', 12757 required: 'required', 12758 reversed: 'reversed', 12759 role: 'role', 12760 rows: 'rows', 12761 rowspan: 'rowSpan', 12762 sandbox: 'sandbox', 12763 scope: 'scope', 12764 scoped: 'scoped', 12765 scrolling: 'scrolling', 12766 seamless: 'seamless', 12767 selected: 'selected', 12768 shape: 'shape', 12769 size: 'size', 12770 sizes: 'sizes', 12771 span: 'span', 12772 spellcheck: 'spellCheck', 12773 src: 'src', 12774 srcdoc: 'srcDoc', 12775 srclang: 'srcLang', 12776 srcset: 'srcSet', 12777 start: 'start', 12778 step: 'step', 12779 style: 'style', 12780 summary: 'summary', 12781 tabindex: 'tabIndex', 12782 target: 'target', 12783 title: 'title', 12784 type: 'type', 12785 usemap: 'useMap', 12786 value: 'value', 12787 width: 'width', 12788 wmode: 'wmode', 12789 wrap: 'wrap', 12790 // SVG 12791 about: 'about', 12792 accentheight: 'accentHeight', 12793 'accent-height': 'accentHeight', 12794 accumulate: 'accumulate', 12795 additive: 'additive', 12796 alignmentbaseline: 'alignmentBaseline', 12797 'alignment-baseline': 'alignmentBaseline', 12798 allowreorder: 'allowReorder', 12799 alphabetic: 'alphabetic', 12800 amplitude: 'amplitude', 12801 arabicform: 'arabicForm', 12802 'arabic-form': 'arabicForm', 12803 ascent: 'ascent', 12804 attributename: 'attributeName', 12805 attributetype: 'attributeType', 12806 autoreverse: 'autoReverse', 12807 azimuth: 'azimuth', 12808 basefrequency: 'baseFrequency', 12809 baselineshift: 'baselineShift', 12810 'baseline-shift': 'baselineShift', 12811 baseprofile: 'baseProfile', 12812 bbox: 'bbox', 12813 begin: 'begin', 12814 bias: 'bias', 12815 by: 'by', 12816 calcmode: 'calcMode', 12817 capheight: 'capHeight', 12818 'cap-height': 'capHeight', 12819 clip: 'clip', 12820 clippath: 'clipPath', 12821 'clip-path': 'clipPath', 12822 clippathunits: 'clipPathUnits', 12823 cliprule: 'clipRule', 12824 'clip-rule': 'clipRule', 12825 color: 'color', 12826 colorinterpolation: 'colorInterpolation', 12827 'color-interpolation': 'colorInterpolation', 12828 colorinterpolationfilters: 'colorInterpolationFilters', 12829 'color-interpolation-filters': 'colorInterpolationFilters', 12830 colorprofile: 'colorProfile', 12831 'color-profile': 'colorProfile', 12832 colorrendering: 'colorRendering', 12833 'color-rendering': 'colorRendering', 12834 contentscripttype: 'contentScriptType', 12835 contentstyletype: 'contentStyleType', 12836 cursor: 'cursor', 12837 cx: 'cx', 12838 cy: 'cy', 12839 d: 'd', 12840 datatype: 'datatype', 12841 decelerate: 'decelerate', 12842 descent: 'descent', 12843 diffuseconstant: 'diffuseConstant', 12844 direction: 'direction', 12845 display: 'display', 12846 divisor: 'divisor', 12847 dominantbaseline: 'dominantBaseline', 12848 'dominant-baseline': 'dominantBaseline', 12849 dur: 'dur', 12850 dx: 'dx', 12851 dy: 'dy', 12852 edgemode: 'edgeMode', 12853 elevation: 'elevation', 12854 enablebackground: 'enableBackground', 12855 'enable-background': 'enableBackground', 12856 end: 'end', 12857 exponent: 'exponent', 12858 externalresourcesrequired: 'externalResourcesRequired', 12859 fill: 'fill', 12860 fillopacity: 'fillOpacity', 12861 'fill-opacity': 'fillOpacity', 12862 fillrule: 'fillRule', 12863 'fill-rule': 'fillRule', 12864 filter: 'filter', 12865 filterres: 'filterRes', 12866 filterunits: 'filterUnits', 12867 floodopacity: 'floodOpacity', 12868 'flood-opacity': 'floodOpacity', 12869 floodcolor: 'floodColor', 12870 'flood-color': 'floodColor', 12871 focusable: 'focusable', 12872 fontfamily: 'fontFamily', 12873 'font-family': 'fontFamily', 12874 fontsize: 'fontSize', 12875 'font-size': 'fontSize', 12876 fontsizeadjust: 'fontSizeAdjust', 12877 'font-size-adjust': 'fontSizeAdjust', 12878 fontstretch: 'fontStretch', 12879 'font-stretch': 'fontStretch', 12880 fontstyle: 'fontStyle', 12881 'font-style': 'fontStyle', 12882 fontvariant: 'fontVariant', 12883 'font-variant': 'fontVariant', 12884 fontweight: 'fontWeight', 12885 'font-weight': 'fontWeight', 12886 format: 'format', 12887 from: 'from', 12888 fx: 'fx', 12889 fy: 'fy', 12890 g1: 'g1', 12891 g2: 'g2', 12892 glyphname: 'glyphName', 12893 'glyph-name': 'glyphName', 12894 glyphorientationhorizontal: 'glyphOrientationHorizontal', 12895 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 12896 glyphorientationvertical: 'glyphOrientationVertical', 12897 'glyph-orientation-vertical': 'glyphOrientationVertical', 12898 glyphref: 'glyphRef', 12899 gradienttransform: 'gradientTransform', 12900 gradientunits: 'gradientUnits', 12901 hanging: 'hanging', 12902 horizadvx: 'horizAdvX', 12903 'horiz-adv-x': 'horizAdvX', 12904 horizoriginx: 'horizOriginX', 12905 'horiz-origin-x': 'horizOriginX', 12906 ideographic: 'ideographic', 12907 imagerendering: 'imageRendering', 12908 'image-rendering': 'imageRendering', 12909 in2: 'in2', 12910 in: 'in', 12911 inlist: 'inlist', 12912 intercept: 'intercept', 12913 k1: 'k1', 12914 k2: 'k2', 12915 k3: 'k3', 12916 k4: 'k4', 12917 k: 'k', 12918 kernelmatrix: 'kernelMatrix', 12919 kernelunitlength: 'kernelUnitLength', 12920 kerning: 'kerning', 12921 keypoints: 'keyPoints', 12922 keysplines: 'keySplines', 12923 keytimes: 'keyTimes', 12924 lengthadjust: 'lengthAdjust', 12925 letterspacing: 'letterSpacing', 12926 'letter-spacing': 'letterSpacing', 12927 lightingcolor: 'lightingColor', 12928 'lighting-color': 'lightingColor', 12929 limitingconeangle: 'limitingConeAngle', 12930 local: 'local', 12931 markerend: 'markerEnd', 12932 'marker-end': 'markerEnd', 12933 markerheight: 'markerHeight', 12934 markermid: 'markerMid', 12935 'marker-mid': 'markerMid', 12936 markerstart: 'markerStart', 12937 'marker-start': 'markerStart', 12938 markerunits: 'markerUnits', 12939 markerwidth: 'markerWidth', 12940 mask: 'mask', 12941 maskcontentunits: 'maskContentUnits', 12942 maskunits: 'maskUnits', 12943 mathematical: 'mathematical', 12944 mode: 'mode', 12945 numoctaves: 'numOctaves', 12946 offset: 'offset', 12947 opacity: 'opacity', 12948 operator: 'operator', 12949 order: 'order', 12950 orient: 'orient', 12951 orientation: 'orientation', 12952 origin: 'origin', 12953 overflow: 'overflow', 12954 overlineposition: 'overlinePosition', 12955 'overline-position': 'overlinePosition', 12956 overlinethickness: 'overlineThickness', 12957 'overline-thickness': 'overlineThickness', 12958 paintorder: 'paintOrder', 12959 'paint-order': 'paintOrder', 12960 panose1: 'panose1', 12961 'panose-1': 'panose1', 12962 pathlength: 'pathLength', 12963 patterncontentunits: 'patternContentUnits', 12964 patterntransform: 'patternTransform', 12965 patternunits: 'patternUnits', 12966 pointerevents: 'pointerEvents', 12967 'pointer-events': 'pointerEvents', 12968 points: 'points', 12969 pointsatx: 'pointsAtX', 12970 pointsaty: 'pointsAtY', 12971 pointsatz: 'pointsAtZ', 12972 prefix: 'prefix', 12973 preservealpha: 'preserveAlpha', 12974 preserveaspectratio: 'preserveAspectRatio', 12975 primitiveunits: 'primitiveUnits', 12976 property: 'property', 12977 r: 'r', 12978 radius: 'radius', 12979 refx: 'refX', 12980 refy: 'refY', 12981 renderingintent: 'renderingIntent', 12982 'rendering-intent': 'renderingIntent', 12983 repeatcount: 'repeatCount', 12984 repeatdur: 'repeatDur', 12985 requiredextensions: 'requiredExtensions', 12986 requiredfeatures: 'requiredFeatures', 12987 resource: 'resource', 12988 restart: 'restart', 12989 result: 'result', 12990 results: 'results', 12991 rotate: 'rotate', 12992 rx: 'rx', 12993 ry: 'ry', 12994 scale: 'scale', 12995 security: 'security', 12996 seed: 'seed', 12997 shaperendering: 'shapeRendering', 12998 'shape-rendering': 'shapeRendering', 12999 slope: 'slope', 13000 spacing: 'spacing', 13001 specularconstant: 'specularConstant', 13002 specularexponent: 'specularExponent', 13003 speed: 'speed', 13004 spreadmethod: 'spreadMethod', 13005 startoffset: 'startOffset', 13006 stddeviation: 'stdDeviation', 13007 stemh: 'stemh', 13008 stemv: 'stemv', 13009 stitchtiles: 'stitchTiles', 13010 stopcolor: 'stopColor', 13011 'stop-color': 'stopColor', 13012 stopopacity: 'stopOpacity', 13013 'stop-opacity': 'stopOpacity', 13014 strikethroughposition: 'strikethroughPosition', 13015 'strikethrough-position': 'strikethroughPosition', 13016 strikethroughthickness: 'strikethroughThickness', 13017 'strikethrough-thickness': 'strikethroughThickness', 13018 string: 'string', 13019 stroke: 'stroke', 13020 strokedasharray: 'strokeDasharray', 13021 'stroke-dasharray': 'strokeDasharray', 13022 strokedashoffset: 'strokeDashoffset', 13023 'stroke-dashoffset': 'strokeDashoffset', 13024 strokelinecap: 'strokeLinecap', 13025 'stroke-linecap': 'strokeLinecap', 13026 strokelinejoin: 'strokeLinejoin', 13027 'stroke-linejoin': 'strokeLinejoin', 13028 strokemiterlimit: 'strokeMiterlimit', 13029 'stroke-miterlimit': 'strokeMiterlimit', 13030 strokewidth: 'strokeWidth', 13031 'stroke-width': 'strokeWidth', 13032 strokeopacity: 'strokeOpacity', 13033 'stroke-opacity': 'strokeOpacity', 13034 suppresscontenteditablewarning: 'suppressContentEditableWarning', 13035 suppresshydrationwarning: 'suppressHydrationWarning', 13036 surfacescale: 'surfaceScale', 13037 systemlanguage: 'systemLanguage', 13038 tablevalues: 'tableValues', 13039 targetx: 'targetX', 13040 targety: 'targetY', 13041 textanchor: 'textAnchor', 13042 'text-anchor': 'textAnchor', 13043 textdecoration: 'textDecoration', 13044 'text-decoration': 'textDecoration', 13045 textlength: 'textLength', 13046 textrendering: 'textRendering', 13047 'text-rendering': 'textRendering', 13048 to: 'to', 13049 transform: 'transform', 13050 typeof: 'typeof', 13051 u1: 'u1', 13052 u2: 'u2', 13053 underlineposition: 'underlinePosition', 13054 'underline-position': 'underlinePosition', 13055 underlinethickness: 'underlineThickness', 13056 'underline-thickness': 'underlineThickness', 13057 unicode: 'unicode', 13058 unicodebidi: 'unicodeBidi', 13059 'unicode-bidi': 'unicodeBidi', 13060 unicoderange: 'unicodeRange', 13061 'unicode-range': 'unicodeRange', 13062 unitsperem: 'unitsPerEm', 13063 'units-per-em': 'unitsPerEm', 13064 unselectable: 'unselectable', 13065 valphabetic: 'vAlphabetic', 13066 'v-alphabetic': 'vAlphabetic', 13067 values: 'values', 13068 vectoreffect: 'vectorEffect', 13069 'vector-effect': 'vectorEffect', 13070 version: 'version', 13071 vertadvy: 'vertAdvY', 13072 'vert-adv-y': 'vertAdvY', 13073 vertoriginx: 'vertOriginX', 13074 'vert-origin-x': 'vertOriginX', 13075 vertoriginy: 'vertOriginY', 13076 'vert-origin-y': 'vertOriginY', 13077 vhanging: 'vHanging', 13078 'v-hanging': 'vHanging', 13079 videographic: 'vIdeographic', 13080 'v-ideographic': 'vIdeographic', 13081 viewbox: 'viewBox', 13082 viewtarget: 'viewTarget', 13083 visibility: 'visibility', 13084 vmathematical: 'vMathematical', 13085 'v-mathematical': 'vMathematical', 13086 vocab: 'vocab', 13087 widths: 'widths', 13088 wordspacing: 'wordSpacing', 13089 'word-spacing': 'wordSpacing', 13090 writingmode: 'writingMode', 13091 'writing-mode': 'writingMode', 13092 x1: 'x1', 13093 x2: 'x2', 13094 x: 'x', 13095 xchannelselector: 'xChannelSelector', 13096 xheight: 'xHeight', 13097 'x-height': 'xHeight', 13098 xlinkactuate: 'xlinkActuate', 13099 'xlink:actuate': 'xlinkActuate', 13100 xlinkarcrole: 'xlinkArcrole', 13101 'xlink:arcrole': 'xlinkArcrole', 13102 xlinkhref: 'xlinkHref', 13103 'xlink:href': 'xlinkHref', 13104 xlinkrole: 'xlinkRole', 13105 'xlink:role': 'xlinkRole', 13106 xlinkshow: 'xlinkShow', 13107 'xlink:show': 'xlinkShow', 13108 xlinktitle: 'xlinkTitle', 13109 'xlink:title': 'xlinkTitle', 13110 xlinktype: 'xlinkType', 13111 'xlink:type': 'xlinkType', 13112 xmlbase: 'xmlBase', 13113 'xml:base': 'xmlBase', 13114 xmllang: 'xmlLang', 13115 'xml:lang': 'xmlLang', 13116 xmlns: 'xmlns', 13117 'xml:space': 'xmlSpace', 13118 xmlnsxlink: 'xmlnsXlink', 13119 'xmlns:xlink': 'xmlnsXlink', 13120 xmlspace: 'xmlSpace', 13121 y1: 'y1', 13122 y2: 'y2', 13123 y: 'y', 13124 ychannelselector: 'yChannelSelector', 13125 z: 'z', 13126 zoomandpan: 'zoomAndPan' 13127}; 13128 13129var ariaProperties = { 13130 'aria-current': 0, 13131 // state 13132 'aria-details': 0, 13133 'aria-disabled': 0, 13134 // state 13135 'aria-hidden': 0, 13136 // state 13137 'aria-invalid': 0, 13138 // state 13139 'aria-keyshortcuts': 0, 13140 'aria-label': 0, 13141 'aria-roledescription': 0, 13142 // Widget Attributes 13143 'aria-autocomplete': 0, 13144 'aria-checked': 0, 13145 'aria-expanded': 0, 13146 'aria-haspopup': 0, 13147 'aria-level': 0, 13148 'aria-modal': 0, 13149 'aria-multiline': 0, 13150 'aria-multiselectable': 0, 13151 'aria-orientation': 0, 13152 'aria-placeholder': 0, 13153 'aria-pressed': 0, 13154 'aria-readonly': 0, 13155 'aria-required': 0, 13156 'aria-selected': 0, 13157 'aria-sort': 0, 13158 'aria-valuemax': 0, 13159 'aria-valuemin': 0, 13160 'aria-valuenow': 0, 13161 'aria-valuetext': 0, 13162 // Live Region Attributes 13163 'aria-atomic': 0, 13164 'aria-busy': 0, 13165 'aria-live': 0, 13166 'aria-relevant': 0, 13167 // Drag-and-Drop Attributes 13168 'aria-dropeffect': 0, 13169 'aria-grabbed': 0, 13170 // Relationship Attributes 13171 'aria-activedescendant': 0, 13172 'aria-colcount': 0, 13173 'aria-colindex': 0, 13174 'aria-colspan': 0, 13175 'aria-controls': 0, 13176 'aria-describedby': 0, 13177 'aria-errormessage': 0, 13178 'aria-flowto': 0, 13179 'aria-labelledby': 0, 13180 'aria-owns': 0, 13181 'aria-posinset': 0, 13182 'aria-rowcount': 0, 13183 'aria-rowindex': 0, 13184 'aria-rowspan': 0, 13185 'aria-setsize': 0 13186}; 13187 13188var warnedProperties = {}; 13189var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 13190var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 13191var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 13192 13193function validateProperty(tagName, name) { 13194 { 13195 if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { 13196 return true; 13197 } 13198 13199 if (rARIACamel.test(name)) { 13200 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 13201 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM 13202 // DOM properties, then it is an invalid aria-* attribute. 13203 13204 if (correctName == null) { 13205 error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); 13206 13207 warnedProperties[name] = true; 13208 return true; 13209 } // aria-* attributes should be lowercase; suggest the lowercase version. 13210 13211 13212 if (name !== correctName) { 13213 error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); 13214 13215 warnedProperties[name] = true; 13216 return true; 13217 } 13218 } 13219 13220 if (rARIA.test(name)) { 13221 var lowerCasedName = name.toLowerCase(); 13222 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM 13223 // DOM properties, then it is an invalid aria-* attribute. 13224 13225 if (standardName == null) { 13226 warnedProperties[name] = true; 13227 return false; 13228 } // aria-* attributes should be lowercase; suggest the lowercase version. 13229 13230 13231 if (name !== standardName) { 13232 error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); 13233 13234 warnedProperties[name] = true; 13235 return true; 13236 } 13237 } 13238 } 13239 13240 return true; 13241} 13242 13243function warnInvalidARIAProps(type, props) { 13244 { 13245 var invalidProps = []; 13246 13247 for (var key in props) { 13248 var isValid = validateProperty(type, key); 13249 13250 if (!isValid) { 13251 invalidProps.push(key); 13252 } 13253 } 13254 13255 var unknownPropString = invalidProps.map(function (prop) { 13256 return '`' + prop + '`'; 13257 }).join(', '); 13258 13259 if (invalidProps.length === 1) { 13260 error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); 13261 } else if (invalidProps.length > 1) { 13262 error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); 13263 } 13264 } 13265} 13266 13267function validateProperties(type, props) { 13268 if (isCustomComponent(type, props)) { 13269 return; 13270 } 13271 13272 warnInvalidARIAProps(type, props); 13273} 13274 13275var didWarnValueNull = false; 13276function validateProperties$1(type, props) { 13277 { 13278 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 13279 return; 13280 } 13281 13282 if (props != null && props.value === null && !didWarnValueNull) { 13283 didWarnValueNull = true; 13284 13285 if (type === 'select' && props.multiple) { 13286 error('`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.', type); 13287 } else { 13288 error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); 13289 } 13290 } 13291 } 13292} 13293 13294var validateProperty$1 = function () {}; 13295 13296{ 13297 var warnedProperties$1 = {}; 13298 var _hasOwnProperty = Object.prototype.hasOwnProperty; 13299 var EVENT_NAME_REGEX = /^on./; 13300 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 13301 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 13302 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 13303 13304 validateProperty$1 = function (tagName, name, value, canUseEventSystem) { 13305 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { 13306 return true; 13307 } 13308 13309 var lowerCasedName = name.toLowerCase(); 13310 13311 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 13312 error('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.'); 13313 13314 warnedProperties$1[name] = true; 13315 return true; 13316 } // We can't rely on the event system being injected on the server. 13317 13318 13319 if (canUseEventSystem) { 13320 if (registrationNameModules.hasOwnProperty(name)) { 13321 return true; 13322 } 13323 13324 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 13325 13326 if (registrationName != null) { 13327 error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); 13328 13329 warnedProperties$1[name] = true; 13330 return true; 13331 } 13332 13333 if (EVENT_NAME_REGEX.test(name)) { 13334 error('Unknown event handler property `%s`. It will be ignored.', name); 13335 13336 warnedProperties$1[name] = true; 13337 return true; 13338 } 13339 } else if (EVENT_NAME_REGEX.test(name)) { 13340 // If no event plugins have been injected, we are in a server environment. 13341 // So we can't tell if the event name is correct for sure, but we can filter 13342 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 13343 if (INVALID_EVENT_NAME_REGEX.test(name)) { 13344 error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); 13345 } 13346 13347 warnedProperties$1[name] = true; 13348 return true; 13349 } // Let the ARIA attribute hook validate ARIA attributes 13350 13351 13352 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 13353 return true; 13354 } 13355 13356 if (lowerCasedName === 'innerhtml') { 13357 error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 13358 13359 warnedProperties$1[name] = true; 13360 return true; 13361 } 13362 13363 if (lowerCasedName === 'aria') { 13364 error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 13365 13366 warnedProperties$1[name] = true; 13367 return true; 13368 } 13369 13370 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 13371 error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); 13372 13373 warnedProperties$1[name] = true; 13374 return true; 13375 } 13376 13377 if (typeof value === 'number' && isNaN(value)) { 13378 error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); 13379 13380 warnedProperties$1[name] = true; 13381 return true; 13382 } 13383 13384 var propertyInfo = getPropertyInfo(name); 13385 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. 13386 13387 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 13388 var standardName = possibleStandardNames[lowerCasedName]; 13389 13390 if (standardName !== name) { 13391 error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); 13392 13393 warnedProperties$1[name] = true; 13394 return true; 13395 } 13396 } else if (!isReserved && name !== lowerCasedName) { 13397 // Unknown attributes should have lowercase casing since that's how they 13398 // will be cased anyway with server rendering. 13399 error('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.', name, lowerCasedName); 13400 13401 warnedProperties$1[name] = true; 13402 return true; 13403 } 13404 13405 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 13406 if (value) { 13407 error('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()}.', value, name, name, value, name); 13408 } else { 13409 error('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.', value, name, name, value, name, name, name); 13410 } 13411 13412 warnedProperties$1[name] = true; 13413 return true; 13414 } // Now that we've validated casing, do not validate 13415 // data types for reserved props 13416 13417 13418 if (isReserved) { 13419 return true; 13420 } // Warn when a known attribute is a bad type 13421 13422 13423 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 13424 warnedProperties$1[name] = true; 13425 return false; 13426 } // Warn when passing the strings 'false' or 'true' into a boolean prop 13427 13428 13429 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { 13430 error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value); 13431 13432 warnedProperties$1[name] = true; 13433 return true; 13434 } 13435 13436 return true; 13437 }; 13438} 13439 13440var warnUnknownProperties = function (type, props, canUseEventSystem) { 13441 { 13442 var unknownProps = []; 13443 13444 for (var key in props) { 13445 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem); 13446 13447 if (!isValid) { 13448 unknownProps.push(key); 13449 } 13450 } 13451 13452 var unknownPropString = unknownProps.map(function (prop) { 13453 return '`' + prop + '`'; 13454 }).join(', '); 13455 13456 if (unknownProps.length === 1) { 13457 error('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', unknownPropString, type); 13458 } else if (unknownProps.length > 1) { 13459 error('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', unknownPropString, type); 13460 } 13461 } 13462}; 13463 13464function validateProperties$2(type, props, canUseEventSystem) { 13465 if (isCustomComponent(type, props)) { 13466 return; 13467 } 13468 13469 warnUnknownProperties(type, props, canUseEventSystem); 13470} 13471 13472var didWarnInvalidHydration = false; 13473var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 13474var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 13475var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 13476var AUTOFOCUS = 'autoFocus'; 13477var CHILDREN = 'children'; 13478var STYLE = 'style'; 13479var HTML$1 = '__html'; 13480var HTML_NAMESPACE$1 = Namespaces.html; 13481var warnedUnknownTags; 13482var suppressHydrationWarning; 13483var validatePropertiesInDevelopment; 13484var warnForTextDifference; 13485var warnForPropDifference; 13486var warnForExtraAttributes; 13487var warnForInvalidEventListener; 13488var canDiffStyleForHydrationWarning; 13489var normalizeMarkupForTextOrAttribute; 13490var normalizeHTML; 13491 13492{ 13493 warnedUnknownTags = { 13494 // Chrome is the only major browser not shipping <time>. But as of July 13495 // 2017 it intends to ship it due to widespread usage. We intentionally 13496 // *don't* warn for <time> even if it's unrecognized by Chrome because 13497 // it soon will be, and many apps have been using it anyway. 13498 time: true, 13499 // There are working polyfills for <dialog>. Let people use it. 13500 dialog: true, 13501 // Electron ships a custom <webview> tag to display external web content in 13502 // an isolated frame and process. 13503 // This tag is not present in non Electron environments such as JSDom which 13504 // is often used for testing purposes. 13505 // @see https://electronjs.org/docs/api/webview-tag 13506 webview: true 13507 }; 13508 13509 validatePropertiesInDevelopment = function (type, props) { 13510 validateProperties(type, props); 13511 validateProperties$1(type, props); 13512 validateProperties$2(type, props, 13513 /* canUseEventSystem */ 13514 true); 13515 }; // IE 11 parses & normalizes the style attribute as opposed to other 13516 // browsers. It adds spaces and sorts the properties in some 13517 // non-alphabetical order. Handling that would require sorting CSS 13518 // properties in the client & server versions or applying 13519 // `expectedStyle` to a temporary DOM node to read its `style` attribute 13520 // normalized. Since it only affects IE, we're skipping style warnings 13521 // in that browser completely in favor of doing all that work. 13522 // See https://github.com/facebook/react/issues/11807 13523 13524 13525 canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. 13526 // It also can turn \u0000 into \uFFFD inside attributes. 13527 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 13528 // If we have a mismatch, it might be caused by that. 13529 // We will still patch up in this case but not fire the warning. 13530 13531 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 13532 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 13533 13534 normalizeMarkupForTextOrAttribute = function (markup) { 13535 var markupString = typeof markup === 'string' ? markup : '' + markup; 13536 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 13537 }; 13538 13539 warnForTextDifference = function (serverText, clientText) { 13540 if (didWarnInvalidHydration) { 13541 return; 13542 } 13543 13544 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 13545 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 13546 13547 if (normalizedServerText === normalizedClientText) { 13548 return; 13549 } 13550 13551 didWarnInvalidHydration = true; 13552 13553 error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 13554 }; 13555 13556 warnForPropDifference = function (propName, serverValue, clientValue) { 13557 if (didWarnInvalidHydration) { 13558 return; 13559 } 13560 13561 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 13562 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 13563 13564 if (normalizedServerValue === normalizedClientValue) { 13565 return; 13566 } 13567 13568 didWarnInvalidHydration = true; 13569 13570 error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 13571 }; 13572 13573 warnForExtraAttributes = function (attributeNames) { 13574 if (didWarnInvalidHydration) { 13575 return; 13576 } 13577 13578 didWarnInvalidHydration = true; 13579 var names = []; 13580 attributeNames.forEach(function (name) { 13581 names.push(name); 13582 }); 13583 13584 error('Extra attributes from the server: %s', names); 13585 }; 13586 13587 warnForInvalidEventListener = function (registrationName, listener) { 13588 if (listener === false) { 13589 error('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.', registrationName, registrationName, registrationName); 13590 } else { 13591 error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); 13592 } 13593 }; // Parse the HTML and read it back to normalize the HTML string so that it 13594 // can be used for comparison. 13595 13596 13597 normalizeHTML = function (parent, html) { 13598 // We could have created a separate document here to avoid 13599 // re-initializing custom elements if they exist. But this breaks 13600 // how <noscript> is being handled. So we use the same document. 13601 // See the discussion in https://github.com/facebook/react/pull/11157. 13602 var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 13603 testElement.innerHTML = html; 13604 return testElement.innerHTML; 13605 }; 13606} 13607 13608function ensureListeningTo(rootContainerElement, registrationName) { 13609 var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE; 13610 var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument; 13611 legacyListenToEvent(registrationName, doc); 13612} 13613 13614function getOwnerDocumentFromRootContainer(rootContainerElement) { 13615 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 13616} 13617 13618function noop() {} 13619 13620function trapClickOnNonInteractiveElement(node) { 13621 // Mobile Safari does not fire properly bubble click events on 13622 // non-interactive elements, which means delegated click listeners do not 13623 // fire. The workaround for this bug involves attaching an empty click 13624 // listener on the target node. 13625 // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 13626 // Just set it using the onclick property so that we don't have to manage any 13627 // bookkeeping for it. Not sure if we need to clear it when the listener is 13628 // removed. 13629 // TODO: Only do this for the relevant Safaris maybe? 13630 node.onclick = noop; 13631} 13632 13633function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 13634 for (var propKey in nextProps) { 13635 if (!nextProps.hasOwnProperty(propKey)) { 13636 continue; 13637 } 13638 13639 var nextProp = nextProps[propKey]; 13640 13641 if (propKey === STYLE) { 13642 { 13643 if (nextProp) { 13644 // Freeze the next style object so that we can assume it won't be 13645 // mutated. We have already warned for this in the past. 13646 Object.freeze(nextProp); 13647 } 13648 } // Relies on `updateStylesByID` not mutating `styleUpdates`. 13649 13650 13651 setValueForStyles(domElement, nextProp); 13652 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 13653 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 13654 13655 if (nextHtml != null) { 13656 setInnerHTML(domElement, nextHtml); 13657 } 13658 } else if (propKey === CHILDREN) { 13659 if (typeof nextProp === 'string') { 13660 // Avoid setting initial textContent when the text is empty. In IE11 setting 13661 // textContent on a <textarea> will cause the placeholder to not 13662 // show within the <textarea> until it has been focused and blurred again. 13663 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 13664 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 13665 13666 if (canSetTextContent) { 13667 setTextContent(domElement, nextProp); 13668 } 13669 } else if (typeof nextProp === 'number') { 13670 setTextContent(domElement, '' + nextProp); 13671 } 13672 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 13673 if (nextProp != null) { 13674 if ( typeof nextProp !== 'function') { 13675 warnForInvalidEventListener(propKey, nextProp); 13676 } 13677 13678 ensureListeningTo(rootContainerElement, propKey); 13679 } 13680 } else if (nextProp != null) { 13681 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); 13682 } 13683 } 13684} 13685 13686function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 13687 // TODO: Handle wasCustomComponentTag 13688 for (var i = 0; i < updatePayload.length; i += 2) { 13689 var propKey = updatePayload[i]; 13690 var propValue = updatePayload[i + 1]; 13691 13692 if (propKey === STYLE) { 13693 setValueForStyles(domElement, propValue); 13694 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 13695 setInnerHTML(domElement, propValue); 13696 } else if (propKey === CHILDREN) { 13697 setTextContent(domElement, propValue); 13698 } else { 13699 setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); 13700 } 13701 } 13702} 13703 13704function createElement(type, props, rootContainerElement, parentNamespace) { 13705 var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML 13706 // tags get no namespace. 13707 13708 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 13709 var domElement; 13710 var namespaceURI = parentNamespace; 13711 13712 if (namespaceURI === HTML_NAMESPACE$1) { 13713 namespaceURI = getIntrinsicNamespace(type); 13714 } 13715 13716 if (namespaceURI === HTML_NAMESPACE$1) { 13717 { 13718 isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to 13719 // allow <SVG> or <mATH>. 13720 13721 if (!isCustomComponentTag && type !== type.toLowerCase()) { 13722 error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); 13723 } 13724 } 13725 13726 if (type === 'script') { 13727 // Create the script via .innerHTML so its "parser-inserted" flag is 13728 // set to true and it does not execute 13729 var div = ownerDocument.createElement('div'); 13730 13731 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 13732 // This is guaranteed to yield a script element. 13733 13734 var firstChild = div.firstChild; 13735 domElement = div.removeChild(firstChild); 13736 } else if (typeof props.is === 'string') { 13737 // $FlowIssue `createElement` should be updated for Web Components 13738 domElement = ownerDocument.createElement(type, { 13739 is: props.is 13740 }); 13741 } else { 13742 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 13743 // See discussion in https://github.com/facebook/react/pull/6896 13744 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 13745 domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` 13746 // attributes on `select`s needs to be added before `option`s are inserted. 13747 // This prevents: 13748 // - a bug where the `select` does not scroll to the correct option because singular 13749 // `select` elements automatically pick the first item #13222 13750 // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 13751 // See https://github.com/facebook/react/issues/13222 13752 // and https://github.com/facebook/react/issues/14239 13753 13754 if (type === 'select') { 13755 var node = domElement; 13756 13757 if (props.multiple) { 13758 node.multiple = true; 13759 } else if (props.size) { 13760 // Setting a size greater than 1 causes a select to behave like `multiple=true`, where 13761 // it is possible that no option is selected. 13762 // 13763 // This is only necessary when a select in "single selection mode". 13764 node.size = props.size; 13765 } 13766 } 13767 } 13768 } else { 13769 domElement = ownerDocument.createElementNS(namespaceURI, type); 13770 } 13771 13772 { 13773 if (namespaceURI === HTML_NAMESPACE$1) { 13774 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 13775 warnedUnknownTags[type] = true; 13776 13777 error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); 13778 } 13779 } 13780 } 13781 13782 return domElement; 13783} 13784function createTextNode(text, rootContainerElement) { 13785 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 13786} 13787function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { 13788 var isCustomComponentTag = isCustomComponent(tag, rawProps); 13789 13790 { 13791 validatePropertiesInDevelopment(tag, rawProps); 13792 } // TODO: Make sure that we check isMounted before firing any of these events. 13793 13794 13795 var props; 13796 13797 switch (tag) { 13798 case 'iframe': 13799 case 'object': 13800 case 'embed': 13801 trapBubbledEvent(TOP_LOAD, domElement); 13802 props = rawProps; 13803 break; 13804 13805 case 'video': 13806 case 'audio': 13807 // Create listener for each media event 13808 for (var i = 0; i < mediaEventTypes.length; i++) { 13809 trapBubbledEvent(mediaEventTypes[i], domElement); 13810 } 13811 13812 props = rawProps; 13813 break; 13814 13815 case 'source': 13816 trapBubbledEvent(TOP_ERROR, domElement); 13817 props = rawProps; 13818 break; 13819 13820 case 'img': 13821 case 'image': 13822 case 'link': 13823 trapBubbledEvent(TOP_ERROR, domElement); 13824 trapBubbledEvent(TOP_LOAD, domElement); 13825 props = rawProps; 13826 break; 13827 13828 case 'form': 13829 trapBubbledEvent(TOP_RESET, domElement); 13830 trapBubbledEvent(TOP_SUBMIT, domElement); 13831 props = rawProps; 13832 break; 13833 13834 case 'details': 13835 trapBubbledEvent(TOP_TOGGLE, domElement); 13836 props = rawProps; 13837 break; 13838 13839 case 'input': 13840 initWrapperState(domElement, rawProps); 13841 props = getHostProps(domElement, rawProps); 13842 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 13843 // to onChange. Even if there is no listener. 13844 13845 ensureListeningTo(rootContainerElement, 'onChange'); 13846 break; 13847 13848 case 'option': 13849 validateProps(domElement, rawProps); 13850 props = getHostProps$1(domElement, rawProps); 13851 break; 13852 13853 case 'select': 13854 initWrapperState$1(domElement, rawProps); 13855 props = getHostProps$2(domElement, rawProps); 13856 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 13857 // to onChange. Even if there is no listener. 13858 13859 ensureListeningTo(rootContainerElement, 'onChange'); 13860 break; 13861 13862 case 'textarea': 13863 initWrapperState$2(domElement, rawProps); 13864 props = getHostProps$3(domElement, rawProps); 13865 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 13866 // to onChange. Even if there is no listener. 13867 13868 ensureListeningTo(rootContainerElement, 'onChange'); 13869 break; 13870 13871 default: 13872 props = rawProps; 13873 } 13874 13875 assertValidProps(tag, props); 13876 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 13877 13878 switch (tag) { 13879 case 'input': 13880 // TODO: Make sure we check if this is still unmounted or do any clean 13881 // up necessary since we never stop tracking anymore. 13882 track(domElement); 13883 postMountWrapper(domElement, rawProps, false); 13884 break; 13885 13886 case 'textarea': 13887 // TODO: Make sure we check if this is still unmounted or do any clean 13888 // up necessary since we never stop tracking anymore. 13889 track(domElement); 13890 postMountWrapper$3(domElement); 13891 break; 13892 13893 case 'option': 13894 postMountWrapper$1(domElement, rawProps); 13895 break; 13896 13897 case 'select': 13898 postMountWrapper$2(domElement, rawProps); 13899 break; 13900 13901 default: 13902 if (typeof props.onClick === 'function') { 13903 // TODO: This cast may not be sound for SVG, MathML or custom elements. 13904 trapClickOnNonInteractiveElement(domElement); 13905 } 13906 13907 break; 13908 } 13909} // Calculate the diff between the two objects. 13910 13911function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 13912 { 13913 validatePropertiesInDevelopment(tag, nextRawProps); 13914 } 13915 13916 var updatePayload = null; 13917 var lastProps; 13918 var nextProps; 13919 13920 switch (tag) { 13921 case 'input': 13922 lastProps = getHostProps(domElement, lastRawProps); 13923 nextProps = getHostProps(domElement, nextRawProps); 13924 updatePayload = []; 13925 break; 13926 13927 case 'option': 13928 lastProps = getHostProps$1(domElement, lastRawProps); 13929 nextProps = getHostProps$1(domElement, nextRawProps); 13930 updatePayload = []; 13931 break; 13932 13933 case 'select': 13934 lastProps = getHostProps$2(domElement, lastRawProps); 13935 nextProps = getHostProps$2(domElement, nextRawProps); 13936 updatePayload = []; 13937 break; 13938 13939 case 'textarea': 13940 lastProps = getHostProps$3(domElement, lastRawProps); 13941 nextProps = getHostProps$3(domElement, nextRawProps); 13942 updatePayload = []; 13943 break; 13944 13945 default: 13946 lastProps = lastRawProps; 13947 nextProps = nextRawProps; 13948 13949 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 13950 // TODO: This cast may not be sound for SVG, MathML or custom elements. 13951 trapClickOnNonInteractiveElement(domElement); 13952 } 13953 13954 break; 13955 } 13956 13957 assertValidProps(tag, nextProps); 13958 var propKey; 13959 var styleName; 13960 var styleUpdates = null; 13961 13962 for (propKey in lastProps) { 13963 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 13964 continue; 13965 } 13966 13967 if (propKey === STYLE) { 13968 var lastStyle = lastProps[propKey]; 13969 13970 for (styleName in lastStyle) { 13971 if (lastStyle.hasOwnProperty(styleName)) { 13972 if (!styleUpdates) { 13973 styleUpdates = {}; 13974 } 13975 13976 styleUpdates[styleName] = ''; 13977 } 13978 } 13979 } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 13980 // This is a special case. If any listener updates we need to ensure 13981 // that the "current" fiber pointer gets updated so we need a commit 13982 // to update this element. 13983 if (!updatePayload) { 13984 updatePayload = []; 13985 } 13986 } else { 13987 // For all other deleted properties we add it to the queue. We use 13988 // the whitelist in the commit phase instead. 13989 (updatePayload = updatePayload || []).push(propKey, null); 13990 } 13991 } 13992 13993 for (propKey in nextProps) { 13994 var nextProp = nextProps[propKey]; 13995 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 13996 13997 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 13998 continue; 13999 } 14000 14001 if (propKey === STYLE) { 14002 { 14003 if (nextProp) { 14004 // Freeze the next style object so that we can assume it won't be 14005 // mutated. We have already warned for this in the past. 14006 Object.freeze(nextProp); 14007 } 14008 } 14009 14010 if (lastProp) { 14011 // Unset styles on `lastProp` but not on `nextProp`. 14012 for (styleName in lastProp) { 14013 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 14014 if (!styleUpdates) { 14015 styleUpdates = {}; 14016 } 14017 14018 styleUpdates[styleName] = ''; 14019 } 14020 } // Update styles that changed since `lastProp`. 14021 14022 14023 for (styleName in nextProp) { 14024 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 14025 if (!styleUpdates) { 14026 styleUpdates = {}; 14027 } 14028 14029 styleUpdates[styleName] = nextProp[styleName]; 14030 } 14031 } 14032 } else { 14033 // Relies on `updateStylesByID` not mutating `styleUpdates`. 14034 if (!styleUpdates) { 14035 if (!updatePayload) { 14036 updatePayload = []; 14037 } 14038 14039 updatePayload.push(propKey, styleUpdates); 14040 } 14041 14042 styleUpdates = nextProp; 14043 } 14044 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 14045 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 14046 var lastHtml = lastProp ? lastProp[HTML$1] : undefined; 14047 14048 if (nextHtml != null) { 14049 if (lastHtml !== nextHtml) { 14050 (updatePayload = updatePayload || []).push(propKey, nextHtml); 14051 } 14052 } 14053 } else if (propKey === CHILDREN) { 14054 if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { 14055 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 14056 } 14057 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 14058 if (nextProp != null) { 14059 // We eagerly listen to this even though we haven't committed yet. 14060 if ( typeof nextProp !== 'function') { 14061 warnForInvalidEventListener(propKey, nextProp); 14062 } 14063 14064 ensureListeningTo(rootContainerElement, propKey); 14065 } 14066 14067 if (!updatePayload && lastProp !== nextProp) { 14068 // This is a special case. If any listener updates we need to ensure 14069 // that the "current" props pointer gets updated so we need a commit 14070 // to update this element. 14071 updatePayload = []; 14072 } 14073 } else { 14074 // For any other property we always add it to the queue and then we 14075 // filter it out using the whitelist during the commit. 14076 (updatePayload = updatePayload || []).push(propKey, nextProp); 14077 } 14078 } 14079 14080 if (styleUpdates) { 14081 { 14082 validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); 14083 } 14084 14085 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 14086 } 14087 14088 return updatePayload; 14089} // Apply the diff. 14090 14091function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 14092 // Update checked *before* name. 14093 // In the middle of an update, it is possible to have multiple checked. 14094 // When a checked radio tries to change name, browser makes another radio's checked false. 14095 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 14096 updateChecked(domElement, nextRawProps); 14097 } 14098 14099 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 14100 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. 14101 14102 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props 14103 // changed. 14104 14105 switch (tag) { 14106 case 'input': 14107 // Update the wrapper around inputs *after* updating props. This has to 14108 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 14109 // raise warnings and prevent the new value from being assigned. 14110 updateWrapper(domElement, nextRawProps); 14111 break; 14112 14113 case 'textarea': 14114 updateWrapper$1(domElement, nextRawProps); 14115 break; 14116 14117 case 'select': 14118 // <select> value update needs to occur after <option> children 14119 // reconciliation 14120 postUpdateWrapper(domElement, nextRawProps); 14121 break; 14122 } 14123} 14124 14125function getPossibleStandardName(propName) { 14126 { 14127 var lowerCasedName = propName.toLowerCase(); 14128 14129 if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { 14130 return null; 14131 } 14132 14133 return possibleStandardNames[lowerCasedName] || null; 14134 } 14135} 14136 14137function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 14138 var isCustomComponentTag; 14139 var extraAttributeNames; 14140 14141 { 14142 suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; 14143 isCustomComponentTag = isCustomComponent(tag, rawProps); 14144 validatePropertiesInDevelopment(tag, rawProps); 14145 } // TODO: Make sure that we check isMounted before firing any of these events. 14146 14147 14148 switch (tag) { 14149 case 'iframe': 14150 case 'object': 14151 case 'embed': 14152 trapBubbledEvent(TOP_LOAD, domElement); 14153 break; 14154 14155 case 'video': 14156 case 'audio': 14157 // Create listener for each media event 14158 for (var i = 0; i < mediaEventTypes.length; i++) { 14159 trapBubbledEvent(mediaEventTypes[i], domElement); 14160 } 14161 14162 break; 14163 14164 case 'source': 14165 trapBubbledEvent(TOP_ERROR, domElement); 14166 break; 14167 14168 case 'img': 14169 case 'image': 14170 case 'link': 14171 trapBubbledEvent(TOP_ERROR, domElement); 14172 trapBubbledEvent(TOP_LOAD, domElement); 14173 break; 14174 14175 case 'form': 14176 trapBubbledEvent(TOP_RESET, domElement); 14177 trapBubbledEvent(TOP_SUBMIT, domElement); 14178 break; 14179 14180 case 'details': 14181 trapBubbledEvent(TOP_TOGGLE, domElement); 14182 break; 14183 14184 case 'input': 14185 initWrapperState(domElement, rawProps); 14186 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 14187 // to onChange. Even if there is no listener. 14188 14189 ensureListeningTo(rootContainerElement, 'onChange'); 14190 break; 14191 14192 case 'option': 14193 validateProps(domElement, rawProps); 14194 break; 14195 14196 case 'select': 14197 initWrapperState$1(domElement, rawProps); 14198 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 14199 // to onChange. Even if there is no listener. 14200 14201 ensureListeningTo(rootContainerElement, 'onChange'); 14202 break; 14203 14204 case 'textarea': 14205 initWrapperState$2(domElement, rawProps); 14206 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 14207 // to onChange. Even if there is no listener. 14208 14209 ensureListeningTo(rootContainerElement, 'onChange'); 14210 break; 14211 } 14212 14213 assertValidProps(tag, rawProps); 14214 14215 { 14216 extraAttributeNames = new Set(); 14217 var attributes = domElement.attributes; 14218 14219 for (var _i = 0; _i < attributes.length; _i++) { 14220 var name = attributes[_i].name.toLowerCase(); 14221 14222 switch (name) { 14223 // Built-in SSR attribute is whitelisted 14224 case 'data-reactroot': 14225 break; 14226 // Controlled attributes are not validated 14227 // TODO: Only ignore them on controlled tags. 14228 14229 case 'value': 14230 break; 14231 14232 case 'checked': 14233 break; 14234 14235 case 'selected': 14236 break; 14237 14238 default: 14239 // Intentionally use the original name. 14240 // See discussion in https://github.com/facebook/react/pull/10676. 14241 extraAttributeNames.add(attributes[_i].name); 14242 } 14243 } 14244 } 14245 14246 var updatePayload = null; 14247 14248 for (var propKey in rawProps) { 14249 if (!rawProps.hasOwnProperty(propKey)) { 14250 continue; 14251 } 14252 14253 var nextProp = rawProps[propKey]; 14254 14255 if (propKey === CHILDREN) { 14256 // For text content children we compare against textContent. This 14257 // might match additional HTML that is hidden when we read it using 14258 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 14259 // satisfies our requirement. Our requirement is not to produce perfect 14260 // HTML and attributes. Ideally we should preserve structure but it's 14261 // ok not to if the visible content is still enough to indicate what 14262 // even listeners these nodes might be wired up to. 14263 // TODO: Warn if there is more than a single textNode as a child. 14264 // TODO: Should we use domElement.firstChild.nodeValue to compare? 14265 if (typeof nextProp === 'string') { 14266 if (domElement.textContent !== nextProp) { 14267 if ( !suppressHydrationWarning) { 14268 warnForTextDifference(domElement.textContent, nextProp); 14269 } 14270 14271 updatePayload = [CHILDREN, nextProp]; 14272 } 14273 } else if (typeof nextProp === 'number') { 14274 if (domElement.textContent !== '' + nextProp) { 14275 if ( !suppressHydrationWarning) { 14276 warnForTextDifference(domElement.textContent, nextProp); 14277 } 14278 14279 updatePayload = [CHILDREN, '' + nextProp]; 14280 } 14281 } 14282 } else if (registrationNameModules.hasOwnProperty(propKey)) { 14283 if (nextProp != null) { 14284 if ( typeof nextProp !== 'function') { 14285 warnForInvalidEventListener(propKey, nextProp); 14286 } 14287 14288 ensureListeningTo(rootContainerElement, propKey); 14289 } 14290 } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) 14291 typeof isCustomComponentTag === 'boolean') { 14292 // Validate that the properties correspond to their expected values. 14293 var serverValue = void 0; 14294 var propertyInfo = getPropertyInfo(propKey); 14295 14296 if (suppressHydrationWarning) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated 14297 // TODO: Only ignore them on controlled tags. 14298 propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 14299 var serverHTML = domElement.innerHTML; 14300 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 14301 var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : ''); 14302 14303 if (expectedHTML !== serverHTML) { 14304 warnForPropDifference(propKey, serverHTML, expectedHTML); 14305 } 14306 } else if (propKey === STYLE) { 14307 // $FlowFixMe - Should be inferred as not undefined. 14308 extraAttributeNames.delete(propKey); 14309 14310 if (canDiffStyleForHydrationWarning) { 14311 var expectedStyle = createDangerousStringForStyles(nextProp); 14312 serverValue = domElement.getAttribute('style'); 14313 14314 if (expectedStyle !== serverValue) { 14315 warnForPropDifference(propKey, serverValue, expectedStyle); 14316 } 14317 } 14318 } else if (isCustomComponentTag) { 14319 // $FlowFixMe - Should be inferred as not undefined. 14320 extraAttributeNames.delete(propKey.toLowerCase()); 14321 serverValue = getValueForAttribute(domElement, propKey, nextProp); 14322 14323 if (nextProp !== serverValue) { 14324 warnForPropDifference(propKey, serverValue, nextProp); 14325 } 14326 } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { 14327 var isMismatchDueToBadCasing = false; 14328 14329 if (propertyInfo !== null) { 14330 // $FlowFixMe - Should be inferred as not undefined. 14331 extraAttributeNames.delete(propertyInfo.attributeName); 14332 serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); 14333 } else { 14334 var ownNamespace = parentNamespace; 14335 14336 if (ownNamespace === HTML_NAMESPACE$1) { 14337 ownNamespace = getIntrinsicNamespace(tag); 14338 } 14339 14340 if (ownNamespace === HTML_NAMESPACE$1) { 14341 // $FlowFixMe - Should be inferred as not undefined. 14342 extraAttributeNames.delete(propKey.toLowerCase()); 14343 } else { 14344 var standardName = getPossibleStandardName(propKey); 14345 14346 if (standardName !== null && standardName !== propKey) { 14347 // If an SVG prop is supplied with bad casing, it will 14348 // be successfully parsed from HTML, but will produce a mismatch 14349 // (and would be incorrectly rendered on the client). 14350 // However, we already warn about bad casing elsewhere. 14351 // So we'll skip the misleading extra mismatch warning in this case. 14352 isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. 14353 14354 extraAttributeNames.delete(standardName); 14355 } // $FlowFixMe - Should be inferred as not undefined. 14356 14357 14358 extraAttributeNames.delete(propKey); 14359 } 14360 14361 serverValue = getValueForAttribute(domElement, propKey, nextProp); 14362 } 14363 14364 if (nextProp !== serverValue && !isMismatchDueToBadCasing) { 14365 warnForPropDifference(propKey, serverValue, nextProp); 14366 } 14367 } 14368 } 14369 } 14370 14371 { 14372 // $FlowFixMe - Should be inferred as not undefined. 14373 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 14374 // $FlowFixMe - Should be inferred as not undefined. 14375 warnForExtraAttributes(extraAttributeNames); 14376 } 14377 } 14378 14379 switch (tag) { 14380 case 'input': 14381 // TODO: Make sure we check if this is still unmounted or do any clean 14382 // up necessary since we never stop tracking anymore. 14383 track(domElement); 14384 postMountWrapper(domElement, rawProps, true); 14385 break; 14386 14387 case 'textarea': 14388 // TODO: Make sure we check if this is still unmounted or do any clean 14389 // up necessary since we never stop tracking anymore. 14390 track(domElement); 14391 postMountWrapper$3(domElement); 14392 break; 14393 14394 case 'select': 14395 case 'option': 14396 // For input and textarea we current always set the value property at 14397 // post mount to force it to diverge from attributes. However, for 14398 // option and select we don't quite do the same thing and select 14399 // is not resilient to the DOM state changing so we don't do that here. 14400 // TODO: Consider not doing this for input and textarea. 14401 break; 14402 14403 default: 14404 if (typeof rawProps.onClick === 'function') { 14405 // TODO: This cast may not be sound for SVG, MathML or custom elements. 14406 trapClickOnNonInteractiveElement(domElement); 14407 } 14408 14409 break; 14410 } 14411 14412 return updatePayload; 14413} 14414function diffHydratedText(textNode, text) { 14415 var isDifferent = textNode.nodeValue !== text; 14416 return isDifferent; 14417} 14418function warnForUnmatchedText(textNode, text) { 14419 { 14420 warnForTextDifference(textNode.nodeValue, text); 14421 } 14422} 14423function warnForDeletedHydratableElement(parentNode, child) { 14424 { 14425 if (didWarnInvalidHydration) { 14426 return; 14427 } 14428 14429 didWarnInvalidHydration = true; 14430 14431 error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 14432 } 14433} 14434function warnForDeletedHydratableText(parentNode, child) { 14435 { 14436 if (didWarnInvalidHydration) { 14437 return; 14438 } 14439 14440 didWarnInvalidHydration = true; 14441 14442 error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 14443 } 14444} 14445function warnForInsertedHydratedElement(parentNode, tag, props) { 14446 { 14447 if (didWarnInvalidHydration) { 14448 return; 14449 } 14450 14451 didWarnInvalidHydration = true; 14452 14453 error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 14454 } 14455} 14456function warnForInsertedHydratedText(parentNode, text) { 14457 { 14458 if (text === '') { 14459 // We expect to insert empty text nodes since they're not represented in 14460 // the HTML. 14461 // TODO: Remove this special case if we can just avoid inserting empty 14462 // text nodes. 14463 return; 14464 } 14465 14466 if (didWarnInvalidHydration) { 14467 return; 14468 } 14469 14470 didWarnInvalidHydration = true; 14471 14472 error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 14473 } 14474} 14475function restoreControlledState$3(domElement, tag, props) { 14476 switch (tag) { 14477 case 'input': 14478 restoreControlledState(domElement, props); 14479 return; 14480 14481 case 'textarea': 14482 restoreControlledState$2(domElement, props); 14483 return; 14484 14485 case 'select': 14486 restoreControlledState$1(domElement, props); 14487 return; 14488 } 14489} 14490 14491function getActiveElement(doc) { 14492 doc = doc || (typeof document !== 'undefined' ? document : undefined); 14493 14494 if (typeof doc === 'undefined') { 14495 return null; 14496 } 14497 14498 try { 14499 return doc.activeElement || doc.body; 14500 } catch (e) { 14501 return doc.body; 14502 } 14503} 14504 14505/** 14506 * Given any node return the first leaf node without children. 14507 * 14508 * @param {DOMElement|DOMTextNode} node 14509 * @return {DOMElement|DOMTextNode} 14510 */ 14511 14512function getLeafNode(node) { 14513 while (node && node.firstChild) { 14514 node = node.firstChild; 14515 } 14516 14517 return node; 14518} 14519/** 14520 * Get the next sibling within a container. This will walk up the 14521 * DOM if a node's siblings have been exhausted. 14522 * 14523 * @param {DOMElement|DOMTextNode} node 14524 * @return {?DOMElement|DOMTextNode} 14525 */ 14526 14527 14528function getSiblingNode(node) { 14529 while (node) { 14530 if (node.nextSibling) { 14531 return node.nextSibling; 14532 } 14533 14534 node = node.parentNode; 14535 } 14536} 14537/** 14538 * Get object describing the nodes which contain characters at offset. 14539 * 14540 * @param {DOMElement|DOMTextNode} root 14541 * @param {number} offset 14542 * @return {?object} 14543 */ 14544 14545 14546function getNodeForCharacterOffset(root, offset) { 14547 var node = getLeafNode(root); 14548 var nodeStart = 0; 14549 var nodeEnd = 0; 14550 14551 while (node) { 14552 if (node.nodeType === TEXT_NODE) { 14553 nodeEnd = nodeStart + node.textContent.length; 14554 14555 if (nodeStart <= offset && nodeEnd >= offset) { 14556 return { 14557 node: node, 14558 offset: offset - nodeStart 14559 }; 14560 } 14561 14562 nodeStart = nodeEnd; 14563 } 14564 14565 node = getLeafNode(getSiblingNode(node)); 14566 } 14567} 14568 14569/** 14570 * @param {DOMElement} outerNode 14571 * @return {?object} 14572 */ 14573 14574function getOffsets(outerNode) { 14575 var ownerDocument = outerNode.ownerDocument; 14576 var win = ownerDocument && ownerDocument.defaultView || window; 14577 var selection = win.getSelection && win.getSelection(); 14578 14579 if (!selection || selection.rangeCount === 0) { 14580 return null; 14581 } 14582 14583 var anchorNode = selection.anchorNode, 14584 anchorOffset = selection.anchorOffset, 14585 focusNode = selection.focusNode, 14586 focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 14587 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 14588 // expose properties, triggering a "Permission denied error" if any of its 14589 // properties are accessed. The only seemingly possible way to avoid erroring 14590 // is to access a property that typically works for non-anonymous divs and 14591 // catch any error that may otherwise arise. See 14592 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 14593 14594 try { 14595 /* eslint-disable no-unused-expressions */ 14596 anchorNode.nodeType; 14597 focusNode.nodeType; 14598 /* eslint-enable no-unused-expressions */ 14599 } catch (e) { 14600 return null; 14601 } 14602 14603 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); 14604} 14605/** 14606 * Returns {start, end} where `start` is the character/codepoint index of 14607 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 14608 * `end` is the index of (focusNode, focusOffset). 14609 * 14610 * Returns null if you pass in garbage input but we should probably just crash. 14611 * 14612 * Exported only for testing. 14613 */ 14614 14615function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { 14616 var length = 0; 14617 var start = -1; 14618 var end = -1; 14619 var indexWithinAnchor = 0; 14620 var indexWithinFocus = 0; 14621 var node = outerNode; 14622 var parentNode = null; 14623 14624 outer: while (true) { 14625 var next = null; 14626 14627 while (true) { 14628 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 14629 start = length + anchorOffset; 14630 } 14631 14632 if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 14633 end = length + focusOffset; 14634 } 14635 14636 if (node.nodeType === TEXT_NODE) { 14637 length += node.nodeValue.length; 14638 } 14639 14640 if ((next = node.firstChild) === null) { 14641 break; 14642 } // Moving from `node` to its first child `next`. 14643 14644 14645 parentNode = node; 14646 node = next; 14647 } 14648 14649 while (true) { 14650 if (node === outerNode) { 14651 // If `outerNode` has children, this is always the second time visiting 14652 // it. If it has no children, this is still the first loop, and the only 14653 // valid selection is anchorNode and focusNode both equal to this node 14654 // and both offsets 0, in which case we will have handled above. 14655 break outer; 14656 } 14657 14658 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 14659 start = length; 14660 } 14661 14662 if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { 14663 end = length; 14664 } 14665 14666 if ((next = node.nextSibling) !== null) { 14667 break; 14668 } 14669 14670 node = parentNode; 14671 parentNode = node.parentNode; 14672 } // Moving from `node` to its next sibling `next`. 14673 14674 14675 node = next; 14676 } 14677 14678 if (start === -1 || end === -1) { 14679 // This should never happen. (Would happen if the anchor/focus nodes aren't 14680 // actually inside the passed-in node.) 14681 return null; 14682 } 14683 14684 return { 14685 start: start, 14686 end: end 14687 }; 14688} 14689/** 14690 * In modern non-IE browsers, we can support both forward and backward 14691 * selections. 14692 * 14693 * Note: IE10+ supports the Selection object, but it does not support 14694 * the `extend` method, which means that even in modern IE, it's not possible 14695 * to programmatically create a backward selection. Thus, for all IE 14696 * versions, we use the old IE API to create our selections. 14697 * 14698 * @param {DOMElement|DOMTextNode} node 14699 * @param {object} offsets 14700 */ 14701 14702function setOffsets(node, offsets) { 14703 var doc = node.ownerDocument || document; 14704 var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. 14705 // (For instance: TinyMCE editor used in a list component that supports pasting to add more, 14706 // fails when pasting 100+ items) 14707 14708 if (!win.getSelection) { 14709 return; 14710 } 14711 14712 var selection = win.getSelection(); 14713 var length = node.textContent.length; 14714 var start = Math.min(offsets.start, length); 14715 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. 14716 // Flip backward selections, so we can set with a single range. 14717 14718 if (!selection.extend && start > end) { 14719 var temp = end; 14720 end = start; 14721 start = temp; 14722 } 14723 14724 var startMarker = getNodeForCharacterOffset(node, start); 14725 var endMarker = getNodeForCharacterOffset(node, end); 14726 14727 if (startMarker && endMarker) { 14728 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 14729 return; 14730 } 14731 14732 var range = doc.createRange(); 14733 range.setStart(startMarker.node, startMarker.offset); 14734 selection.removeAllRanges(); 14735 14736 if (start > end) { 14737 selection.addRange(range); 14738 selection.extend(endMarker.node, endMarker.offset); 14739 } else { 14740 range.setEnd(endMarker.node, endMarker.offset); 14741 selection.addRange(range); 14742 } 14743 } 14744} 14745 14746function isTextNode(node) { 14747 return node && node.nodeType === TEXT_NODE; 14748} 14749 14750function containsNode(outerNode, innerNode) { 14751 if (!outerNode || !innerNode) { 14752 return false; 14753 } else if (outerNode === innerNode) { 14754 return true; 14755 } else if (isTextNode(outerNode)) { 14756 return false; 14757 } else if (isTextNode(innerNode)) { 14758 return containsNode(outerNode, innerNode.parentNode); 14759 } else if ('contains' in outerNode) { 14760 return outerNode.contains(innerNode); 14761 } else if (outerNode.compareDocumentPosition) { 14762 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 14763 } else { 14764 return false; 14765 } 14766} 14767 14768function isInDocument(node) { 14769 return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); 14770} 14771 14772function isSameOriginFrame(iframe) { 14773 try { 14774 // Accessing the contentDocument of a HTMLIframeElement can cause the browser 14775 // to throw, e.g. if it has a cross-origin src attribute. 14776 // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: 14777 // iframe.contentDocument.defaultView; 14778 // A safety way is to access one of the cross origin properties: Window or Location 14779 // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. 14780 // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl 14781 return typeof iframe.contentWindow.location.href === 'string'; 14782 } catch (err) { 14783 return false; 14784 } 14785} 14786 14787function getActiveElementDeep() { 14788 var win = window; 14789 var element = getActiveElement(); 14790 14791 while (element instanceof win.HTMLIFrameElement) { 14792 if (isSameOriginFrame(element)) { 14793 win = element.contentWindow; 14794 } else { 14795 return element; 14796 } 14797 14798 element = getActiveElement(win.document); 14799 } 14800 14801 return element; 14802} 14803/** 14804 * @ReactInputSelection: React input selection module. Based on Selection.js, 14805 * but modified to be suitable for react and has a couple of bug fixes (doesn't 14806 * assume buttons have range selections allowed). 14807 * Input selection module for React. 14808 */ 14809 14810/** 14811 * @hasSelectionCapabilities: we get the element types that support selection 14812 * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` 14813 * and `selectionEnd` rows. 14814 */ 14815 14816 14817function hasSelectionCapabilities(elem) { 14818 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 14819 return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); 14820} 14821function getSelectionInformation() { 14822 var focusedElem = getActiveElementDeep(); 14823 return { 14824 // Used by Flare 14825 activeElementDetached: null, 14826 focusedElem: focusedElem, 14827 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null 14828 }; 14829} 14830/** 14831 * @restoreSelection: If any selection information was potentially lost, 14832 * restore it. This is useful when performing operations that could remove dom 14833 * nodes and place them back in, resulting in focus being lost. 14834 */ 14835 14836function restoreSelection(priorSelectionInformation) { 14837 var curFocusedElem = getActiveElementDeep(); 14838 var priorFocusedElem = priorSelectionInformation.focusedElem; 14839 var priorSelectionRange = priorSelectionInformation.selectionRange; 14840 14841 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 14842 if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { 14843 setSelection(priorFocusedElem, priorSelectionRange); 14844 } // Focusing a node can change the scroll position, which is undesirable 14845 14846 14847 var ancestors = []; 14848 var ancestor = priorFocusedElem; 14849 14850 while (ancestor = ancestor.parentNode) { 14851 if (ancestor.nodeType === ELEMENT_NODE) { 14852 ancestors.push({ 14853 element: ancestor, 14854 left: ancestor.scrollLeft, 14855 top: ancestor.scrollTop 14856 }); 14857 } 14858 } 14859 14860 if (typeof priorFocusedElem.focus === 'function') { 14861 priorFocusedElem.focus(); 14862 } 14863 14864 for (var i = 0; i < ancestors.length; i++) { 14865 var info = ancestors[i]; 14866 info.element.scrollLeft = info.left; 14867 info.element.scrollTop = info.top; 14868 } 14869 } 14870} 14871/** 14872 * @getSelection: Gets the selection bounds of a focused textarea, input or 14873 * contentEditable node. 14874 * -@input: Look up selection bounds of this input 14875 * -@return {start: selectionStart, end: selectionEnd} 14876 */ 14877 14878function getSelection(input) { 14879 var selection; 14880 14881 if ('selectionStart' in input) { 14882 // Modern browser with input or textarea. 14883 selection = { 14884 start: input.selectionStart, 14885 end: input.selectionEnd 14886 }; 14887 } else { 14888 // Content editable or old IE textarea. 14889 selection = getOffsets(input); 14890 } 14891 14892 return selection || { 14893 start: 0, 14894 end: 0 14895 }; 14896} 14897/** 14898 * @setSelection: Sets the selection bounds of a textarea or input and focuses 14899 * the input. 14900 * -@input Set selection bounds of this input or textarea 14901 * -@offsets Object of same form that is returned from get* 14902 */ 14903 14904function setSelection(input, offsets) { 14905 var start = offsets.start, 14906 end = offsets.end; 14907 14908 if (end === undefined) { 14909 end = start; 14910 } 14911 14912 if ('selectionStart' in input) { 14913 input.selectionStart = start; 14914 input.selectionEnd = Math.min(end, input.value.length); 14915 } else { 14916 setOffsets(input, offsets); 14917 } 14918} 14919 14920var validateDOMNesting = function () {}; 14921 14922var updatedAncestorInfo = function () {}; 14923 14924{ 14925 // This validation code was written based on the HTML5 parsing spec: 14926 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 14927 // 14928 // Note: this does not catch all invalid nesting, nor does it try to (as it's 14929 // not clear what practical benefit doing so provides); instead, we warn only 14930 // for cases where the parser will give a parse tree differing from what React 14931 // intended. For example, <b><div></div></b> is invalid but we don't warn 14932 // because it still parses correctly; we do warn for other cases like nested 14933 // <p> tags where the beginning of the second element implicitly closes the 14934 // first, causing a confusing mess. 14935 // https://html.spec.whatwg.org/multipage/syntax.html#special 14936 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']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 14937 14938 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 14939 // TODO: Distinguish by namespace here -- for <title>, including it here 14940 // errs on the side of fewer warnings 14941 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 14942 14943 var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 14944 14945 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 14946 var emptyAncestorInfo = { 14947 current: null, 14948 formTag: null, 14949 aTagInScope: null, 14950 buttonTagInScope: null, 14951 nobrTagInScope: null, 14952 pTagInButtonScope: null, 14953 listItemTagAutoclosing: null, 14954 dlItemTagAutoclosing: null 14955 }; 14956 14957 updatedAncestorInfo = function (oldInfo, tag) { 14958 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 14959 14960 var info = { 14961 tag: tag 14962 }; 14963 14964 if (inScopeTags.indexOf(tag) !== -1) { 14965 ancestorInfo.aTagInScope = null; 14966 ancestorInfo.buttonTagInScope = null; 14967 ancestorInfo.nobrTagInScope = null; 14968 } 14969 14970 if (buttonScopeTags.indexOf(tag) !== -1) { 14971 ancestorInfo.pTagInButtonScope = null; 14972 } // See rules for 'li', 'dd', 'dt' start tags in 14973 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 14974 14975 14976 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 14977 ancestorInfo.listItemTagAutoclosing = null; 14978 ancestorInfo.dlItemTagAutoclosing = null; 14979 } 14980 14981 ancestorInfo.current = info; 14982 14983 if (tag === 'form') { 14984 ancestorInfo.formTag = info; 14985 } 14986 14987 if (tag === 'a') { 14988 ancestorInfo.aTagInScope = info; 14989 } 14990 14991 if (tag === 'button') { 14992 ancestorInfo.buttonTagInScope = info; 14993 } 14994 14995 if (tag === 'nobr') { 14996 ancestorInfo.nobrTagInScope = info; 14997 } 14998 14999 if (tag === 'p') { 15000 ancestorInfo.pTagInButtonScope = info; 15001 } 15002 15003 if (tag === 'li') { 15004 ancestorInfo.listItemTagAutoclosing = info; 15005 } 15006 15007 if (tag === 'dd' || tag === 'dt') { 15008 ancestorInfo.dlItemTagAutoclosing = info; 15009 } 15010 15011 return ancestorInfo; 15012 }; 15013 /** 15014 * Returns whether 15015 */ 15016 15017 15018 var isTagValidWithParent = function (tag, parentTag) { 15019 // First, let's check if we're in an unusual parsing mode... 15020 switch (parentTag) { 15021 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 15022 case 'select': 15023 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 15024 15025 case 'optgroup': 15026 return tag === 'option' || tag === '#text'; 15027 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 15028 // but 15029 15030 case 'option': 15031 return tag === '#text'; 15032 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 15033 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 15034 // No special behavior since these rules fall back to "in body" mode for 15035 // all except special table nodes which cause bad parsing behavior anyway. 15036 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 15037 15038 case 'tr': 15039 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 15040 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 15041 15042 case 'tbody': 15043 case 'thead': 15044 case 'tfoot': 15045 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 15046 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 15047 15048 case 'colgroup': 15049 return tag === 'col' || tag === 'template'; 15050 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 15051 15052 case 'table': 15053 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 15054 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 15055 15056 case 'head': 15057 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 15058 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 15059 15060 case 'html': 15061 return tag === 'head' || tag === 'body' || tag === 'frameset'; 15062 15063 case 'frameset': 15064 return tag === 'frame'; 15065 15066 case '#document': 15067 return tag === 'html'; 15068 } // Probably in the "in body" parsing mode, so we outlaw only tag combos 15069 // where the parsing rules cause implicit opens or closes to be added. 15070 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 15071 15072 15073 switch (tag) { 15074 case 'h1': 15075 case 'h2': 15076 case 'h3': 15077 case 'h4': 15078 case 'h5': 15079 case 'h6': 15080 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 15081 15082 case 'rp': 15083 case 'rt': 15084 return impliedEndTags.indexOf(parentTag) === -1; 15085 15086 case 'body': 15087 case 'caption': 15088 case 'col': 15089 case 'colgroup': 15090 case 'frameset': 15091 case 'frame': 15092 case 'head': 15093 case 'html': 15094 case 'tbody': 15095 case 'td': 15096 case 'tfoot': 15097 case 'th': 15098 case 'thead': 15099 case 'tr': 15100 // These tags are only valid with a few parents that have special child 15101 // parsing rules -- if we're down here, then none of those matched and 15102 // so we allow it only if we don't know what the parent is, as all other 15103 // cases are invalid. 15104 return parentTag == null; 15105 } 15106 15107 return true; 15108 }; 15109 /** 15110 * Returns whether 15111 */ 15112 15113 15114 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 15115 switch (tag) { 15116 case 'address': 15117 case 'article': 15118 case 'aside': 15119 case 'blockquote': 15120 case 'center': 15121 case 'details': 15122 case 'dialog': 15123 case 'dir': 15124 case 'div': 15125 case 'dl': 15126 case 'fieldset': 15127 case 'figcaption': 15128 case 'figure': 15129 case 'footer': 15130 case 'header': 15131 case 'hgroup': 15132 case 'main': 15133 case 'menu': 15134 case 'nav': 15135 case 'ol': 15136 case 'p': 15137 case 'section': 15138 case 'summary': 15139 case 'ul': 15140 case 'pre': 15141 case 'listing': 15142 case 'table': 15143 case 'hr': 15144 case 'xmp': 15145 case 'h1': 15146 case 'h2': 15147 case 'h3': 15148 case 'h4': 15149 case 'h5': 15150 case 'h6': 15151 return ancestorInfo.pTagInButtonScope; 15152 15153 case 'form': 15154 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 15155 15156 case 'li': 15157 return ancestorInfo.listItemTagAutoclosing; 15158 15159 case 'dd': 15160 case 'dt': 15161 return ancestorInfo.dlItemTagAutoclosing; 15162 15163 case 'button': 15164 return ancestorInfo.buttonTagInScope; 15165 15166 case 'a': 15167 // Spec says something about storing a list of markers, but it sounds 15168 // equivalent to this check. 15169 return ancestorInfo.aTagInScope; 15170 15171 case 'nobr': 15172 return ancestorInfo.nobrTagInScope; 15173 } 15174 15175 return null; 15176 }; 15177 15178 var didWarn$1 = {}; 15179 15180 validateDOMNesting = function (childTag, childText, ancestorInfo) { 15181 ancestorInfo = ancestorInfo || emptyAncestorInfo; 15182 var parentInfo = ancestorInfo.current; 15183 var parentTag = parentInfo && parentInfo.tag; 15184 15185 if (childText != null) { 15186 if (childTag != null) { 15187 error('validateDOMNesting: when childText is passed, childTag should be null'); 15188 } 15189 15190 childTag = '#text'; 15191 } 15192 15193 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 15194 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 15195 var invalidParentOrAncestor = invalidParent || invalidAncestor; 15196 15197 if (!invalidParentOrAncestor) { 15198 return; 15199 } 15200 15201 var ancestorTag = invalidParentOrAncestor.tag; 15202 var addendum = getCurrentFiberStackInDev(); 15203 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; 15204 15205 if (didWarn$1[warnKey]) { 15206 return; 15207 } 15208 15209 didWarn$1[warnKey] = true; 15210 var tagDisplayName = childTag; 15211 var whitespaceInfo = ''; 15212 15213 if (childTag === '#text') { 15214 if (/\S/.test(childText)) { 15215 tagDisplayName = 'Text nodes'; 15216 } else { 15217 tagDisplayName = 'Whitespace text nodes'; 15218 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 15219 } 15220 } else { 15221 tagDisplayName = '<' + childTag + '>'; 15222 } 15223 15224 if (invalidParent) { 15225 var info = ''; 15226 15227 if (ancestorTag === 'table' && childTag === 'tr') { 15228 info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; 15229 } 15230 15231 error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); 15232 } else { 15233 error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); 15234 } 15235 }; 15236} 15237 15238var SUPPRESS_HYDRATION_WARNING$1; 15239 15240{ 15241 SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 15242} 15243 15244var SUSPENSE_START_DATA = '$'; 15245var SUSPENSE_END_DATA = '/$'; 15246var SUSPENSE_PENDING_START_DATA = '$?'; 15247var SUSPENSE_FALLBACK_START_DATA = '$!'; 15248var STYLE$1 = 'style'; 15249var eventsEnabled = null; 15250var selectionInformation = null; 15251 15252function shouldAutoFocusHostComponent(type, props) { 15253 switch (type) { 15254 case 'button': 15255 case 'input': 15256 case 'select': 15257 case 'textarea': 15258 return !!props.autoFocus; 15259 } 15260 15261 return false; 15262} 15263function getRootHostContext(rootContainerInstance) { 15264 var type; 15265 var namespace; 15266 var nodeType = rootContainerInstance.nodeType; 15267 15268 switch (nodeType) { 15269 case DOCUMENT_NODE: 15270 case DOCUMENT_FRAGMENT_NODE: 15271 { 15272 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 15273 var root = rootContainerInstance.documentElement; 15274 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 15275 break; 15276 } 15277 15278 default: 15279 { 15280 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 15281 var ownNamespace = container.namespaceURI || null; 15282 type = container.tagName; 15283 namespace = getChildNamespace(ownNamespace, type); 15284 break; 15285 } 15286 } 15287 15288 { 15289 var validatedTag = type.toLowerCase(); 15290 var ancestorInfo = updatedAncestorInfo(null, validatedTag); 15291 return { 15292 namespace: namespace, 15293 ancestorInfo: ancestorInfo 15294 }; 15295 } 15296} 15297function getChildHostContext(parentHostContext, type, rootContainerInstance) { 15298 { 15299 var parentHostContextDev = parentHostContext; 15300 var namespace = getChildNamespace(parentHostContextDev.namespace, type); 15301 var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); 15302 return { 15303 namespace: namespace, 15304 ancestorInfo: ancestorInfo 15305 }; 15306 } 15307} 15308function getPublicInstance(instance) { 15309 return instance; 15310} 15311function prepareForCommit(containerInfo) { 15312 eventsEnabled = isEnabled(); 15313 selectionInformation = getSelectionInformation(); 15314 setEnabled(false); 15315} 15316function resetAfterCommit(containerInfo) { 15317 restoreSelection(selectionInformation); 15318 setEnabled(eventsEnabled); 15319 eventsEnabled = null; 15320 15321 selectionInformation = null; 15322} 15323function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 15324 var parentNamespace; 15325 15326 { 15327 // TODO: take namespace into account when validating. 15328 var hostContextDev = hostContext; 15329 validateDOMNesting(type, null, hostContextDev.ancestorInfo); 15330 15331 if (typeof props.children === 'string' || typeof props.children === 'number') { 15332 var string = '' + props.children; 15333 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 15334 validateDOMNesting(null, string, ownAncestorInfo); 15335 } 15336 15337 parentNamespace = hostContextDev.namespace; 15338 } 15339 15340 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 15341 precacheFiberNode(internalInstanceHandle, domElement); 15342 updateFiberProps(domElement, props); 15343 return domElement; 15344} 15345function appendInitialChild(parentInstance, child) { 15346 parentInstance.appendChild(child); 15347} 15348function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { 15349 setInitialProperties(domElement, type, props, rootContainerInstance); 15350 return shouldAutoFocusHostComponent(type, props); 15351} 15352function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 15353 { 15354 var hostContextDev = hostContext; 15355 15356 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 15357 var string = '' + newProps.children; 15358 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 15359 validateDOMNesting(null, string, ownAncestorInfo); 15360 } 15361 } 15362 15363 return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance); 15364} 15365function shouldSetTextContent(type, props) { 15366 return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null; 15367} 15368function shouldDeprioritizeSubtree(type, props) { 15369 return !!props.hidden; 15370} 15371function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { 15372 { 15373 var hostContextDev = hostContext; 15374 validateDOMNesting(null, text, hostContextDev.ancestorInfo); 15375 } 15376 15377 var textNode = createTextNode(text, rootContainerInstance); 15378 precacheFiberNode(internalInstanceHandle, textNode); 15379 return textNode; 15380} 15381// if a component just imports ReactDOM (e.g. for findDOMNode). 15382// Some environments might not have setTimeout or clearTimeout. 15383 15384var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; 15385var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; 15386var noTimeout = -1; // ------------------- 15387function commitMount(domElement, type, newProps, internalInstanceHandle) { 15388 // Despite the naming that might imply otherwise, this method only 15389 // fires if there is an `Update` effect scheduled during mounting. 15390 // This happens if `finalizeInitialChildren` returns `true` (which it 15391 // does to implement the `autoFocus` attribute on the client). But 15392 // there are also other cases when this might happen (such as patching 15393 // up text content during hydration mismatch). So we'll check this again. 15394 if (shouldAutoFocusHostComponent(type, newProps)) { 15395 domElement.focus(); 15396 } 15397} 15398function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 15399 // Update the props handle so that we know which props are the ones with 15400 // with current event handlers. 15401 updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. 15402 15403 updateProperties(domElement, updatePayload, type, oldProps, newProps); 15404} 15405function resetTextContent(domElement) { 15406 setTextContent(domElement, ''); 15407} 15408function commitTextUpdate(textInstance, oldText, newText) { 15409 textInstance.nodeValue = newText; 15410} 15411function appendChild(parentInstance, child) { 15412 parentInstance.appendChild(child); 15413} 15414function appendChildToContainer(container, child) { 15415 var parentNode; 15416 15417 if (container.nodeType === COMMENT_NODE) { 15418 parentNode = container.parentNode; 15419 parentNode.insertBefore(child, container); 15420 } else { 15421 parentNode = container; 15422 parentNode.appendChild(child); 15423 } // This container might be used for a portal. 15424 // If something inside a portal is clicked, that click should bubble 15425 // through the React tree. However, on Mobile Safari the click would 15426 // never bubble through the *DOM* tree unless an ancestor with onclick 15427 // event exists. So we wouldn't see it and dispatch it. 15428 // This is why we ensure that non React root containers have inline onclick 15429 // defined. 15430 // https://github.com/facebook/react/issues/11918 15431 15432 15433 var reactRootContainer = container._reactRootContainer; 15434 15435 if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { 15436 // TODO: This cast may not be sound for SVG, MathML or custom elements. 15437 trapClickOnNonInteractiveElement(parentNode); 15438 } 15439} 15440function insertBefore(parentInstance, child, beforeChild) { 15441 parentInstance.insertBefore(child, beforeChild); 15442} 15443function insertInContainerBefore(container, child, beforeChild) { 15444 if (container.nodeType === COMMENT_NODE) { 15445 container.parentNode.insertBefore(child, beforeChild); 15446 } else { 15447 container.insertBefore(child, beforeChild); 15448 } 15449} 15450function removeChild(parentInstance, child) { 15451 parentInstance.removeChild(child); 15452} 15453function removeChildFromContainer(container, child) { 15454 if (container.nodeType === COMMENT_NODE) { 15455 container.parentNode.removeChild(child); 15456 } else { 15457 container.removeChild(child); 15458 } 15459} 15460 15461function hideInstance(instance) { 15462 // pass host context to this method? 15463 15464 15465 instance = instance; 15466 var style = instance.style; 15467 15468 if (typeof style.setProperty === 'function') { 15469 style.setProperty('display', 'none', 'important'); 15470 } else { 15471 style.display = 'none'; 15472 } 15473} 15474function hideTextInstance(textInstance) { 15475 textInstance.nodeValue = ''; 15476} 15477function unhideInstance(instance, props) { 15478 instance = instance; 15479 var styleProp = props[STYLE$1]; 15480 var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; 15481 instance.style.display = dangerousStyleValue('display', display); 15482} 15483function unhideTextInstance(textInstance, text) { 15484 textInstance.nodeValue = text; 15485} // ------------------- 15486function canHydrateInstance(instance, type, props) { 15487 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 15488 return null; 15489 } // This has now been refined to an element node. 15490 15491 15492 return instance; 15493} 15494function canHydrateTextInstance(instance, text) { 15495 if (text === '' || instance.nodeType !== TEXT_NODE) { 15496 // Empty strings are not parsed by HTML so there won't be a correct match here. 15497 return null; 15498 } // This has now been refined to a text node. 15499 15500 15501 return instance; 15502} 15503function isSuspenseInstancePending(instance) { 15504 return instance.data === SUSPENSE_PENDING_START_DATA; 15505} 15506function isSuspenseInstanceFallback(instance) { 15507 return instance.data === SUSPENSE_FALLBACK_START_DATA; 15508} 15509 15510function getNextHydratable(node) { 15511 // Skip non-hydratable nodes. 15512 for (; node != null; node = node.nextSibling) { 15513 var nodeType = node.nodeType; 15514 15515 if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { 15516 break; 15517 } 15518 } 15519 15520 return node; 15521} 15522 15523function getNextHydratableSibling(instance) { 15524 return getNextHydratable(instance.nextSibling); 15525} 15526function getFirstHydratableChild(parentInstance) { 15527 return getNextHydratable(parentInstance.firstChild); 15528} 15529function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 15530 precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events 15531 // get attached. 15532 15533 updateFiberProps(instance, props); 15534 var parentNamespace; 15535 15536 { 15537 var hostContextDev = hostContext; 15538 parentNamespace = hostContextDev.namespace; 15539 } 15540 15541 return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance); 15542} 15543function hydrateTextInstance(textInstance, text, internalInstanceHandle) { 15544 precacheFiberNode(internalInstanceHandle, textInstance); 15545 return diffHydratedText(textInstance, text); 15546} 15547function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { 15548 var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. 15549 // There might be nested nodes so we need to keep track of how 15550 // deep we are and only break out when we're back on top. 15551 15552 var depth = 0; 15553 15554 while (node) { 15555 if (node.nodeType === COMMENT_NODE) { 15556 var data = node.data; 15557 15558 if (data === SUSPENSE_END_DATA) { 15559 if (depth === 0) { 15560 return getNextHydratableSibling(node); 15561 } else { 15562 depth--; 15563 } 15564 } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 15565 depth++; 15566 } 15567 } 15568 15569 node = node.nextSibling; 15570 } // TODO: Warn, we didn't find the end comment boundary. 15571 15572 15573 return null; 15574} // Returns the SuspenseInstance if this node is a direct child of a 15575// SuspenseInstance. I.e. if its previous sibling is a Comment with 15576// SUSPENSE_x_START_DATA. Otherwise, null. 15577 15578function getParentSuspenseInstance(targetInstance) { 15579 var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. 15580 // There might be nested nodes so we need to keep track of how 15581 // deep we are and only break out when we're back on top. 15582 15583 var depth = 0; 15584 15585 while (node) { 15586 if (node.nodeType === COMMENT_NODE) { 15587 var data = node.data; 15588 15589 if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 15590 if (depth === 0) { 15591 return node; 15592 } else { 15593 depth--; 15594 } 15595 } else if (data === SUSPENSE_END_DATA) { 15596 depth++; 15597 } 15598 } 15599 15600 node = node.previousSibling; 15601 } 15602 15603 return null; 15604} 15605function commitHydratedContainer(container) { 15606 // Retry if any event replaying was blocked on this. 15607 retryIfBlockedOn(container); 15608} 15609function commitHydratedSuspenseInstance(suspenseInstance) { 15610 // Retry if any event replaying was blocked on this. 15611 retryIfBlockedOn(suspenseInstance); 15612} 15613function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { 15614 { 15615 warnForUnmatchedText(textInstance, text); 15616 } 15617} 15618function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { 15619 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 15620 warnForUnmatchedText(textInstance, text); 15621 } 15622} 15623function didNotHydrateContainerInstance(parentContainer, instance) { 15624 { 15625 if (instance.nodeType === ELEMENT_NODE) { 15626 warnForDeletedHydratableElement(parentContainer, instance); 15627 } else if (instance.nodeType === COMMENT_NODE) ; else { 15628 warnForDeletedHydratableText(parentContainer, instance); 15629 } 15630 } 15631} 15632function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { 15633 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 15634 if (instance.nodeType === ELEMENT_NODE) { 15635 warnForDeletedHydratableElement(parentInstance, instance); 15636 } else if (instance.nodeType === COMMENT_NODE) ; else { 15637 warnForDeletedHydratableText(parentInstance, instance); 15638 } 15639 } 15640} 15641function didNotFindHydratableContainerInstance(parentContainer, type, props) { 15642 { 15643 warnForInsertedHydratedElement(parentContainer, type); 15644 } 15645} 15646function didNotFindHydratableContainerTextInstance(parentContainer, text) { 15647 { 15648 warnForInsertedHydratedText(parentContainer, text); 15649 } 15650} 15651function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { 15652 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 15653 warnForInsertedHydratedElement(parentInstance, type); 15654 } 15655} 15656function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { 15657 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 15658 warnForInsertedHydratedText(parentInstance, text); 15659 } 15660} 15661function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { 15662 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; 15663} 15664 15665var randomKey = Math.random().toString(36).slice(2); 15666var internalInstanceKey = '__reactInternalInstance$' + randomKey; 15667var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; 15668var internalContainerInstanceKey = '__reactContainere$' + randomKey; 15669function precacheFiberNode(hostInst, node) { 15670 node[internalInstanceKey] = hostInst; 15671} 15672function markContainerAsRoot(hostRoot, node) { 15673 node[internalContainerInstanceKey] = hostRoot; 15674} 15675function unmarkContainerAsRoot(node) { 15676 node[internalContainerInstanceKey] = null; 15677} 15678function isContainerMarkedAsRoot(node) { 15679 return !!node[internalContainerInstanceKey]; 15680} // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. 15681// If the target node is part of a hydrated or not yet rendered subtree, then 15682// this may also return a SuspenseComponent or HostRoot to indicate that. 15683// Conceptually the HostRoot fiber is a child of the Container node. So if you 15684// pass the Container node as the targetNode, you will not actually get the 15685// HostRoot back. To get to the HostRoot, you need to pass a child of it. 15686// The same thing applies to Suspense boundaries. 15687 15688function getClosestInstanceFromNode(targetNode) { 15689 var targetInst = targetNode[internalInstanceKey]; 15690 15691 if (targetInst) { 15692 // Don't return HostRoot or SuspenseComponent here. 15693 return targetInst; 15694 } // If the direct event target isn't a React owned DOM node, we need to look 15695 // to see if one of its parents is a React owned DOM node. 15696 15697 15698 var parentNode = targetNode.parentNode; 15699 15700 while (parentNode) { 15701 // We'll check if this is a container root that could include 15702 // React nodes in the future. We need to check this first because 15703 // if we're a child of a dehydrated container, we need to first 15704 // find that inner container before moving on to finding the parent 15705 // instance. Note that we don't check this field on the targetNode 15706 // itself because the fibers are conceptually between the container 15707 // node and the first child. It isn't surrounding the container node. 15708 // If it's not a container, we check if it's an instance. 15709 targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; 15710 15711 if (targetInst) { 15712 // Since this wasn't the direct target of the event, we might have 15713 // stepped past dehydrated DOM nodes to get here. However they could 15714 // also have been non-React nodes. We need to answer which one. 15715 // If we the instance doesn't have any children, then there can't be 15716 // a nested suspense boundary within it. So we can use this as a fast 15717 // bailout. Most of the time, when people add non-React children to 15718 // the tree, it is using a ref to a child-less DOM node. 15719 // Normally we'd only need to check one of the fibers because if it 15720 // has ever gone from having children to deleting them or vice versa 15721 // it would have deleted the dehydrated boundary nested inside already. 15722 // However, since the HostRoot starts out with an alternate it might 15723 // have one on the alternate so we need to check in case this was a 15724 // root. 15725 var alternate = targetInst.alternate; 15726 15727 if (targetInst.child !== null || alternate !== null && alternate.child !== null) { 15728 // Next we need to figure out if the node that skipped past is 15729 // nested within a dehydrated boundary and if so, which one. 15730 var suspenseInstance = getParentSuspenseInstance(targetNode); 15731 15732 while (suspenseInstance !== null) { 15733 // We found a suspense instance. That means that we haven't 15734 // hydrated it yet. Even though we leave the comments in the 15735 // DOM after hydrating, and there are boundaries in the DOM 15736 // that could already be hydrated, we wouldn't have found them 15737 // through this pass since if the target is hydrated it would 15738 // have had an internalInstanceKey on it. 15739 // Let's get the fiber associated with the SuspenseComponent 15740 // as the deepest instance. 15741 var targetSuspenseInst = suspenseInstance[internalInstanceKey]; 15742 15743 if (targetSuspenseInst) { 15744 return targetSuspenseInst; 15745 } // If we don't find a Fiber on the comment, it might be because 15746 // we haven't gotten to hydrate it yet. There might still be a 15747 // parent boundary that hasn't above this one so we need to find 15748 // the outer most that is known. 15749 15750 15751 suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent 15752 // host component also hasn't hydrated yet. We can return it 15753 // below since it will bail out on the isMounted check later. 15754 } 15755 } 15756 15757 return targetInst; 15758 } 15759 15760 targetNode = parentNode; 15761 parentNode = targetNode.parentNode; 15762 } 15763 15764 return null; 15765} 15766/** 15767 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 15768 * instance, or null if the node was not rendered by this React. 15769 */ 15770 15771function getInstanceFromNode$1(node) { 15772 var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; 15773 15774 if (inst) { 15775 if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { 15776 return inst; 15777 } else { 15778 return null; 15779 } 15780 } 15781 15782 return null; 15783} 15784/** 15785 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 15786 * DOM node. 15787 */ 15788 15789function getNodeFromInstance$1(inst) { 15790 if (inst.tag === HostComponent || inst.tag === HostText) { 15791 // In Fiber this, is just the state node right now. We assume it will be 15792 // a host component or host text. 15793 return inst.stateNode; 15794 } // Without this first invariant, passing a non-DOM-component triggers the next 15795 // invariant for a missing parent, which is super confusing. 15796 15797 15798 { 15799 { 15800 throw Error( "getNodeFromInstance: Invalid argument." ); 15801 } 15802 } 15803} 15804function getFiberCurrentPropsFromNode$1(node) { 15805 return node[internalEventHandlersKey] || null; 15806} 15807function updateFiberProps(node, props) { 15808 node[internalEventHandlersKey] = props; 15809} 15810 15811function getParent(inst) { 15812 do { 15813 inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. 15814 // That is depending on if we want nested subtrees (layers) to bubble 15815 // events to their parent. We could also go through parentNode on the 15816 // host node but that wouldn't work for React Native and doesn't let us 15817 // do the portal feature. 15818 } while (inst && inst.tag !== HostComponent); 15819 15820 if (inst) { 15821 return inst; 15822 } 15823 15824 return null; 15825} 15826/** 15827 * Return the lowest common ancestor of A and B, or null if they are in 15828 * different trees. 15829 */ 15830 15831 15832function getLowestCommonAncestor(instA, instB) { 15833 var depthA = 0; 15834 15835 for (var tempA = instA; tempA; tempA = getParent(tempA)) { 15836 depthA++; 15837 } 15838 15839 var depthB = 0; 15840 15841 for (var tempB = instB; tempB; tempB = getParent(tempB)) { 15842 depthB++; 15843 } // If A is deeper, crawl up. 15844 15845 15846 while (depthA - depthB > 0) { 15847 instA = getParent(instA); 15848 depthA--; 15849 } // If B is deeper, crawl up. 15850 15851 15852 while (depthB - depthA > 0) { 15853 instB = getParent(instB); 15854 depthB--; 15855 } // Walk in lockstep until we find a match. 15856 15857 15858 var depth = depthA; 15859 15860 while (depth--) { 15861 if (instA === instB || instA === instB.alternate) { 15862 return instA; 15863 } 15864 15865 instA = getParent(instA); 15866 instB = getParent(instB); 15867 } 15868 15869 return null; 15870} 15871/** 15872 * Simulates the traversal of a two-phase, capture/bubble event dispatch. 15873 */ 15874 15875function traverseTwoPhase(inst, fn, arg) { 15876 var path = []; 15877 15878 while (inst) { 15879 path.push(inst); 15880 inst = getParent(inst); 15881 } 15882 15883 var i; 15884 15885 for (i = path.length; i-- > 0;) { 15886 fn(path[i], 'captured', arg); 15887 } 15888 15889 for (i = 0; i < path.length; i++) { 15890 fn(path[i], 'bubbled', arg); 15891 } 15892} 15893/** 15894 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that 15895 * should would receive a `mouseEnter` or `mouseLeave` event. 15896 * 15897 * Does not invoke the callback on the nearest common ancestor because nothing 15898 * "entered" or "left" that element. 15899 */ 15900 15901function traverseEnterLeave(from, to, fn, argFrom, argTo) { 15902 var common = from && to ? getLowestCommonAncestor(from, to) : null; 15903 var pathFrom = []; 15904 15905 while (true) { 15906 if (!from) { 15907 break; 15908 } 15909 15910 if (from === common) { 15911 break; 15912 } 15913 15914 var alternate = from.alternate; 15915 15916 if (alternate !== null && alternate === common) { 15917 break; 15918 } 15919 15920 pathFrom.push(from); 15921 from = getParent(from); 15922 } 15923 15924 var pathTo = []; 15925 15926 while (true) { 15927 if (!to) { 15928 break; 15929 } 15930 15931 if (to === common) { 15932 break; 15933 } 15934 15935 var _alternate = to.alternate; 15936 15937 if (_alternate !== null && _alternate === common) { 15938 break; 15939 } 15940 15941 pathTo.push(to); 15942 to = getParent(to); 15943 } 15944 15945 for (var i = 0; i < pathFrom.length; i++) { 15946 fn(pathFrom[i], 'bubbled', argFrom); 15947 } 15948 15949 for (var _i = pathTo.length; _i-- > 0;) { 15950 fn(pathTo[_i], 'captured', argTo); 15951 } 15952} 15953 15954function isInteractive(tag) { 15955 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 15956} 15957 15958function shouldPreventMouseEvent(name, type, props) { 15959 switch (name) { 15960 case 'onClick': 15961 case 'onClickCapture': 15962 case 'onDoubleClick': 15963 case 'onDoubleClickCapture': 15964 case 'onMouseDown': 15965 case 'onMouseDownCapture': 15966 case 'onMouseMove': 15967 case 'onMouseMoveCapture': 15968 case 'onMouseUp': 15969 case 'onMouseUpCapture': 15970 case 'onMouseEnter': 15971 return !!(props.disabled && isInteractive(type)); 15972 15973 default: 15974 return false; 15975 } 15976} 15977/** 15978 * @param {object} inst The instance, which is the source of events. 15979 * @param {string} registrationName Name of listener (e.g. `onClick`). 15980 * @return {?function} The stored callback. 15981 */ 15982 15983 15984function getListener(inst, registrationName) { 15985 var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not 15986 // live here; needs to be moved to a better place soon 15987 15988 var stateNode = inst.stateNode; 15989 15990 if (!stateNode) { 15991 // Work in progress (ex: onload events in incremental mode). 15992 return null; 15993 } 15994 15995 var props = getFiberCurrentPropsFromNode(stateNode); 15996 15997 if (!props) { 15998 // Work in progress. 15999 return null; 16000 } 16001 16002 listener = props[registrationName]; 16003 16004 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 16005 return null; 16006 } 16007 16008 if (!(!listener || typeof listener === 'function')) { 16009 { 16010 throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); 16011 } 16012 } 16013 16014 return listener; 16015} 16016 16017/** 16018 * Some event types have a notion of different registration names for different 16019 * "phases" of propagation. This finds listeners by a given phase. 16020 */ 16021function listenerAtPhase(inst, event, propagationPhase) { 16022 var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; 16023 return getListener(inst, registrationName); 16024} 16025/** 16026 * A small set of propagation patterns, each of which will accept a small amount 16027 * of information, and generate a set of "dispatch ready event objects" - which 16028 * are sets of events that have already been annotated with a set of dispatched 16029 * listener functions/ids. The API is designed this way to discourage these 16030 * propagation strategies from actually executing the dispatches, since we 16031 * always want to collect the entire set of dispatches before executing even a 16032 * single one. 16033 */ 16034 16035/** 16036 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function 16037 * here, allows us to not have to bind or create functions for each event. 16038 * Mutating the event's members allows us to not have to create a wrapping 16039 * "dispatch" object that pairs the event with the listener. 16040 */ 16041 16042 16043function accumulateDirectionalDispatches(inst, phase, event) { 16044 { 16045 if (!inst) { 16046 error('Dispatching inst must not be null'); 16047 } 16048 } 16049 16050 var listener = listenerAtPhase(inst, event, phase); 16051 16052 if (listener) { 16053 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 16054 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 16055 } 16056} 16057/** 16058 * Collect dispatches (must be entirely collected before dispatching - see unit 16059 * tests). Lazily allocate the array to conserve memory. We must loop through 16060 * each event and perform the traversal for each one. We cannot perform a 16061 * single traversal for the entire collection of events because each event may 16062 * have a different target. 16063 */ 16064 16065 16066function accumulateTwoPhaseDispatchesSingle(event) { 16067 if (event && event.dispatchConfig.phasedRegistrationNames) { 16068 traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); 16069 } 16070} 16071/** 16072 * Accumulates without regard to direction, does not look for phased 16073 * registration names. Same as `accumulateDirectDispatchesSingle` but without 16074 * requiring that the `dispatchMarker` be the same as the dispatched ID. 16075 */ 16076 16077 16078function accumulateDispatches(inst, ignoredDirection, event) { 16079 if (inst && event && event.dispatchConfig.registrationName) { 16080 var registrationName = event.dispatchConfig.registrationName; 16081 var listener = getListener(inst, registrationName); 16082 16083 if (listener) { 16084 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 16085 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 16086 } 16087 } 16088} 16089/** 16090 * Accumulates dispatches on an `SyntheticEvent`, but only for the 16091 * `dispatchMarker`. 16092 * @param {SyntheticEvent} event 16093 */ 16094 16095 16096function accumulateDirectDispatchesSingle(event) { 16097 if (event && event.dispatchConfig.registrationName) { 16098 accumulateDispatches(event._targetInst, null, event); 16099 } 16100} 16101 16102function accumulateTwoPhaseDispatches(events) { 16103 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); 16104} 16105function accumulateEnterLeaveDispatches(leave, enter, from, to) { 16106 traverseEnterLeave(from, to, accumulateDispatches, leave, enter); 16107} 16108function accumulateDirectDispatches(events) { 16109 forEachAccumulated(events, accumulateDirectDispatchesSingle); 16110} 16111 16112/** 16113 * These variables store information about text content of a target node, 16114 * allowing comparison of content before and after a given event. 16115 * 16116 * Identify the node where selection currently begins, then observe 16117 * both its text content and its current position in the DOM. Since the 16118 * browser may natively replace the target node during composition, we can 16119 * use its position to find its replacement. 16120 * 16121 * 16122 */ 16123var root = null; 16124var startText = null; 16125var fallbackText = null; 16126function initialize(nativeEventTarget) { 16127 root = nativeEventTarget; 16128 startText = getText(); 16129 return true; 16130} 16131function reset() { 16132 root = null; 16133 startText = null; 16134 fallbackText = null; 16135} 16136function getData() { 16137 if (fallbackText) { 16138 return fallbackText; 16139 } 16140 16141 var start; 16142 var startValue = startText; 16143 var startLength = startValue.length; 16144 var end; 16145 var endValue = getText(); 16146 var endLength = endValue.length; 16147 16148 for (start = 0; start < startLength; start++) { 16149 if (startValue[start] !== endValue[start]) { 16150 break; 16151 } 16152 } 16153 16154 var minEnd = startLength - start; 16155 16156 for (end = 1; end <= minEnd; end++) { 16157 if (startValue[startLength - end] !== endValue[endLength - end]) { 16158 break; 16159 } 16160 } 16161 16162 var sliceTail = end > 1 ? 1 - end : undefined; 16163 fallbackText = endValue.slice(start, sliceTail); 16164 return fallbackText; 16165} 16166function getText() { 16167 if ('value' in root) { 16168 return root.value; 16169 } 16170 16171 return root.textContent; 16172} 16173 16174var EVENT_POOL_SIZE = 10; 16175/** 16176 * @interface Event 16177 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 16178 */ 16179 16180var EventInterface = { 16181 type: null, 16182 target: null, 16183 // currentTarget is set when dispatching; no use in copying it here 16184 currentTarget: function () { 16185 return null; 16186 }, 16187 eventPhase: null, 16188 bubbles: null, 16189 cancelable: null, 16190 timeStamp: function (event) { 16191 return event.timeStamp || Date.now(); 16192 }, 16193 defaultPrevented: null, 16194 isTrusted: null 16195}; 16196 16197function functionThatReturnsTrue() { 16198 return true; 16199} 16200 16201function functionThatReturnsFalse() { 16202 return false; 16203} 16204/** 16205 * Synthetic events are dispatched by event plugins, typically in response to a 16206 * top-level event delegation handler. 16207 * 16208 * These systems should generally use pooling to reduce the frequency of garbage 16209 * collection. The system should check `isPersistent` to determine whether the 16210 * event should be released into the pool after being dispatched. Users that 16211 * need a persisted event should invoke `persist`. 16212 * 16213 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 16214 * normalizing browser quirks. Subclasses do not necessarily have to implement a 16215 * DOM interface; custom application-specific events can also subclass this. 16216 * 16217 * @param {object} dispatchConfig Configuration used to dispatch this event. 16218 * @param {*} targetInst Marker identifying the event target. 16219 * @param {object} nativeEvent Native browser event. 16220 * @param {DOMEventTarget} nativeEventTarget Target node. 16221 */ 16222 16223 16224function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { 16225 { 16226 // these have a getter/setter for warnings 16227 delete this.nativeEvent; 16228 delete this.preventDefault; 16229 delete this.stopPropagation; 16230 delete this.isDefaultPrevented; 16231 delete this.isPropagationStopped; 16232 } 16233 16234 this.dispatchConfig = dispatchConfig; 16235 this._targetInst = targetInst; 16236 this.nativeEvent = nativeEvent; 16237 var Interface = this.constructor.Interface; 16238 16239 for (var propName in Interface) { 16240 if (!Interface.hasOwnProperty(propName)) { 16241 continue; 16242 } 16243 16244 { 16245 delete this[propName]; // this has a getter/setter for warnings 16246 } 16247 16248 var normalize = Interface[propName]; 16249 16250 if (normalize) { 16251 this[propName] = normalize(nativeEvent); 16252 } else { 16253 if (propName === 'target') { 16254 this.target = nativeEventTarget; 16255 } else { 16256 this[propName] = nativeEvent[propName]; 16257 } 16258 } 16259 } 16260 16261 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 16262 16263 if (defaultPrevented) { 16264 this.isDefaultPrevented = functionThatReturnsTrue; 16265 } else { 16266 this.isDefaultPrevented = functionThatReturnsFalse; 16267 } 16268 16269 this.isPropagationStopped = functionThatReturnsFalse; 16270 return this; 16271} 16272 16273_assign(SyntheticEvent.prototype, { 16274 preventDefault: function () { 16275 this.defaultPrevented = true; 16276 var event = this.nativeEvent; 16277 16278 if (!event) { 16279 return; 16280 } 16281 16282 if (event.preventDefault) { 16283 event.preventDefault(); 16284 } else if (typeof event.returnValue !== 'unknown') { 16285 event.returnValue = false; 16286 } 16287 16288 this.isDefaultPrevented = functionThatReturnsTrue; 16289 }, 16290 stopPropagation: function () { 16291 var event = this.nativeEvent; 16292 16293 if (!event) { 16294 return; 16295 } 16296 16297 if (event.stopPropagation) { 16298 event.stopPropagation(); 16299 } else if (typeof event.cancelBubble !== 'unknown') { 16300 // The ChangeEventPlugin registers a "propertychange" event for 16301 // IE. This event does not support bubbling or cancelling, and 16302 // any references to cancelBubble throw "Member not found". A 16303 // typeof check of "unknown" circumvents this issue (and is also 16304 // IE specific). 16305 event.cancelBubble = true; 16306 } 16307 16308 this.isPropagationStopped = functionThatReturnsTrue; 16309 }, 16310 16311 /** 16312 * We release all dispatched `SyntheticEvent`s after each event loop, adding 16313 * them back into the pool. This allows a way to hold onto a reference that 16314 * won't be added back into the pool. 16315 */ 16316 persist: function () { 16317 this.isPersistent = functionThatReturnsTrue; 16318 }, 16319 16320 /** 16321 * Checks if this event should be released back into the pool. 16322 * 16323 * @return {boolean} True if this should not be released, false otherwise. 16324 */ 16325 isPersistent: functionThatReturnsFalse, 16326 16327 /** 16328 * `PooledClass` looks for `destructor` on each instance it releases. 16329 */ 16330 destructor: function () { 16331 var Interface = this.constructor.Interface; 16332 16333 for (var propName in Interface) { 16334 { 16335 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); 16336 } 16337 } 16338 16339 this.dispatchConfig = null; 16340 this._targetInst = null; 16341 this.nativeEvent = null; 16342 this.isDefaultPrevented = functionThatReturnsFalse; 16343 this.isPropagationStopped = functionThatReturnsFalse; 16344 this._dispatchListeners = null; 16345 this._dispatchInstances = null; 16346 16347 { 16348 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); 16349 Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse)); 16350 Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse)); 16351 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {})); 16352 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {})); 16353 } 16354 } 16355}); 16356 16357SyntheticEvent.Interface = EventInterface; 16358/** 16359 * Helper to reduce boilerplate when creating subclasses. 16360 */ 16361 16362SyntheticEvent.extend = function (Interface) { 16363 var Super = this; 16364 16365 var E = function () {}; 16366 16367 E.prototype = Super.prototype; 16368 var prototype = new E(); 16369 16370 function Class() { 16371 return Super.apply(this, arguments); 16372 } 16373 16374 _assign(prototype, Class.prototype); 16375 16376 Class.prototype = prototype; 16377 Class.prototype.constructor = Class; 16378 Class.Interface = _assign({}, Super.Interface, Interface); 16379 Class.extend = Super.extend; 16380 addEventPoolingTo(Class); 16381 return Class; 16382}; 16383 16384addEventPoolingTo(SyntheticEvent); 16385/** 16386 * Helper to nullify syntheticEvent instance properties when destructing 16387 * 16388 * @param {String} propName 16389 * @param {?object} getVal 16390 * @return {object} defineProperty object 16391 */ 16392 16393function getPooledWarningPropertyDefinition(propName, getVal) { 16394 var isFunction = typeof getVal === 'function'; 16395 return { 16396 configurable: true, 16397 set: set, 16398 get: get 16399 }; 16400 16401 function set(val) { 16402 var action = isFunction ? 'setting the method' : 'setting the property'; 16403 warn(action, 'This is effectively a no-op'); 16404 return val; 16405 } 16406 16407 function get() { 16408 var action = isFunction ? 'accessing the method' : 'accessing the property'; 16409 var result = isFunction ? 'This is a no-op function' : 'This is set to null'; 16410 warn(action, result); 16411 return getVal; 16412 } 16413 16414 function warn(action, result) { 16415 { 16416 error("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); 16417 } 16418 } 16419} 16420 16421function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { 16422 var EventConstructor = this; 16423 16424 if (EventConstructor.eventPool.length) { 16425 var instance = EventConstructor.eventPool.pop(); 16426 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); 16427 return instance; 16428 } 16429 16430 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); 16431} 16432 16433function releasePooledEvent(event) { 16434 var EventConstructor = this; 16435 16436 if (!(event instanceof EventConstructor)) { 16437 { 16438 throw Error( "Trying to release an event instance into a pool of a different type." ); 16439 } 16440 } 16441 16442 event.destructor(); 16443 16444 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { 16445 EventConstructor.eventPool.push(event); 16446 } 16447} 16448 16449function addEventPoolingTo(EventConstructor) { 16450 EventConstructor.eventPool = []; 16451 EventConstructor.getPooled = getPooledEvent; 16452 EventConstructor.release = releasePooledEvent; 16453} 16454 16455/** 16456 * @interface Event 16457 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 16458 */ 16459 16460var SyntheticCompositionEvent = SyntheticEvent.extend({ 16461 data: null 16462}); 16463 16464/** 16465 * @interface Event 16466 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 16467 * /#events-inputevents 16468 */ 16469 16470var SyntheticInputEvent = SyntheticEvent.extend({ 16471 data: null 16472}); 16473 16474var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 16475 16476var START_KEYCODE = 229; 16477var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; 16478var documentMode = null; 16479 16480if (canUseDOM && 'documentMode' in document) { 16481 documentMode = document.documentMode; 16482} // Webkit offers a very useful `textInput` event that can be used to 16483// directly represent `beforeInput`. The IE `textinput` event is not as 16484// useful, so we don't use it. 16485 16486 16487var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied 16488// by the native compositionend event may be incorrect. Japanese ideographic 16489// spaces, for instance (\u3000) are not recorded correctly. 16490 16491var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 16492var SPACEBAR_CODE = 32; 16493var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names. 16494 16495var eventTypes = { 16496 beforeInput: { 16497 phasedRegistrationNames: { 16498 bubbled: 'onBeforeInput', 16499 captured: 'onBeforeInputCapture' 16500 }, 16501 dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE] 16502 }, 16503 compositionEnd: { 16504 phasedRegistrationNames: { 16505 bubbled: 'onCompositionEnd', 16506 captured: 'onCompositionEndCapture' 16507 }, 16508 dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 16509 }, 16510 compositionStart: { 16511 phasedRegistrationNames: { 16512 bubbled: 'onCompositionStart', 16513 captured: 'onCompositionStartCapture' 16514 }, 16515 dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 16516 }, 16517 compositionUpdate: { 16518 phasedRegistrationNames: { 16519 bubbled: 'onCompositionUpdate', 16520 captured: 'onCompositionUpdateCapture' 16521 }, 16522 dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 16523 } 16524}; // Track whether we've ever handled a keypress on the space key. 16525 16526var hasSpaceKeypress = false; 16527/** 16528 * Return whether a native keypress event is assumed to be a command. 16529 * This is required because Firefox fires `keypress` events for key commands 16530 * (cut, copy, select-all, etc.) even though no character is inserted. 16531 */ 16532 16533function isKeypressCommand(nativeEvent) { 16534 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. 16535 !(nativeEvent.ctrlKey && nativeEvent.altKey); 16536} 16537/** 16538 * Translate native top level events into event types. 16539 * 16540 * @param {string} topLevelType 16541 * @return {object} 16542 */ 16543 16544 16545function getCompositionEventType(topLevelType) { 16546 switch (topLevelType) { 16547 case TOP_COMPOSITION_START: 16548 return eventTypes.compositionStart; 16549 16550 case TOP_COMPOSITION_END: 16551 return eventTypes.compositionEnd; 16552 16553 case TOP_COMPOSITION_UPDATE: 16554 return eventTypes.compositionUpdate; 16555 } 16556} 16557/** 16558 * Does our fallback best-guess model think this event signifies that 16559 * composition has begun? 16560 * 16561 * @param {string} topLevelType 16562 * @param {object} nativeEvent 16563 * @return {boolean} 16564 */ 16565 16566 16567function isFallbackCompositionStart(topLevelType, nativeEvent) { 16568 return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE; 16569} 16570/** 16571 * Does our fallback mode think that this event is the end of composition? 16572 * 16573 * @param {string} topLevelType 16574 * @param {object} nativeEvent 16575 * @return {boolean} 16576 */ 16577 16578 16579function isFallbackCompositionEnd(topLevelType, nativeEvent) { 16580 switch (topLevelType) { 16581 case TOP_KEY_UP: 16582 // Command keys insert or clear IME input. 16583 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 16584 16585 case TOP_KEY_DOWN: 16586 // Expect IME keyCode on each keydown. If we get any other 16587 // code we must have exited earlier. 16588 return nativeEvent.keyCode !== START_KEYCODE; 16589 16590 case TOP_KEY_PRESS: 16591 case TOP_MOUSE_DOWN: 16592 case TOP_BLUR: 16593 // Events are not possible without cancelling IME. 16594 return true; 16595 16596 default: 16597 return false; 16598 } 16599} 16600/** 16601 * Google Input Tools provides composition data via a CustomEvent, 16602 * with the `data` property populated in the `detail` object. If this 16603 * is available on the event object, use it. If not, this is a plain 16604 * composition event and we have nothing special to extract. 16605 * 16606 * @param {object} nativeEvent 16607 * @return {?string} 16608 */ 16609 16610 16611function getDataFromCustomEvent(nativeEvent) { 16612 var detail = nativeEvent.detail; 16613 16614 if (typeof detail === 'object' && 'data' in detail) { 16615 return detail.data; 16616 } 16617 16618 return null; 16619} 16620/** 16621 * Check if a composition event was triggered by Korean IME. 16622 * Our fallback mode does not work well with IE's Korean IME, 16623 * so just use native composition events when Korean IME is used. 16624 * Although CompositionEvent.locale property is deprecated, 16625 * it is available in IE, where our fallback mode is enabled. 16626 * 16627 * @param {object} nativeEvent 16628 * @return {boolean} 16629 */ 16630 16631 16632function isUsingKoreanIME(nativeEvent) { 16633 return nativeEvent.locale === 'ko'; 16634} // Track the current IME composition status, if any. 16635 16636 16637var isComposing = false; 16638/** 16639 * @return {?object} A SyntheticCompositionEvent. 16640 */ 16641 16642function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 16643 var eventType; 16644 var fallbackData; 16645 16646 if (canUseCompositionEvent) { 16647 eventType = getCompositionEventType(topLevelType); 16648 } else if (!isComposing) { 16649 if (isFallbackCompositionStart(topLevelType, nativeEvent)) { 16650 eventType = eventTypes.compositionStart; 16651 } 16652 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { 16653 eventType = eventTypes.compositionEnd; 16654 } 16655 16656 if (!eventType) { 16657 return null; 16658 } 16659 16660 if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { 16661 // The current composition is stored statically and must not be 16662 // overwritten while composition continues. 16663 if (!isComposing && eventType === eventTypes.compositionStart) { 16664 isComposing = initialize(nativeEventTarget); 16665 } else if (eventType === eventTypes.compositionEnd) { 16666 if (isComposing) { 16667 fallbackData = getData(); 16668 } 16669 } 16670 } 16671 16672 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); 16673 16674 if (fallbackData) { 16675 // Inject data generated from fallback path into the synthetic event. 16676 // This matches the property of native CompositionEventInterface. 16677 event.data = fallbackData; 16678 } else { 16679 var customData = getDataFromCustomEvent(nativeEvent); 16680 16681 if (customData !== null) { 16682 event.data = customData; 16683 } 16684 } 16685 16686 accumulateTwoPhaseDispatches(event); 16687 return event; 16688} 16689/** 16690 * @param {TopLevelType} topLevelType Number from `TopLevelType`. 16691 * @param {object} nativeEvent Native browser event. 16692 * @return {?string} The string corresponding to this `beforeInput` event. 16693 */ 16694 16695 16696function getNativeBeforeInputChars(topLevelType, nativeEvent) { 16697 switch (topLevelType) { 16698 case TOP_COMPOSITION_END: 16699 return getDataFromCustomEvent(nativeEvent); 16700 16701 case TOP_KEY_PRESS: 16702 /** 16703 * If native `textInput` events are available, our goal is to make 16704 * use of them. However, there is a special case: the spacebar key. 16705 * In Webkit, preventing default on a spacebar `textInput` event 16706 * cancels character insertion, but it *also* causes the browser 16707 * to fall back to its default spacebar behavior of scrolling the 16708 * page. 16709 * 16710 * Tracking at: 16711 * https://code.google.com/p/chromium/issues/detail?id=355103 16712 * 16713 * To avoid this issue, use the keypress event as if no `textInput` 16714 * event is available. 16715 */ 16716 var which = nativeEvent.which; 16717 16718 if (which !== SPACEBAR_CODE) { 16719 return null; 16720 } 16721 16722 hasSpaceKeypress = true; 16723 return SPACEBAR_CHAR; 16724 16725 case TOP_TEXT_INPUT: 16726 // Record the characters to be added to the DOM. 16727 var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled 16728 // it at the keypress level and bail immediately. Android Chrome 16729 // doesn't give us keycodes, so we need to ignore it. 16730 16731 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 16732 return null; 16733 } 16734 16735 return chars; 16736 16737 default: 16738 // For other native event types, do nothing. 16739 return null; 16740 } 16741} 16742/** 16743 * For browsers that do not provide the `textInput` event, extract the 16744 * appropriate string to use for SyntheticInputEvent. 16745 * 16746 * @param {number} topLevelType Number from `TopLevelEventTypes`. 16747 * @param {object} nativeEvent Native browser event. 16748 * @return {?string} The fallback string for this `beforeInput` event. 16749 */ 16750 16751 16752function getFallbackBeforeInputChars(topLevelType, nativeEvent) { 16753 // If we are currently composing (IME) and using a fallback to do so, 16754 // try to extract the composed characters from the fallback object. 16755 // If composition event is available, we extract a string only at 16756 // compositionevent, otherwise extract it at fallback events. 16757 if (isComposing) { 16758 if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { 16759 var chars = getData(); 16760 reset(); 16761 isComposing = false; 16762 return chars; 16763 } 16764 16765 return null; 16766 } 16767 16768 switch (topLevelType) { 16769 case TOP_PASTE: 16770 // If a paste event occurs after a keypress, throw out the input 16771 // chars. Paste events should not lead to BeforeInput events. 16772 return null; 16773 16774 case TOP_KEY_PRESS: 16775 /** 16776 * As of v27, Firefox may fire keypress events even when no character 16777 * will be inserted. A few possibilities: 16778 * 16779 * - `which` is `0`. Arrow keys, Esc key, etc. 16780 * 16781 * - `which` is the pressed key code, but no char is available. 16782 * Ex: 'AltGr + d` in Polish. There is no modified character for 16783 * this key combination and no character is inserted into the 16784 * document, but FF fires the keypress for char code `100` anyway. 16785 * No `input` event will occur. 16786 * 16787 * - `which` is the pressed key code, but a command combination is 16788 * being used. Ex: `Cmd+C`. No character is inserted, and no 16789 * `input` event will occur. 16790 */ 16791 if (!isKeypressCommand(nativeEvent)) { 16792 // IE fires the `keypress` event when a user types an emoji via 16793 // Touch keyboard of Windows. In such a case, the `char` property 16794 // holds an emoji character like `\uD83D\uDE0A`. Because its length 16795 // is 2, the property `which` does not represent an emoji correctly. 16796 // In such a case, we directly return the `char` property instead of 16797 // using `which`. 16798 if (nativeEvent.char && nativeEvent.char.length > 1) { 16799 return nativeEvent.char; 16800 } else if (nativeEvent.which) { 16801 return String.fromCharCode(nativeEvent.which); 16802 } 16803 } 16804 16805 return null; 16806 16807 case TOP_COMPOSITION_END: 16808 return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; 16809 16810 default: 16811 return null; 16812 } 16813} 16814/** 16815 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 16816 * `textInput` or fallback behavior. 16817 * 16818 * @return {?object} A SyntheticInputEvent. 16819 */ 16820 16821 16822function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 16823 var chars; 16824 16825 if (canUseTextInputEvent) { 16826 chars = getNativeBeforeInputChars(topLevelType, nativeEvent); 16827 } else { 16828 chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); 16829 } // If no characters are being inserted, no BeforeInput event should 16830 // be fired. 16831 16832 16833 if (!chars) { 16834 return null; 16835 } 16836 16837 var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); 16838 event.data = chars; 16839 accumulateTwoPhaseDispatches(event); 16840 return event; 16841} 16842/** 16843 * Create an `onBeforeInput` event to match 16844 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 16845 * 16846 * This event plugin is based on the native `textInput` event 16847 * available in Chrome, Safari, Opera, and IE. This event fires after 16848 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 16849 * 16850 * `beforeInput` is spec'd but not implemented in any browsers, and 16851 * the `input` event does not provide any useful information about what has 16852 * actually been added, contrary to the spec. Thus, `textInput` is the best 16853 * available event to identify the characters that have actually been inserted 16854 * into the target node. 16855 * 16856 * This plugin is also responsible for emitting `composition` events, thus 16857 * allowing us to share composition fallback code for both `beforeInput` and 16858 * `composition` event types. 16859 */ 16860 16861 16862var BeforeInputEventPlugin = { 16863 eventTypes: eventTypes, 16864 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 16865 var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 16866 var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 16867 16868 if (composition === null) { 16869 return beforeInput; 16870 } 16871 16872 if (beforeInput === null) { 16873 return composition; 16874 } 16875 16876 return [composition, beforeInput]; 16877 } 16878}; 16879 16880/** 16881 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 16882 */ 16883var supportedInputTypes = { 16884 color: true, 16885 date: true, 16886 datetime: true, 16887 'datetime-local': true, 16888 email: true, 16889 month: true, 16890 number: true, 16891 password: true, 16892 range: true, 16893 search: true, 16894 tel: true, 16895 text: true, 16896 time: true, 16897 url: true, 16898 week: true 16899}; 16900 16901function isTextInputElement(elem) { 16902 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 16903 16904 if (nodeName === 'input') { 16905 return !!supportedInputTypes[elem.type]; 16906 } 16907 16908 if (nodeName === 'textarea') { 16909 return true; 16910 } 16911 16912 return false; 16913} 16914 16915var eventTypes$1 = { 16916 change: { 16917 phasedRegistrationNames: { 16918 bubbled: 'onChange', 16919 captured: 'onChangeCapture' 16920 }, 16921 dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE] 16922 } 16923}; 16924 16925function createAndAccumulateChangeEvent(inst, nativeEvent, target) { 16926 var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target); 16927 event.type = 'change'; // Flag this event loop as needing state restore. 16928 16929 enqueueStateRestore(target); 16930 accumulateTwoPhaseDispatches(event); 16931 return event; 16932} 16933/** 16934 * For IE shims 16935 */ 16936 16937 16938var activeElement = null; 16939var activeElementInst = null; 16940/** 16941 * SECTION: handle `change` event 16942 */ 16943 16944function shouldUseChangeEvent(elem) { 16945 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 16946 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 16947} 16948 16949function manualDispatchChangeEvent(nativeEvent) { 16950 var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the 16951 // other events and have it go through ReactBrowserEventEmitter. Since it 16952 // doesn't, we manually listen for the events and so we have to enqueue and 16953 // process the abstract event manually. 16954 // 16955 // Batching is necessary here in order to ensure that all event handlers run 16956 // before the next rerender (including event handlers attached to ancestor 16957 // elements instead of directly on the input). Without this, controlled 16958 // components don't work properly in conjunction with event bubbling because 16959 // the component is rerendered and the value reverted before all the event 16960 // handlers can run. See https://github.com/facebook/react/issues/708. 16961 16962 batchedUpdates(runEventInBatch, event); 16963} 16964 16965function runEventInBatch(event) { 16966 runEventsInBatch(event); 16967} 16968 16969function getInstIfValueChanged(targetInst) { 16970 var targetNode = getNodeFromInstance$1(targetInst); 16971 16972 if (updateValueIfChanged(targetNode)) { 16973 return targetInst; 16974 } 16975} 16976 16977function getTargetInstForChangeEvent(topLevelType, targetInst) { 16978 if (topLevelType === TOP_CHANGE) { 16979 return targetInst; 16980 } 16981} 16982/** 16983 * SECTION: handle `input` event 16984 */ 16985 16986 16987var isInputEventSupported = false; 16988 16989if (canUseDOM) { 16990 // IE9 claims to support the input event but fails to trigger it when 16991 // deleting text, so we ignore its input events. 16992 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 16993} 16994/** 16995 * (For IE <=9) Starts tracking propertychange events on the passed-in element 16996 * and override the value property so that we can distinguish user events from 16997 * value changes in JS. 16998 */ 16999 17000 17001function startWatchingForValueChange(target, targetInst) { 17002 activeElement = target; 17003 activeElementInst = targetInst; 17004 activeElement.attachEvent('onpropertychange', handlePropertyChange); 17005} 17006/** 17007 * (For IE <=9) Removes the event listeners from the currently-tracked element, 17008 * if any exists. 17009 */ 17010 17011 17012function stopWatchingForValueChange() { 17013 if (!activeElement) { 17014 return; 17015 } 17016 17017 activeElement.detachEvent('onpropertychange', handlePropertyChange); 17018 activeElement = null; 17019 activeElementInst = null; 17020} 17021/** 17022 * (For IE <=9) Handles a propertychange event, sending a `change` event if 17023 * the value of the active element has changed. 17024 */ 17025 17026 17027function handlePropertyChange(nativeEvent) { 17028 if (nativeEvent.propertyName !== 'value') { 17029 return; 17030 } 17031 17032 if (getInstIfValueChanged(activeElementInst)) { 17033 manualDispatchChangeEvent(nativeEvent); 17034 } 17035} 17036 17037function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { 17038 if (topLevelType === TOP_FOCUS) { 17039 // In IE9, propertychange fires for most input events but is buggy and 17040 // doesn't fire when text is deleted, but conveniently, selectionchange 17041 // appears to fire in all of the remaining cases so we catch those and 17042 // forward the event if the value has changed 17043 // In either case, we don't want to call the event handler if the value 17044 // is changed from JS so we redefine a setter for `.value` that updates 17045 // our activeElementValue variable, allowing us to ignore those changes 17046 // 17047 // stopWatching() should be a noop here but we call it just in case we 17048 // missed a blur event somehow. 17049 stopWatchingForValueChange(); 17050 startWatchingForValueChange(target, targetInst); 17051 } else if (topLevelType === TOP_BLUR) { 17052 stopWatchingForValueChange(); 17053 } 17054} // For IE8 and IE9. 17055 17056 17057function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { 17058 if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) { 17059 // On the selectionchange event, the target is just document which isn't 17060 // helpful for us so just check activeElement instead. 17061 // 17062 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 17063 // propertychange on the first input event after setting `value` from a 17064 // script and fires only keydown, keypress, keyup. Catching keyup usually 17065 // gets it and catching keydown lets us fire an event for the first 17066 // keystroke if user does a key repeat (it'll be a little delayed: right 17067 // before the second keystroke). Other input methods (e.g., paste) seem to 17068 // fire selectionchange normally. 17069 return getInstIfValueChanged(activeElementInst); 17070 } 17071} 17072/** 17073 * SECTION: handle `click` event 17074 */ 17075 17076 17077function shouldUseClickEvent(elem) { 17078 // Use the `click` event to detect changes to checkbox and radio inputs. 17079 // This approach works across all browsers, whereas `change` does not fire 17080 // until `blur` in IE8. 17081 var nodeName = elem.nodeName; 17082 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 17083} 17084 17085function getTargetInstForClickEvent(topLevelType, targetInst) { 17086 if (topLevelType === TOP_CLICK) { 17087 return getInstIfValueChanged(targetInst); 17088 } 17089} 17090 17091function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { 17092 if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) { 17093 return getInstIfValueChanged(targetInst); 17094 } 17095} 17096 17097function handleControlledInputBlur(node) { 17098 var state = node._wrapperState; 17099 17100 if (!state || !state.controlled || node.type !== 'number') { 17101 return; 17102 } 17103 17104 { 17105 // If controlled, assign the value attribute to the current value on blur 17106 setDefaultValue(node, 'number', node.value); 17107 } 17108} 17109/** 17110 * This plugin creates an `onChange` event that normalizes change events 17111 * across form elements. This event fires at a time when it's possible to 17112 * change the element's value without seeing a flicker. 17113 * 17114 * Supported elements are: 17115 * - input (see `isTextInputElement`) 17116 * - textarea 17117 * - select 17118 */ 17119 17120 17121var ChangeEventPlugin = { 17122 eventTypes: eventTypes$1, 17123 _isInputEventSupported: isInputEventSupported, 17124 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 17125 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 17126 var getTargetInstFunc, handleEventFunc; 17127 17128 if (shouldUseChangeEvent(targetNode)) { 17129 getTargetInstFunc = getTargetInstForChangeEvent; 17130 } else if (isTextInputElement(targetNode)) { 17131 if (isInputEventSupported) { 17132 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 17133 } else { 17134 getTargetInstFunc = getTargetInstForInputEventPolyfill; 17135 handleEventFunc = handleEventsForInputEventPolyfill; 17136 } 17137 } else if (shouldUseClickEvent(targetNode)) { 17138 getTargetInstFunc = getTargetInstForClickEvent; 17139 } 17140 17141 if (getTargetInstFunc) { 17142 var inst = getTargetInstFunc(topLevelType, targetInst); 17143 17144 if (inst) { 17145 var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); 17146 return event; 17147 } 17148 } 17149 17150 if (handleEventFunc) { 17151 handleEventFunc(topLevelType, targetNode, targetInst); 17152 } // When blurring, set the value attribute for number inputs 17153 17154 17155 if (topLevelType === TOP_BLUR) { 17156 handleControlledInputBlur(targetNode); 17157 } 17158 } 17159}; 17160 17161var SyntheticUIEvent = SyntheticEvent.extend({ 17162 view: null, 17163 detail: null 17164}); 17165 17166/** 17167 * Translation from modifier key to the associated property in the event. 17168 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 17169 */ 17170var modifierKeyToProp = { 17171 Alt: 'altKey', 17172 Control: 'ctrlKey', 17173 Meta: 'metaKey', 17174 Shift: 'shiftKey' 17175}; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support 17176// getModifierState. If getModifierState is not supported, we map it to a set of 17177// modifier keys exposed by the event. In this case, Lock-keys are not supported. 17178 17179function modifierStateGetter(keyArg) { 17180 var syntheticEvent = this; 17181 var nativeEvent = syntheticEvent.nativeEvent; 17182 17183 if (nativeEvent.getModifierState) { 17184 return nativeEvent.getModifierState(keyArg); 17185 } 17186 17187 var keyProp = modifierKeyToProp[keyArg]; 17188 return keyProp ? !!nativeEvent[keyProp] : false; 17189} 17190 17191function getEventModifierState(nativeEvent) { 17192 return modifierStateGetter; 17193} 17194 17195var previousScreenX = 0; 17196var previousScreenY = 0; // Use flags to signal movementX/Y has already been set 17197 17198var isMovementXSet = false; 17199var isMovementYSet = false; 17200/** 17201 * @interface MouseEvent 17202 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 17203 */ 17204 17205var SyntheticMouseEvent = SyntheticUIEvent.extend({ 17206 screenX: null, 17207 screenY: null, 17208 clientX: null, 17209 clientY: null, 17210 pageX: null, 17211 pageY: null, 17212 ctrlKey: null, 17213 shiftKey: null, 17214 altKey: null, 17215 metaKey: null, 17216 getModifierState: getEventModifierState, 17217 button: null, 17218 buttons: null, 17219 relatedTarget: function (event) { 17220 return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); 17221 }, 17222 movementX: function (event) { 17223 if ('movementX' in event) { 17224 return event.movementX; 17225 } 17226 17227 var screenX = previousScreenX; 17228 previousScreenX = event.screenX; 17229 17230 if (!isMovementXSet) { 17231 isMovementXSet = true; 17232 return 0; 17233 } 17234 17235 return event.type === 'mousemove' ? event.screenX - screenX : 0; 17236 }, 17237 movementY: function (event) { 17238 if ('movementY' in event) { 17239 return event.movementY; 17240 } 17241 17242 var screenY = previousScreenY; 17243 previousScreenY = event.screenY; 17244 17245 if (!isMovementYSet) { 17246 isMovementYSet = true; 17247 return 0; 17248 } 17249 17250 return event.type === 'mousemove' ? event.screenY - screenY : 0; 17251 } 17252}); 17253 17254/** 17255 * @interface PointerEvent 17256 * @see http://www.w3.org/TR/pointerevents/ 17257 */ 17258 17259var SyntheticPointerEvent = SyntheticMouseEvent.extend({ 17260 pointerId: null, 17261 width: null, 17262 height: null, 17263 pressure: null, 17264 tangentialPressure: null, 17265 tiltX: null, 17266 tiltY: null, 17267 twist: null, 17268 pointerType: null, 17269 isPrimary: null 17270}); 17271 17272var eventTypes$2 = { 17273 mouseEnter: { 17274 registrationName: 'onMouseEnter', 17275 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 17276 }, 17277 mouseLeave: { 17278 registrationName: 'onMouseLeave', 17279 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 17280 }, 17281 pointerEnter: { 17282 registrationName: 'onPointerEnter', 17283 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 17284 }, 17285 pointerLeave: { 17286 registrationName: 'onPointerLeave', 17287 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 17288 } 17289}; 17290var EnterLeaveEventPlugin = { 17291 eventTypes: eventTypes$2, 17292 17293 /** 17294 * For almost every interaction we care about, there will be both a top-level 17295 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 17296 * we do not extract duplicate events. However, moving the mouse into the 17297 * browser from outside will not fire a `mouseout` event. In this case, we use 17298 * the `mouseover` top-level event. 17299 */ 17300 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 17301 var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER; 17302 var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT; 17303 17304 if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { 17305 // If this is an over event with a target, then we've already dispatched 17306 // the event in the out event of the other target. If this is replayed, 17307 // then it's because we couldn't dispatch against this target previously 17308 // so we have to do it now instead. 17309 return null; 17310 } 17311 17312 if (!isOutEvent && !isOverEvent) { 17313 // Must not be a mouse or pointer in or out - ignoring. 17314 return null; 17315 } 17316 17317 var win; 17318 17319 if (nativeEventTarget.window === nativeEventTarget) { 17320 // `nativeEventTarget` is probably a window object. 17321 win = nativeEventTarget; 17322 } else { 17323 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 17324 var doc = nativeEventTarget.ownerDocument; 17325 17326 if (doc) { 17327 win = doc.defaultView || doc.parentWindow; 17328 } else { 17329 win = window; 17330 } 17331 } 17332 17333 var from; 17334 var to; 17335 17336 if (isOutEvent) { 17337 from = targetInst; 17338 var related = nativeEvent.relatedTarget || nativeEvent.toElement; 17339 to = related ? getClosestInstanceFromNode(related) : null; 17340 17341 if (to !== null) { 17342 var nearestMounted = getNearestMountedFiber(to); 17343 17344 if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { 17345 to = null; 17346 } 17347 } 17348 } else { 17349 // Moving to a node from outside the window. 17350 from = null; 17351 to = targetInst; 17352 } 17353 17354 if (from === to) { 17355 // Nothing pertains to our managed components. 17356 return null; 17357 } 17358 17359 var eventInterface, leaveEventType, enterEventType, eventTypePrefix; 17360 17361 if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) { 17362 eventInterface = SyntheticMouseEvent; 17363 leaveEventType = eventTypes$2.mouseLeave; 17364 enterEventType = eventTypes$2.mouseEnter; 17365 eventTypePrefix = 'mouse'; 17366 } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) { 17367 eventInterface = SyntheticPointerEvent; 17368 leaveEventType = eventTypes$2.pointerLeave; 17369 enterEventType = eventTypes$2.pointerEnter; 17370 eventTypePrefix = 'pointer'; 17371 } 17372 17373 var fromNode = from == null ? win : getNodeFromInstance$1(from); 17374 var toNode = to == null ? win : getNodeFromInstance$1(to); 17375 var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget); 17376 leave.type = eventTypePrefix + 'leave'; 17377 leave.target = fromNode; 17378 leave.relatedTarget = toNode; 17379 var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget); 17380 enter.type = eventTypePrefix + 'enter'; 17381 enter.target = toNode; 17382 enter.relatedTarget = fromNode; 17383 accumulateEnterLeaveDispatches(leave, enter, from, to); // If we are not processing the first ancestor, then we 17384 // should not process the same nativeEvent again, as we 17385 // will have already processed it in the first ancestor. 17386 17387 if ((eventSystemFlags & IS_FIRST_ANCESTOR) === 0) { 17388 return [leave]; 17389 } 17390 17391 return [leave, enter]; 17392 } 17393}; 17394 17395/** 17396 * inlined Object.is polyfill to avoid requiring consumers ship their own 17397 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 17398 */ 17399function is(x, y) { 17400 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare 17401 ; 17402} 17403 17404var objectIs = typeof Object.is === 'function' ? Object.is : is; 17405 17406var hasOwnProperty$2 = Object.prototype.hasOwnProperty; 17407/** 17408 * Performs equality by iterating through keys on an object and returning false 17409 * when any key has values which are not strictly equal between the arguments. 17410 * Returns true when the values of all keys are strictly equal. 17411 */ 17412 17413function shallowEqual(objA, objB) { 17414 if (objectIs(objA, objB)) { 17415 return true; 17416 } 17417 17418 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 17419 return false; 17420 } 17421 17422 var keysA = Object.keys(objA); 17423 var keysB = Object.keys(objB); 17424 17425 if (keysA.length !== keysB.length) { 17426 return false; 17427 } // Test for A's keys different from B. 17428 17429 17430 for (var i = 0; i < keysA.length; i++) { 17431 if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { 17432 return false; 17433 } 17434 } 17435 17436 return true; 17437} 17438 17439var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; 17440var eventTypes$3 = { 17441 select: { 17442 phasedRegistrationNames: { 17443 bubbled: 'onSelect', 17444 captured: 'onSelectCapture' 17445 }, 17446 dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_DRAG_END, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE] 17447 } 17448}; 17449var activeElement$1 = null; 17450var activeElementInst$1 = null; 17451var lastSelection = null; 17452var mouseDown = false; 17453/** 17454 * Get an object which is a unique representation of the current selection. 17455 * 17456 * The return value will not be consistent across nodes or browsers, but 17457 * two identical selections on the same node will return identical objects. 17458 * 17459 * @param {DOMElement} node 17460 * @return {object} 17461 */ 17462 17463function getSelection$1(node) { 17464 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 17465 return { 17466 start: node.selectionStart, 17467 end: node.selectionEnd 17468 }; 17469 } else { 17470 var win = node.ownerDocument && node.ownerDocument.defaultView || window; 17471 var selection = win.getSelection(); 17472 return { 17473 anchorNode: selection.anchorNode, 17474 anchorOffset: selection.anchorOffset, 17475 focusNode: selection.focusNode, 17476 focusOffset: selection.focusOffset 17477 }; 17478 } 17479} 17480/** 17481 * Get document associated with the event target. 17482 * 17483 * @param {object} nativeEventTarget 17484 * @return {Document} 17485 */ 17486 17487 17488function getEventTargetDocument(eventTarget) { 17489 return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; 17490} 17491/** 17492 * Poll selection to see whether it's changed. 17493 * 17494 * @param {object} nativeEvent 17495 * @param {object} nativeEventTarget 17496 * @return {?SyntheticEvent} 17497 */ 17498 17499 17500function constructSelectEvent(nativeEvent, nativeEventTarget) { 17501 // Ensure we have the right element, and that the user is not dragging a 17502 // selection (this matches native `select` event behavior). In HTML5, select 17503 // fires only on input and textarea thus if there's no focused element we 17504 // won't dispatch. 17505 var doc = getEventTargetDocument(nativeEventTarget); 17506 17507 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { 17508 return null; 17509 } // Only fire when selection has actually changed. 17510 17511 17512 var currentSelection = getSelection$1(activeElement$1); 17513 17514 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 17515 lastSelection = currentSelection; 17516 var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); 17517 syntheticEvent.type = 'select'; 17518 syntheticEvent.target = activeElement$1; 17519 accumulateTwoPhaseDispatches(syntheticEvent); 17520 return syntheticEvent; 17521 } 17522 17523 return null; 17524} 17525/** 17526 * This plugin creates an `onSelect` event that normalizes select events 17527 * across form elements. 17528 * 17529 * Supported elements are: 17530 * - input (see `isTextInputElement`) 17531 * - textarea 17532 * - contentEditable 17533 * 17534 * This differs from native browser implementations in the following ways: 17535 * - Fires on contentEditable fields as well as inputs. 17536 * - Fires for collapsed selection. 17537 * - Fires after user input. 17538 */ 17539 17540 17541var SelectEventPlugin = { 17542 eventTypes: eventTypes$3, 17543 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, container) { 17544 var containerOrDoc = container || getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do 17545 // not extract events. See #3639. 17546 17547 if (!containerOrDoc || !isListeningToAllDependencies('onSelect', containerOrDoc)) { 17548 return null; 17549 } 17550 17551 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 17552 17553 switch (topLevelType) { 17554 // Track the input node that has focus. 17555 case TOP_FOCUS: 17556 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 17557 activeElement$1 = targetNode; 17558 activeElementInst$1 = targetInst; 17559 lastSelection = null; 17560 } 17561 17562 break; 17563 17564 case TOP_BLUR: 17565 activeElement$1 = null; 17566 activeElementInst$1 = null; 17567 lastSelection = null; 17568 break; 17569 // Don't fire the event while the user is dragging. This matches the 17570 // semantics of the native select event. 17571 17572 case TOP_MOUSE_DOWN: 17573 mouseDown = true; 17574 break; 17575 17576 case TOP_CONTEXT_MENU: 17577 case TOP_MOUSE_UP: 17578 case TOP_DRAG_END: 17579 mouseDown = false; 17580 return constructSelectEvent(nativeEvent, nativeEventTarget); 17581 // Chrome and IE fire non-standard event when selection is changed (and 17582 // sometimes when it hasn't). IE's event fires out of order with respect 17583 // to key and input events on deletion, so we discard it. 17584 // 17585 // Firefox doesn't support selectionchange, so check selection status 17586 // after each key entry. The selection changes after keydown and before 17587 // keyup, but we check on keydown as well in the case of holding down a 17588 // key, when multiple keydown events are fired but only one keyup is. 17589 // This is also our approach for IE handling, for the reason above. 17590 17591 case TOP_SELECTION_CHANGE: 17592 if (skipSelectionChangeEvent) { 17593 break; 17594 } 17595 17596 // falls through 17597 17598 case TOP_KEY_DOWN: 17599 case TOP_KEY_UP: 17600 return constructSelectEvent(nativeEvent, nativeEventTarget); 17601 } 17602 17603 return null; 17604 } 17605}; 17606 17607/** 17608 * @interface Event 17609 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 17610 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 17611 */ 17612 17613var SyntheticAnimationEvent = SyntheticEvent.extend({ 17614 animationName: null, 17615 elapsedTime: null, 17616 pseudoElement: null 17617}); 17618 17619/** 17620 * @interface Event 17621 * @see http://www.w3.org/TR/clipboard-apis/ 17622 */ 17623 17624var SyntheticClipboardEvent = SyntheticEvent.extend({ 17625 clipboardData: function (event) { 17626 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 17627 } 17628}); 17629 17630/** 17631 * @interface FocusEvent 17632 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 17633 */ 17634 17635var SyntheticFocusEvent = SyntheticUIEvent.extend({ 17636 relatedTarget: null 17637}); 17638 17639/** 17640 * `charCode` represents the actual "character code" and is safe to use with 17641 * `String.fromCharCode`. As such, only keys that correspond to printable 17642 * characters produce a valid `charCode`, the only exception to this is Enter. 17643 * The Tab-key is considered non-printable and does not have a `charCode`, 17644 * presumably because it does not produce a tab-character in browsers. 17645 * 17646 * @param {object} nativeEvent Native browser event. 17647 * @return {number} Normalized `charCode` property. 17648 */ 17649function getEventCharCode(nativeEvent) { 17650 var charCode; 17651 var keyCode = nativeEvent.keyCode; 17652 17653 if ('charCode' in nativeEvent) { 17654 charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. 17655 17656 if (charCode === 0 && keyCode === 13) { 17657 charCode = 13; 17658 } 17659 } else { 17660 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 17661 charCode = keyCode; 17662 } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) 17663 // report Enter as charCode 10 when ctrl is pressed. 17664 17665 17666 if (charCode === 10) { 17667 charCode = 13; 17668 } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 17669 // Must not discard the (non-)printable Enter-key. 17670 17671 17672 if (charCode >= 32 || charCode === 13) { 17673 return charCode; 17674 } 17675 17676 return 0; 17677} 17678 17679/** 17680 * Normalization of deprecated HTML5 `key` values 17681 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 17682 */ 17683 17684var normalizeKey = { 17685 Esc: 'Escape', 17686 Spacebar: ' ', 17687 Left: 'ArrowLeft', 17688 Up: 'ArrowUp', 17689 Right: 'ArrowRight', 17690 Down: 'ArrowDown', 17691 Del: 'Delete', 17692 Win: 'OS', 17693 Menu: 'ContextMenu', 17694 Apps: 'ContextMenu', 17695 Scroll: 'ScrollLock', 17696 MozPrintableKey: 'Unidentified' 17697}; 17698/** 17699 * Translation from legacy `keyCode` to HTML5 `key` 17700 * Only special keys supported, all others depend on keyboard layout or browser 17701 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 17702 */ 17703 17704var translateToKey = { 17705 '8': 'Backspace', 17706 '9': 'Tab', 17707 '12': 'Clear', 17708 '13': 'Enter', 17709 '16': 'Shift', 17710 '17': 'Control', 17711 '18': 'Alt', 17712 '19': 'Pause', 17713 '20': 'CapsLock', 17714 '27': 'Escape', 17715 '32': ' ', 17716 '33': 'PageUp', 17717 '34': 'PageDown', 17718 '35': 'End', 17719 '36': 'Home', 17720 '37': 'ArrowLeft', 17721 '38': 'ArrowUp', 17722 '39': 'ArrowRight', 17723 '40': 'ArrowDown', 17724 '45': 'Insert', 17725 '46': 'Delete', 17726 '112': 'F1', 17727 '113': 'F2', 17728 '114': 'F3', 17729 '115': 'F4', 17730 '116': 'F5', 17731 '117': 'F6', 17732 '118': 'F7', 17733 '119': 'F8', 17734 '120': 'F9', 17735 '121': 'F10', 17736 '122': 'F11', 17737 '123': 'F12', 17738 '144': 'NumLock', 17739 '145': 'ScrollLock', 17740 '224': 'Meta' 17741}; 17742/** 17743 * @param {object} nativeEvent Native browser event. 17744 * @return {string} Normalized `key` property. 17745 */ 17746 17747function getEventKey(nativeEvent) { 17748 if (nativeEvent.key) { 17749 // Normalize inconsistent values reported by browsers due to 17750 // implementations of a working draft specification. 17751 // FireFox implements `key` but returns `MozPrintableKey` for all 17752 // printable characters (normalized to `Unidentified`), ignore it. 17753 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 17754 17755 if (key !== 'Unidentified') { 17756 return key; 17757 } 17758 } // Browser does not implement `key`, polyfill as much of it as we can. 17759 17760 17761 if (nativeEvent.type === 'keypress') { 17762 var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can 17763 // thus be captured by `keypress`, no other non-printable key should. 17764 17765 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 17766 } 17767 17768 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 17769 // While user keyboard layout determines the actual meaning of each 17770 // `keyCode` value, almost all function keys have a universal value. 17771 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 17772 } 17773 17774 return ''; 17775} 17776 17777/** 17778 * @interface KeyboardEvent 17779 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 17780 */ 17781 17782var SyntheticKeyboardEvent = SyntheticUIEvent.extend({ 17783 key: getEventKey, 17784 location: null, 17785 ctrlKey: null, 17786 shiftKey: null, 17787 altKey: null, 17788 metaKey: null, 17789 repeat: null, 17790 locale: null, 17791 getModifierState: getEventModifierState, 17792 // Legacy Interface 17793 charCode: function (event) { 17794 // `charCode` is the result of a KeyPress event and represents the value of 17795 // the actual printable character. 17796 // KeyPress is deprecated, but its replacement is not yet final and not 17797 // implemented in any major browser. Only KeyPress has charCode. 17798 if (event.type === 'keypress') { 17799 return getEventCharCode(event); 17800 } 17801 17802 return 0; 17803 }, 17804 keyCode: function (event) { 17805 // `keyCode` is the result of a KeyDown/Up event and represents the value of 17806 // physical keyboard key. 17807 // The actual meaning of the value depends on the users' keyboard layout 17808 // which cannot be detected. Assuming that it is a US keyboard layout 17809 // provides a surprisingly accurate mapping for US and European users. 17810 // Due to this, it is left to the user to implement at this time. 17811 if (event.type === 'keydown' || event.type === 'keyup') { 17812 return event.keyCode; 17813 } 17814 17815 return 0; 17816 }, 17817 which: function (event) { 17818 // `which` is an alias for either `keyCode` or `charCode` depending on the 17819 // type of the event. 17820 if (event.type === 'keypress') { 17821 return getEventCharCode(event); 17822 } 17823 17824 if (event.type === 'keydown' || event.type === 'keyup') { 17825 return event.keyCode; 17826 } 17827 17828 return 0; 17829 } 17830}); 17831 17832/** 17833 * @interface DragEvent 17834 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 17835 */ 17836 17837var SyntheticDragEvent = SyntheticMouseEvent.extend({ 17838 dataTransfer: null 17839}); 17840 17841/** 17842 * @interface TouchEvent 17843 * @see http://www.w3.org/TR/touch-events/ 17844 */ 17845 17846var SyntheticTouchEvent = SyntheticUIEvent.extend({ 17847 touches: null, 17848 targetTouches: null, 17849 changedTouches: null, 17850 altKey: null, 17851 metaKey: null, 17852 ctrlKey: null, 17853 shiftKey: null, 17854 getModifierState: getEventModifierState 17855}); 17856 17857/** 17858 * @interface Event 17859 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 17860 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 17861 */ 17862 17863var SyntheticTransitionEvent = SyntheticEvent.extend({ 17864 propertyName: null, 17865 elapsedTime: null, 17866 pseudoElement: null 17867}); 17868 17869/** 17870 * @interface WheelEvent 17871 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 17872 */ 17873 17874var SyntheticWheelEvent = SyntheticMouseEvent.extend({ 17875 deltaX: function (event) { 17876 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 17877 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 17878 }, 17879 deltaY: function (event) { 17880 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 17881 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 17882 'wheelDelta' in event ? -event.wheelDelta : 0; 17883 }, 17884 deltaZ: null, 17885 // Browsers without "deltaMode" is reporting in raw wheel delta where one 17886 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 17887 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 17888 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 17889 deltaMode: null 17890}); 17891 17892var knownHTMLTopLevelTypes = [TOP_ABORT, TOP_CANCEL, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_CLOSE, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_INPUT, TOP_INVALID, TOP_LOAD, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_RESET, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUBMIT, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_TOGGLE, TOP_VOLUME_CHANGE, TOP_WAITING]; 17893var SimpleEventPlugin = { 17894 // simpleEventPluginEventTypes gets populated from 17895 // the DOMEventProperties module. 17896 eventTypes: simpleEventPluginEventTypes, 17897 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 17898 var dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType); 17899 17900 if (!dispatchConfig) { 17901 return null; 17902 } 17903 17904 var EventConstructor; 17905 17906 switch (topLevelType) { 17907 case TOP_KEY_PRESS: 17908 // Firefox creates a keypress event for function keys too. This removes 17909 // the unwanted keypress events. Enter is however both printable and 17910 // non-printable. One would expect Tab to be as well (but it isn't). 17911 if (getEventCharCode(nativeEvent) === 0) { 17912 return null; 17913 } 17914 17915 /* falls through */ 17916 17917 case TOP_KEY_DOWN: 17918 case TOP_KEY_UP: 17919 EventConstructor = SyntheticKeyboardEvent; 17920 break; 17921 17922 case TOP_BLUR: 17923 case TOP_FOCUS: 17924 EventConstructor = SyntheticFocusEvent; 17925 break; 17926 17927 case TOP_CLICK: 17928 // Firefox creates a click event on right mouse clicks. This removes the 17929 // unwanted click events. 17930 if (nativeEvent.button === 2) { 17931 return null; 17932 } 17933 17934 /* falls through */ 17935 17936 case TOP_AUX_CLICK: 17937 case TOP_DOUBLE_CLICK: 17938 case TOP_MOUSE_DOWN: 17939 case TOP_MOUSE_MOVE: 17940 case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events 17941 17942 /* falls through */ 17943 17944 case TOP_MOUSE_OUT: 17945 case TOP_MOUSE_OVER: 17946 case TOP_CONTEXT_MENU: 17947 EventConstructor = SyntheticMouseEvent; 17948 break; 17949 17950 case TOP_DRAG: 17951 case TOP_DRAG_END: 17952 case TOP_DRAG_ENTER: 17953 case TOP_DRAG_EXIT: 17954 case TOP_DRAG_LEAVE: 17955 case TOP_DRAG_OVER: 17956 case TOP_DRAG_START: 17957 case TOP_DROP: 17958 EventConstructor = SyntheticDragEvent; 17959 break; 17960 17961 case TOP_TOUCH_CANCEL: 17962 case TOP_TOUCH_END: 17963 case TOP_TOUCH_MOVE: 17964 case TOP_TOUCH_START: 17965 EventConstructor = SyntheticTouchEvent; 17966 break; 17967 17968 case TOP_ANIMATION_END: 17969 case TOP_ANIMATION_ITERATION: 17970 case TOP_ANIMATION_START: 17971 EventConstructor = SyntheticAnimationEvent; 17972 break; 17973 17974 case TOP_TRANSITION_END: 17975 EventConstructor = SyntheticTransitionEvent; 17976 break; 17977 17978 case TOP_SCROLL: 17979 EventConstructor = SyntheticUIEvent; 17980 break; 17981 17982 case TOP_WHEEL: 17983 EventConstructor = SyntheticWheelEvent; 17984 break; 17985 17986 case TOP_COPY: 17987 case TOP_CUT: 17988 case TOP_PASTE: 17989 EventConstructor = SyntheticClipboardEvent; 17990 break; 17991 17992 case TOP_GOT_POINTER_CAPTURE: 17993 case TOP_LOST_POINTER_CAPTURE: 17994 case TOP_POINTER_CANCEL: 17995 case TOP_POINTER_DOWN: 17996 case TOP_POINTER_MOVE: 17997 case TOP_POINTER_OUT: 17998 case TOP_POINTER_OVER: 17999 case TOP_POINTER_UP: 18000 EventConstructor = SyntheticPointerEvent; 18001 break; 18002 18003 default: 18004 { 18005 if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) { 18006 error('SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType); 18007 } 18008 } // HTML Events 18009 // @see http://www.w3.org/TR/html5/index.html#events-0 18010 18011 18012 EventConstructor = SyntheticEvent; 18013 break; 18014 } 18015 18016 var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); 18017 accumulateTwoPhaseDispatches(event); 18018 return event; 18019 } 18020}; 18021 18022/** 18023 * Specifies a deterministic ordering of `EventPlugin`s. A convenient way to 18024 * reason about plugins, without having to package every one of them. This 18025 * is better than having plugins be ordered in the same order that they 18026 * are injected because that ordering would be influenced by the packaging order. 18027 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that 18028 * preventing default on events is convenient in `SimpleEventPlugin` handlers. 18029 */ 18030 18031var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; 18032/** 18033 * Inject modules for resolving DOM hierarchy and plugin ordering. 18034 */ 18035 18036injectEventPluginOrder(DOMEventPluginOrder); 18037setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1); 18038/** 18039 * Some important event plugins included by default (without having to require 18040 * them). 18041 */ 18042 18043injectEventPluginsByName({ 18044 SimpleEventPlugin: SimpleEventPlugin, 18045 EnterLeaveEventPlugin: EnterLeaveEventPlugin, 18046 ChangeEventPlugin: ChangeEventPlugin, 18047 SelectEventPlugin: SelectEventPlugin, 18048 BeforeInputEventPlugin: BeforeInputEventPlugin 18049}); 18050 18051// Prefix measurements so that it's possible to filter them. 18052// Longer prefixes are hard to read in DevTools. 18053var reactEmoji = "\u269B"; 18054var warningEmoji = "\u26D4"; 18055var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause. 18056// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? 18057 18058var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? 18059// Reusing `currentFiber` would be confusing for this because user code fiber 18060// can change during commit phase too, but we don't need to unwind it (since 18061// lifecycles in the commit phase don't resemble a tree). 18062 18063var currentPhase = null; 18064var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, 18065// so we will keep track of it, and include it in the report. 18066// Track commits caused by cascading updates. 18067 18068var isCommitting = false; 18069var hasScheduledUpdateInCurrentCommit = false; 18070var hasScheduledUpdateInCurrentPhase = false; 18071var commitCountInCurrentWorkLoop = 0; 18072var effectCountInCurrentCommit = 0; 18073// to avoid stretch the commit phase with measurement overhead. 18074 18075var labelsInCurrentCommit = new Set(); 18076 18077var formatMarkName = function (markName) { 18078 return reactEmoji + " " + markName; 18079}; 18080 18081var formatLabel = function (label, warning) { 18082 var prefix = warning ? warningEmoji + " " : reactEmoji + " "; 18083 var suffix = warning ? " Warning: " + warning : ''; 18084 return "" + prefix + label + suffix; 18085}; 18086 18087var beginMark = function (markName) { 18088 performance.mark(formatMarkName(markName)); 18089}; 18090 18091var clearMark = function (markName) { 18092 performance.clearMarks(formatMarkName(markName)); 18093}; 18094 18095var endMark = function (label, markName, warning) { 18096 var formattedMarkName = formatMarkName(markName); 18097 var formattedLabel = formatLabel(label, warning); 18098 18099 try { 18100 performance.measure(formattedLabel, formattedMarkName); 18101 } catch (err) {} // If previous mark was missing for some reason, this will throw. 18102 // This could only happen if React crashed in an unexpected place earlier. 18103 // Don't pile on with more errors. 18104 // Clear marks immediately to avoid growing buffer. 18105 18106 18107 performance.clearMarks(formattedMarkName); 18108 performance.clearMeasures(formattedLabel); 18109}; 18110 18111var getFiberMarkName = function (label, debugID) { 18112 return label + " (#" + debugID + ")"; 18113}; 18114 18115var getFiberLabel = function (componentName, isMounted, phase) { 18116 if (phase === null) { 18117 // These are composite component total time measurements. 18118 return componentName + " [" + (isMounted ? 'update' : 'mount') + "]"; 18119 } else { 18120 // Composite component methods. 18121 return componentName + "." + phase; 18122 } 18123}; 18124 18125var beginFiberMark = function (fiber, phase) { 18126 var componentName = getComponentName(fiber.type) || 'Unknown'; 18127 var debugID = fiber._debugID; 18128 var isMounted = fiber.alternate !== null; 18129 var label = getFiberLabel(componentName, isMounted, phase); 18130 18131 if (isCommitting && labelsInCurrentCommit.has(label)) { 18132 // During the commit phase, we don't show duplicate labels because 18133 // there is a fixed overhead for every measurement, and we don't 18134 // want to stretch the commit phase beyond necessary. 18135 return false; 18136 } 18137 18138 labelsInCurrentCommit.add(label); 18139 var markName = getFiberMarkName(label, debugID); 18140 beginMark(markName); 18141 return true; 18142}; 18143 18144var clearFiberMark = function (fiber, phase) { 18145 var componentName = getComponentName(fiber.type) || 'Unknown'; 18146 var debugID = fiber._debugID; 18147 var isMounted = fiber.alternate !== null; 18148 var label = getFiberLabel(componentName, isMounted, phase); 18149 var markName = getFiberMarkName(label, debugID); 18150 clearMark(markName); 18151}; 18152 18153var endFiberMark = function (fiber, phase, warning) { 18154 var componentName = getComponentName(fiber.type) || 'Unknown'; 18155 var debugID = fiber._debugID; 18156 var isMounted = fiber.alternate !== null; 18157 var label = getFiberLabel(componentName, isMounted, phase); 18158 var markName = getFiberMarkName(label, debugID); 18159 endMark(label, markName, warning); 18160}; 18161 18162var shouldIgnoreFiber = function (fiber) { 18163 // Host components should be skipped in the timeline. 18164 // We could check typeof fiber.type, but does this work with RN? 18165 switch (fiber.tag) { 18166 case HostRoot: 18167 case HostComponent: 18168 case HostText: 18169 case HostPortal: 18170 case Fragment: 18171 case ContextProvider: 18172 case ContextConsumer: 18173 case Mode: 18174 return true; 18175 18176 default: 18177 return false; 18178 } 18179}; 18180 18181var clearPendingPhaseMeasurement = function () { 18182 if (currentPhase !== null && currentPhaseFiber !== null) { 18183 clearFiberMark(currentPhaseFiber, currentPhase); 18184 } 18185 18186 currentPhaseFiber = null; 18187 currentPhase = null; 18188 hasScheduledUpdateInCurrentPhase = false; 18189}; 18190 18191var pauseTimers = function () { 18192 // Stops all currently active measurements so that they can be resumed 18193 // if we continue in a later deferred loop from the same unit of work. 18194 var fiber = currentFiber; 18195 18196 while (fiber) { 18197 if (fiber._debugIsCurrentlyTiming) { 18198 endFiberMark(fiber, null, null); 18199 } 18200 18201 fiber = fiber.return; 18202 } 18203}; 18204 18205var resumeTimersRecursively = function (fiber) { 18206 if (fiber.return !== null) { 18207 resumeTimersRecursively(fiber.return); 18208 } 18209 18210 if (fiber._debugIsCurrentlyTiming) { 18211 beginFiberMark(fiber, null); 18212 } 18213}; 18214 18215var resumeTimers = function () { 18216 // Resumes all measurements that were active during the last deferred loop. 18217 if (currentFiber !== null) { 18218 resumeTimersRecursively(currentFiber); 18219 } 18220}; 18221 18222function recordEffect() { 18223 { 18224 effectCountInCurrentCommit++; 18225 } 18226} 18227function recordScheduleUpdate() { 18228 { 18229 if (isCommitting) { 18230 hasScheduledUpdateInCurrentCommit = true; 18231 } 18232 18233 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { 18234 hasScheduledUpdateInCurrentPhase = true; 18235 } 18236 } 18237} 18238function startWorkTimer(fiber) { 18239 { 18240 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 18241 return; 18242 } // If we pause, this is the fiber to unwind from. 18243 18244 18245 currentFiber = fiber; 18246 18247 if (!beginFiberMark(fiber, null)) { 18248 return; 18249 } 18250 18251 fiber._debugIsCurrentlyTiming = true; 18252 } 18253} 18254function cancelWorkTimer(fiber) { 18255 { 18256 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 18257 return; 18258 } // Remember we shouldn't complete measurement for this fiber. 18259 // Otherwise flamechart will be deep even for small updates. 18260 18261 18262 fiber._debugIsCurrentlyTiming = false; 18263 clearFiberMark(fiber, null); 18264 } 18265} 18266function stopWorkTimer(fiber) { 18267 { 18268 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 18269 return; 18270 } // If we pause, its parent is the fiber to unwind from. 18271 18272 18273 currentFiber = fiber.return; 18274 18275 if (!fiber._debugIsCurrentlyTiming) { 18276 return; 18277 } 18278 18279 fiber._debugIsCurrentlyTiming = false; 18280 endFiberMark(fiber, null, null); 18281 } 18282} 18283function stopFailedWorkTimer(fiber) { 18284 { 18285 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 18286 return; 18287 } // If we pause, its parent is the fiber to unwind from. 18288 18289 18290 currentFiber = fiber.return; 18291 18292 if (!fiber._debugIsCurrentlyTiming) { 18293 return; 18294 } 18295 18296 fiber._debugIsCurrentlyTiming = false; 18297 var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary'; 18298 endFiberMark(fiber, null, warning); 18299 } 18300} 18301function startPhaseTimer(fiber, phase) { 18302 { 18303 if (!supportsUserTiming) { 18304 return; 18305 } 18306 18307 clearPendingPhaseMeasurement(); 18308 18309 if (!beginFiberMark(fiber, phase)) { 18310 return; 18311 } 18312 18313 currentPhaseFiber = fiber; 18314 currentPhase = phase; 18315 } 18316} 18317function stopPhaseTimer() { 18318 { 18319 if (!supportsUserTiming) { 18320 return; 18321 } 18322 18323 if (currentPhase !== null && currentPhaseFiber !== null) { 18324 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; 18325 endFiberMark(currentPhaseFiber, currentPhase, warning); 18326 } 18327 18328 currentPhase = null; 18329 currentPhaseFiber = null; 18330 } 18331} 18332function startWorkLoopTimer(nextUnitOfWork) { 18333 { 18334 currentFiber = nextUnitOfWork; 18335 18336 if (!supportsUserTiming) { 18337 return; 18338 } 18339 18340 commitCountInCurrentWorkLoop = 0; // This is top level call. 18341 // Any other measurements are performed within. 18342 18343 beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop. 18344 18345 resumeTimers(); 18346 } 18347} 18348function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { 18349 { 18350 if (!supportsUserTiming) { 18351 return; 18352 } 18353 18354 var warning = null; 18355 18356 if (interruptedBy !== null) { 18357 if (interruptedBy.tag === HostRoot) { 18358 warning = 'A top-level update interrupted the previous render'; 18359 } else { 18360 var componentName = getComponentName(interruptedBy.type) || 'Unknown'; 18361 warning = "An update to " + componentName + " interrupted the previous render"; 18362 } 18363 } else if (commitCountInCurrentWorkLoop > 1) { 18364 warning = 'There were cascading updates'; 18365 } 18366 18367 commitCountInCurrentWorkLoop = 0; 18368 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop. 18369 18370 pauseTimers(); 18371 endMark(label, '(React Tree Reconciliation)', warning); 18372 } 18373} 18374function startCommitTimer() { 18375 { 18376 if (!supportsUserTiming) { 18377 return; 18378 } 18379 18380 isCommitting = true; 18381 hasScheduledUpdateInCurrentCommit = false; 18382 labelsInCurrentCommit.clear(); 18383 beginMark('(Committing Changes)'); 18384 } 18385} 18386function stopCommitTimer() { 18387 { 18388 if (!supportsUserTiming) { 18389 return; 18390 } 18391 18392 var warning = null; 18393 18394 if (hasScheduledUpdateInCurrentCommit) { 18395 warning = 'Lifecycle hook scheduled a cascading update'; 18396 } else if (commitCountInCurrentWorkLoop > 0) { 18397 warning = 'Caused by a cascading update in earlier commit'; 18398 } 18399 18400 hasScheduledUpdateInCurrentCommit = false; 18401 commitCountInCurrentWorkLoop++; 18402 isCommitting = false; 18403 labelsInCurrentCommit.clear(); 18404 endMark('(Committing Changes)', '(Committing Changes)', warning); 18405 } 18406} 18407function startCommitSnapshotEffectsTimer() { 18408 { 18409 if (!supportsUserTiming) { 18410 return; 18411 } 18412 18413 effectCountInCurrentCommit = 0; 18414 beginMark('(Committing Snapshot Effects)'); 18415 } 18416} 18417function stopCommitSnapshotEffectsTimer() { 18418 { 18419 if (!supportsUserTiming) { 18420 return; 18421 } 18422 18423 var count = effectCountInCurrentCommit; 18424 effectCountInCurrentCommit = 0; 18425 endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null); 18426 } 18427} 18428function startCommitHostEffectsTimer() { 18429 { 18430 if (!supportsUserTiming) { 18431 return; 18432 } 18433 18434 effectCountInCurrentCommit = 0; 18435 beginMark('(Committing Host Effects)'); 18436 } 18437} 18438function stopCommitHostEffectsTimer() { 18439 { 18440 if (!supportsUserTiming) { 18441 return; 18442 } 18443 18444 var count = effectCountInCurrentCommit; 18445 effectCountInCurrentCommit = 0; 18446 endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null); 18447 } 18448} 18449function startCommitLifeCyclesTimer() { 18450 { 18451 if (!supportsUserTiming) { 18452 return; 18453 } 18454 18455 effectCountInCurrentCommit = 0; 18456 beginMark('(Calling Lifecycle Methods)'); 18457 } 18458} 18459function stopCommitLifeCyclesTimer() { 18460 { 18461 if (!supportsUserTiming) { 18462 return; 18463 } 18464 18465 var count = effectCountInCurrentCommit; 18466 effectCountInCurrentCommit = 0; 18467 endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null); 18468 } 18469} 18470 18471var valueStack = []; 18472var fiberStack; 18473 18474{ 18475 fiberStack = []; 18476} 18477 18478var index = -1; 18479 18480function createCursor(defaultValue) { 18481 return { 18482 current: defaultValue 18483 }; 18484} 18485 18486function pop(cursor, fiber) { 18487 if (index < 0) { 18488 { 18489 error('Unexpected pop.'); 18490 } 18491 18492 return; 18493 } 18494 18495 { 18496 if (fiber !== fiberStack[index]) { 18497 error('Unexpected Fiber popped.'); 18498 } 18499 } 18500 18501 cursor.current = valueStack[index]; 18502 valueStack[index] = null; 18503 18504 { 18505 fiberStack[index] = null; 18506 } 18507 18508 index--; 18509} 18510 18511function push(cursor, value, fiber) { 18512 index++; 18513 valueStack[index] = cursor.current; 18514 18515 { 18516 fiberStack[index] = fiber; 18517 } 18518 18519 cursor.current = value; 18520} 18521 18522var warnedAboutMissingGetChildContext; 18523 18524{ 18525 warnedAboutMissingGetChildContext = {}; 18526} 18527 18528var emptyContextObject = {}; 18529 18530{ 18531 Object.freeze(emptyContextObject); 18532} // A cursor to the current merged context object on the stack. 18533 18534 18535var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. 18536 18537var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. 18538// We use this to get access to the parent context after we have already 18539// pushed the next context provider, and now need to merge their contexts. 18540 18541var previousContext = emptyContextObject; 18542 18543function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { 18544 { 18545 if (didPushOwnContextIfProvider && isContextProvider(Component)) { 18546 // If the fiber is a context provider itself, when we read its context 18547 // we may have already pushed its own child context on the stack. A context 18548 // provider should not "see" its own child context. Therefore we read the 18549 // previous (parent) context instead for a context provider. 18550 return previousContext; 18551 } 18552 18553 return contextStackCursor.current; 18554 } 18555} 18556 18557function cacheContext(workInProgress, unmaskedContext, maskedContext) { 18558 { 18559 var instance = workInProgress.stateNode; 18560 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 18561 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 18562 } 18563} 18564 18565function getMaskedContext(workInProgress, unmaskedContext) { 18566 { 18567 var type = workInProgress.type; 18568 var contextTypes = type.contextTypes; 18569 18570 if (!contextTypes) { 18571 return emptyContextObject; 18572 } // Avoid recreating masked context unless unmasked context has changed. 18573 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 18574 // This may trigger infinite loops if componentWillReceiveProps calls setState. 18575 18576 18577 var instance = workInProgress.stateNode; 18578 18579 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 18580 return instance.__reactInternalMemoizedMaskedChildContext; 18581 } 18582 18583 var context = {}; 18584 18585 for (var key in contextTypes) { 18586 context[key] = unmaskedContext[key]; 18587 } 18588 18589 { 18590 var name = getComponentName(type) || 'Unknown'; 18591 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev); 18592 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 18593 // Context is created before the class component is instantiated so check for instance. 18594 18595 18596 if (instance) { 18597 cacheContext(workInProgress, unmaskedContext, context); 18598 } 18599 18600 return context; 18601 } 18602} 18603 18604function hasContextChanged() { 18605 { 18606 return didPerformWorkStackCursor.current; 18607 } 18608} 18609 18610function isContextProvider(type) { 18611 { 18612 var childContextTypes = type.childContextTypes; 18613 return childContextTypes !== null && childContextTypes !== undefined; 18614 } 18615} 18616 18617function popContext(fiber) { 18618 { 18619 pop(didPerformWorkStackCursor, fiber); 18620 pop(contextStackCursor, fiber); 18621 } 18622} 18623 18624function popTopLevelContextObject(fiber) { 18625 { 18626 pop(didPerformWorkStackCursor, fiber); 18627 pop(contextStackCursor, fiber); 18628 } 18629} 18630 18631function pushTopLevelContextObject(fiber, context, didChange) { 18632 { 18633 if (!(contextStackCursor.current === emptyContextObject)) { 18634 { 18635 throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); 18636 } 18637 } 18638 18639 push(contextStackCursor, context, fiber); 18640 push(didPerformWorkStackCursor, didChange, fiber); 18641 } 18642} 18643 18644function processChildContext(fiber, type, parentContext) { 18645 { 18646 var instance = fiber.stateNode; 18647 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. 18648 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 18649 18650 if (typeof instance.getChildContext !== 'function') { 18651 { 18652 var componentName = getComponentName(type) || 'Unknown'; 18653 18654 if (!warnedAboutMissingGetChildContext[componentName]) { 18655 warnedAboutMissingGetChildContext[componentName] = true; 18656 18657 error('%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); 18658 } 18659 } 18660 18661 return parentContext; 18662 } 18663 18664 var childContext; 18665 startPhaseTimer(fiber, 'getChildContext'); 18666 childContext = instance.getChildContext(); 18667 stopPhaseTimer(); 18668 18669 for (var contextKey in childContext) { 18670 if (!(contextKey in childContextTypes)) { 18671 { 18672 throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); 18673 } 18674 } 18675 } 18676 18677 { 18678 var name = getComponentName(type) || 'Unknown'; 18679 checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when 18680 // somebody calls unstable_renderSubtreeIntoContainer() and we process 18681 // context from the parent component instance. The stack will be missing 18682 // because it's outside of the reconciliation, and so the pointer has not 18683 // been set. This is rare and doesn't matter. We'll also remove that API. 18684 getCurrentFiberStackInDev); 18685 } 18686 18687 return _assign({}, parentContext, {}, childContext); 18688 } 18689} 18690 18691function pushContextProvider(workInProgress) { 18692 { 18693 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. 18694 // If the instance does not exist yet, we will push null at first, 18695 // and replace it on the stack later when invalidating the context. 18696 18697 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. 18698 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 18699 18700 previousContext = contextStackCursor.current; 18701 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 18702 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 18703 return true; 18704 } 18705} 18706 18707function invalidateContextProvider(workInProgress, type, didChange) { 18708 { 18709 var instance = workInProgress.stateNode; 18710 18711 if (!instance) { 18712 { 18713 throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); 18714 } 18715 } 18716 18717 if (didChange) { 18718 // Merge parent and own context. 18719 // Skip this if we're not updating due to sCU. 18720 // This avoids unnecessarily recomputing memoized values. 18721 var mergedContext = processChildContext(workInProgress, type, previousContext); 18722 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. 18723 // It is important to unwind the context in the reverse order. 18724 18725 pop(didPerformWorkStackCursor, workInProgress); 18726 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. 18727 18728 push(contextStackCursor, mergedContext, workInProgress); 18729 push(didPerformWorkStackCursor, didChange, workInProgress); 18730 } else { 18731 pop(didPerformWorkStackCursor, workInProgress); 18732 push(didPerformWorkStackCursor, didChange, workInProgress); 18733 } 18734 } 18735} 18736 18737function findCurrentUnmaskedContext(fiber) { 18738 { 18739 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 18740 // makes sense elsewhere 18741 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { 18742 { 18743 throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); 18744 } 18745 } 18746 18747 var node = fiber; 18748 18749 do { 18750 switch (node.tag) { 18751 case HostRoot: 18752 return node.stateNode.context; 18753 18754 case ClassComponent: 18755 { 18756 var Component = node.type; 18757 18758 if (isContextProvider(Component)) { 18759 return node.stateNode.__reactInternalMemoizedMergedChildContext; 18760 } 18761 18762 break; 18763 } 18764 } 18765 18766 node = node.return; 18767 } while (node !== null); 18768 18769 { 18770 { 18771 throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); 18772 } 18773 } 18774 } 18775} 18776 18777var LegacyRoot = 0; 18778var BlockingRoot = 1; 18779var ConcurrentRoot = 2; 18780 18781var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, 18782 Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, 18783 Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, 18784 Scheduler_shouldYield = Scheduler.unstable_shouldYield, 18785 Scheduler_requestPaint = Scheduler.unstable_requestPaint, 18786 Scheduler_now = Scheduler.unstable_now, 18787 Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, 18788 Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, 18789 Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 18790 Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, 18791 Scheduler_LowPriority = Scheduler.unstable_LowPriority, 18792 Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; 18793 18794{ 18795 // Provide explicit error message when production+profiling bundle of e.g. 18796 // react-dom is used with production (non-profiling) bundle of 18797 // scheduler/tracing 18798 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 18799 { 18800 throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); 18801 } 18802 } 18803} 18804 18805var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use 18806// ascending numbers so we can compare them like numbers. They start at 90 to 18807// avoid clashing with Scheduler's priorities. 18808 18809var ImmediatePriority = 99; 18810var UserBlockingPriority$1 = 98; 18811var NormalPriority = 97; 18812var LowPriority = 96; 18813var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. 18814 18815var NoPriority = 90; 18816var shouldYield = Scheduler_shouldYield; 18817var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. 18818Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; 18819var syncQueue = null; 18820var immediateQueueCallbackNode = null; 18821var isFlushingSyncQueue = false; 18822var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 18823// This will be the case for modern browsers that support `performance.now`. In 18824// older browsers, Scheduler falls back to `Date.now`, which returns a Unix 18825// timestamp. In that case, subtract the module initialization time to simulate 18826// the behavior of performance.now and keep our times small enough to fit 18827// within 32 bits. 18828// TODO: Consider lifting this into Scheduler. 18829 18830var now = initialTimeMs < 10000 ? Scheduler_now : function () { 18831 return Scheduler_now() - initialTimeMs; 18832}; 18833function getCurrentPriorityLevel() { 18834 switch (Scheduler_getCurrentPriorityLevel()) { 18835 case Scheduler_ImmediatePriority: 18836 return ImmediatePriority; 18837 18838 case Scheduler_UserBlockingPriority: 18839 return UserBlockingPriority$1; 18840 18841 case Scheduler_NormalPriority: 18842 return NormalPriority; 18843 18844 case Scheduler_LowPriority: 18845 return LowPriority; 18846 18847 case Scheduler_IdlePriority: 18848 return IdlePriority; 18849 18850 default: 18851 { 18852 { 18853 throw Error( "Unknown priority level." ); 18854 } 18855 } 18856 18857 } 18858} 18859 18860function reactPriorityToSchedulerPriority(reactPriorityLevel) { 18861 switch (reactPriorityLevel) { 18862 case ImmediatePriority: 18863 return Scheduler_ImmediatePriority; 18864 18865 case UserBlockingPriority$1: 18866 return Scheduler_UserBlockingPriority; 18867 18868 case NormalPriority: 18869 return Scheduler_NormalPriority; 18870 18871 case LowPriority: 18872 return Scheduler_LowPriority; 18873 18874 case IdlePriority: 18875 return Scheduler_IdlePriority; 18876 18877 default: 18878 { 18879 { 18880 throw Error( "Unknown priority level." ); 18881 } 18882 } 18883 18884 } 18885} 18886 18887function runWithPriority$1(reactPriorityLevel, fn) { 18888 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 18889 return Scheduler_runWithPriority(priorityLevel, fn); 18890} 18891function scheduleCallback(reactPriorityLevel, callback, options) { 18892 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 18893 return Scheduler_scheduleCallback(priorityLevel, callback, options); 18894} 18895function scheduleSyncCallback(callback) { 18896 // Push this callback into an internal queue. We'll flush these either in 18897 // the next tick, or earlier if something calls `flushSyncCallbackQueue`. 18898 if (syncQueue === null) { 18899 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. 18900 18901 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); 18902 } else { 18903 // Push onto existing queue. Don't need to schedule a callback because 18904 // we already scheduled one when we created the queue. 18905 syncQueue.push(callback); 18906 } 18907 18908 return fakeCallbackNode; 18909} 18910function cancelCallback(callbackNode) { 18911 if (callbackNode !== fakeCallbackNode) { 18912 Scheduler_cancelCallback(callbackNode); 18913 } 18914} 18915function flushSyncCallbackQueue() { 18916 if (immediateQueueCallbackNode !== null) { 18917 var node = immediateQueueCallbackNode; 18918 immediateQueueCallbackNode = null; 18919 Scheduler_cancelCallback(node); 18920 } 18921 18922 flushSyncCallbackQueueImpl(); 18923} 18924 18925function flushSyncCallbackQueueImpl() { 18926 if (!isFlushingSyncQueue && syncQueue !== null) { 18927 // Prevent re-entrancy. 18928 isFlushingSyncQueue = true; 18929 var i = 0; 18930 18931 try { 18932 var _isSync = true; 18933 var queue = syncQueue; 18934 runWithPriority$1(ImmediatePriority, function () { 18935 for (; i < queue.length; i++) { 18936 var callback = queue[i]; 18937 18938 do { 18939 callback = callback(_isSync); 18940 } while (callback !== null); 18941 } 18942 }); 18943 syncQueue = null; 18944 } catch (error) { 18945 // If something throws, leave the remaining callbacks on the queue. 18946 if (syncQueue !== null) { 18947 syncQueue = syncQueue.slice(i + 1); 18948 } // Resume flushing in the next tick 18949 18950 18951 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); 18952 throw error; 18953 } finally { 18954 isFlushingSyncQueue = false; 18955 } 18956 } 18957} 18958 18959var NoMode = 0; 18960var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root 18961// tag instead 18962 18963var BlockingMode = 2; 18964var ConcurrentMode = 4; 18965var ProfileMode = 8; 18966 18967// Max 31 bit integer. The max integer size in V8 for 32-bit systems. 18968// Math.pow(2, 30) - 1 18969// 0b111111111111111111111111111111 18970var MAX_SIGNED_31_BIT_INT = 1073741823; 18971 18972var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that 18973// Never work can be committed in an inconsistent state without tearing the UI. 18974// The main example is offscreen content, like a hidden subtree. So one possible 18975// name is Offscreen. However, it also includes dehydrated Suspense boundaries, 18976// which are inconsistent in the sense that they haven't finished yet, but 18977// aren't visibly inconsistent because the server rendered HTML matches what the 18978// hydrated tree would look like. 18979 18980var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in 18981// order to be consistent. 18982 18983var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase 18984// priority of hover targets. 18985 18986var ContinuousHydration = 3; 18987var Sync = MAX_SIGNED_31_BIT_INT; 18988var Batched = Sync - 1; 18989var UNIT_SIZE = 10; 18990var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. 18991 18992function msToExpirationTime(ms) { 18993 // Always subtract from the offset so that we don't clash with the magic number for NoWork. 18994 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0); 18995} 18996function expirationTimeToMs(expirationTime) { 18997 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; 18998} 18999 19000function ceiling(num, precision) { 19001 return ((num / precision | 0) + 1) * precision; 19002} 19003 19004function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { 19005 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE); 19006} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update 19007// the names to reflect. 19008 19009 19010var LOW_PRIORITY_EXPIRATION = 5000; 19011var LOW_PRIORITY_BATCH_SIZE = 250; 19012function computeAsyncExpiration(currentTime) { 19013 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE); 19014} 19015function computeSuspenseExpiration(currentTime, timeoutMs) { 19016 // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? 19017 return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE); 19018} // We intentionally set a higher expiration time for interactive updates in 19019// dev than in production. 19020// 19021// If the main thread is being blocked so long that you hit the expiration, 19022// it's a problem that could be solved with better scheduling. 19023// 19024// People will be more likely to notice this and fix it with the long 19025// expiration time in development. 19026// 19027// In production we opt for better UX at the risk of masking scheduling 19028// problems, by expiring fast. 19029 19030var HIGH_PRIORITY_EXPIRATION = 500 ; 19031var HIGH_PRIORITY_BATCH_SIZE = 100; 19032function computeInteractiveExpiration(currentTime) { 19033 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE); 19034} 19035function inferPriorityFromExpirationTime(currentTime, expirationTime) { 19036 if (expirationTime === Sync) { 19037 return ImmediatePriority; 19038 } 19039 19040 if (expirationTime === Never || expirationTime === Idle) { 19041 return IdlePriority; 19042 } 19043 19044 var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); 19045 19046 if (msUntil <= 0) { 19047 return ImmediatePriority; 19048 } 19049 19050 if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { 19051 return UserBlockingPriority$1; 19052 } 19053 19054 if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { 19055 return NormalPriority; 19056 } // TODO: Handle LowPriority 19057 // Assume anything lower has idle priority 19058 19059 19060 return IdlePriority; 19061} 19062 19063var ReactStrictModeWarnings = { 19064 recordUnsafeLifecycleWarnings: function (fiber, instance) {}, 19065 flushPendingUnsafeLifecycleWarnings: function () {}, 19066 recordLegacyContextWarning: function (fiber, instance) {}, 19067 flushLegacyContextWarning: function () {}, 19068 discardPendingWarnings: function () {} 19069}; 19070 19071{ 19072 var findStrictRoot = function (fiber) { 19073 var maybeStrictRoot = null; 19074 var node = fiber; 19075 19076 while (node !== null) { 19077 if (node.mode & StrictMode) { 19078 maybeStrictRoot = node; 19079 } 19080 19081 node = node.return; 19082 } 19083 19084 return maybeStrictRoot; 19085 }; 19086 19087 var setToSortedString = function (set) { 19088 var array = []; 19089 set.forEach(function (value) { 19090 array.push(value); 19091 }); 19092 return array.sort().join(', '); 19093 }; 19094 19095 var pendingComponentWillMountWarnings = []; 19096 var pendingUNSAFE_ComponentWillMountWarnings = []; 19097 var pendingComponentWillReceivePropsWarnings = []; 19098 var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 19099 var pendingComponentWillUpdateWarnings = []; 19100 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. 19101 19102 var didWarnAboutUnsafeLifecycles = new Set(); 19103 19104 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { 19105 // Dedup strategy: Warn once per component. 19106 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { 19107 return; 19108 } 19109 19110 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. 19111 instance.componentWillMount.__suppressDeprecationWarning !== true) { 19112 pendingComponentWillMountWarnings.push(fiber); 19113 } 19114 19115 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { 19116 pendingUNSAFE_ComponentWillMountWarnings.push(fiber); 19117 } 19118 19119 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 19120 pendingComponentWillReceivePropsWarnings.push(fiber); 19121 } 19122 19123 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 19124 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); 19125 } 19126 19127 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 19128 pendingComponentWillUpdateWarnings.push(fiber); 19129 } 19130 19131 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { 19132 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); 19133 } 19134 }; 19135 19136 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { 19137 // We do an initial pass to gather component names 19138 var componentWillMountUniqueNames = new Set(); 19139 19140 if (pendingComponentWillMountWarnings.length > 0) { 19141 pendingComponentWillMountWarnings.forEach(function (fiber) { 19142 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19143 didWarnAboutUnsafeLifecycles.add(fiber.type); 19144 }); 19145 pendingComponentWillMountWarnings = []; 19146 } 19147 19148 var UNSAFE_componentWillMountUniqueNames = new Set(); 19149 19150 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { 19151 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { 19152 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19153 didWarnAboutUnsafeLifecycles.add(fiber.type); 19154 }); 19155 pendingUNSAFE_ComponentWillMountWarnings = []; 19156 } 19157 19158 var componentWillReceivePropsUniqueNames = new Set(); 19159 19160 if (pendingComponentWillReceivePropsWarnings.length > 0) { 19161 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { 19162 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19163 didWarnAboutUnsafeLifecycles.add(fiber.type); 19164 }); 19165 pendingComponentWillReceivePropsWarnings = []; 19166 } 19167 19168 var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); 19169 19170 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { 19171 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { 19172 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19173 didWarnAboutUnsafeLifecycles.add(fiber.type); 19174 }); 19175 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 19176 } 19177 19178 var componentWillUpdateUniqueNames = new Set(); 19179 19180 if (pendingComponentWillUpdateWarnings.length > 0) { 19181 pendingComponentWillUpdateWarnings.forEach(function (fiber) { 19182 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19183 didWarnAboutUnsafeLifecycles.add(fiber.type); 19184 }); 19185 pendingComponentWillUpdateWarnings = []; 19186 } 19187 19188 var UNSAFE_componentWillUpdateUniqueNames = new Set(); 19189 19190 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { 19191 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { 19192 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 19193 didWarnAboutUnsafeLifecycles.add(fiber.type); 19194 }); 19195 pendingUNSAFE_ComponentWillUpdateWarnings = []; 19196 } // Finally, we flush all the warnings 19197 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' 19198 19199 19200 if (UNSAFE_componentWillMountUniqueNames.size > 0) { 19201 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); 19202 19203 error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames); 19204 } 19205 19206 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { 19207 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); 19208 19209 error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames); 19210 } 19211 19212 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { 19213 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); 19214 19215 error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2); 19216 } 19217 19218 if (componentWillMountUniqueNames.size > 0) { 19219 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); 19220 19221 warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3); 19222 } 19223 19224 if (componentWillReceivePropsUniqueNames.size > 0) { 19225 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); 19226 19227 warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4); 19228 } 19229 19230 if (componentWillUpdateUniqueNames.size > 0) { 19231 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); 19232 19233 warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5); 19234 } 19235 }; 19236 19237 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. 19238 19239 var didWarnAboutLegacyContext = new Set(); 19240 19241 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { 19242 var strictRoot = findStrictRoot(fiber); 19243 19244 if (strictRoot === null) { 19245 error('Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); 19246 19247 return; 19248 } // Dedup strategy: Warn once per component. 19249 19250 19251 if (didWarnAboutLegacyContext.has(fiber.type)) { 19252 return; 19253 } 19254 19255 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); 19256 19257 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { 19258 if (warningsForRoot === undefined) { 19259 warningsForRoot = []; 19260 pendingLegacyContextWarning.set(strictRoot, warningsForRoot); 19261 } 19262 19263 warningsForRoot.push(fiber); 19264 } 19265 }; 19266 19267 ReactStrictModeWarnings.flushLegacyContextWarning = function () { 19268 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { 19269 if (fiberArray.length === 0) { 19270 return; 19271 } 19272 19273 var firstFiber = fiberArray[0]; 19274 var uniqueNames = new Set(); 19275 fiberArray.forEach(function (fiber) { 19276 uniqueNames.add(getComponentName(fiber.type) || 'Component'); 19277 didWarnAboutLegacyContext.add(fiber.type); 19278 }); 19279 var sortedNames = setToSortedString(uniqueNames); 19280 var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); 19281 19282 error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, firstComponentStack); 19283 }); 19284 }; 19285 19286 ReactStrictModeWarnings.discardPendingWarnings = function () { 19287 pendingComponentWillMountWarnings = []; 19288 pendingUNSAFE_ComponentWillMountWarnings = []; 19289 pendingComponentWillReceivePropsWarnings = []; 19290 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 19291 pendingComponentWillUpdateWarnings = []; 19292 pendingUNSAFE_ComponentWillUpdateWarnings = []; 19293 pendingLegacyContextWarning = new Map(); 19294 }; 19295} 19296 19297var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. 19298 19299var failedBoundaries = null; 19300var setRefreshHandler = function (handler) { 19301 { 19302 resolveFamily = handler; 19303 } 19304}; 19305function resolveFunctionForHotReloading(type) { 19306 { 19307 if (resolveFamily === null) { 19308 // Hot reloading is disabled. 19309 return type; 19310 } 19311 19312 var family = resolveFamily(type); 19313 19314 if (family === undefined) { 19315 return type; 19316 } // Use the latest known implementation. 19317 19318 19319 return family.current; 19320 } 19321} 19322function resolveClassForHotReloading(type) { 19323 // No implementation differences. 19324 return resolveFunctionForHotReloading(type); 19325} 19326function resolveForwardRefForHotReloading(type) { 19327 { 19328 if (resolveFamily === null) { 19329 // Hot reloading is disabled. 19330 return type; 19331 } 19332 19333 var family = resolveFamily(type); 19334 19335 if (family === undefined) { 19336 // Check if we're dealing with a real forwardRef. Don't want to crash early. 19337 if (type !== null && type !== undefined && typeof type.render === 'function') { 19338 // ForwardRef is special because its resolved .type is an object, 19339 // but it's possible that we only have its inner render function in the map. 19340 // If that inner render function is different, we'll build a new forwardRef type. 19341 var currentRender = resolveFunctionForHotReloading(type.render); 19342 19343 if (type.render !== currentRender) { 19344 var syntheticType = { 19345 $$typeof: REACT_FORWARD_REF_TYPE, 19346 render: currentRender 19347 }; 19348 19349 if (type.displayName !== undefined) { 19350 syntheticType.displayName = type.displayName; 19351 } 19352 19353 return syntheticType; 19354 } 19355 } 19356 19357 return type; 19358 } // Use the latest known implementation. 19359 19360 19361 return family.current; 19362 } 19363} 19364function isCompatibleFamilyForHotReloading(fiber, element) { 19365 { 19366 if (resolveFamily === null) { 19367 // Hot reloading is disabled. 19368 return false; 19369 } 19370 19371 var prevType = fiber.elementType; 19372 var nextType = element.type; // If we got here, we know types aren't === equal. 19373 19374 var needsCompareFamilies = false; 19375 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; 19376 19377 switch (fiber.tag) { 19378 case ClassComponent: 19379 { 19380 if (typeof nextType === 'function') { 19381 needsCompareFamilies = true; 19382 } 19383 19384 break; 19385 } 19386 19387 case FunctionComponent: 19388 { 19389 if (typeof nextType === 'function') { 19390 needsCompareFamilies = true; 19391 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 19392 // We don't know the inner type yet. 19393 // We're going to assume that the lazy inner type is stable, 19394 // and so it is sufficient to avoid reconciling it away. 19395 // We're not going to unwrap or actually use the new lazy type. 19396 needsCompareFamilies = true; 19397 } 19398 19399 break; 19400 } 19401 19402 case ForwardRef: 19403 { 19404 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { 19405 needsCompareFamilies = true; 19406 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 19407 needsCompareFamilies = true; 19408 } 19409 19410 break; 19411 } 19412 19413 case MemoComponent: 19414 case SimpleMemoComponent: 19415 { 19416 if ($$typeofNextType === REACT_MEMO_TYPE) { 19417 // TODO: if it was but can no longer be simple, 19418 // we shouldn't set this. 19419 needsCompareFamilies = true; 19420 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 19421 needsCompareFamilies = true; 19422 } 19423 19424 break; 19425 } 19426 19427 default: 19428 return false; 19429 } // Check if both types have a family and it's the same one. 19430 19431 19432 if (needsCompareFamilies) { 19433 // Note: memo() and forwardRef() we'll compare outer rather than inner type. 19434 // This means both of them need to be registered to preserve state. 19435 // If we unwrapped and compared the inner types for wrappers instead, 19436 // then we would risk falsely saying two separate memo(Foo) 19437 // calls are equivalent because they wrap the same Foo function. 19438 var prevFamily = resolveFamily(prevType); 19439 19440 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { 19441 return true; 19442 } 19443 } 19444 19445 return false; 19446 } 19447} 19448function markFailedErrorBoundaryForHotReloading(fiber) { 19449 { 19450 if (resolveFamily === null) { 19451 // Hot reloading is disabled. 19452 return; 19453 } 19454 19455 if (typeof WeakSet !== 'function') { 19456 return; 19457 } 19458 19459 if (failedBoundaries === null) { 19460 failedBoundaries = new WeakSet(); 19461 } 19462 19463 failedBoundaries.add(fiber); 19464 } 19465} 19466var scheduleRefresh = function (root, update) { 19467 { 19468 if (resolveFamily === null) { 19469 // Hot reloading is disabled. 19470 return; 19471 } 19472 19473 var staleFamilies = update.staleFamilies, 19474 updatedFamilies = update.updatedFamilies; 19475 flushPassiveEffects(); 19476 flushSync(function () { 19477 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); 19478 }); 19479 } 19480}; 19481var scheduleRoot = function (root, element) { 19482 { 19483 if (root.context !== emptyContextObject) { 19484 // Super edge case: root has a legacy _renderSubtree context 19485 // but we don't know the parentComponent so we can't pass it. 19486 // Just ignore. We'll delete this with _renderSubtree code path later. 19487 return; 19488 } 19489 19490 flushPassiveEffects(); 19491 syncUpdates(function () { 19492 updateContainer(element, root, null, null); 19493 }); 19494 } 19495}; 19496 19497function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { 19498 { 19499 var alternate = fiber.alternate, 19500 child = fiber.child, 19501 sibling = fiber.sibling, 19502 tag = fiber.tag, 19503 type = fiber.type; 19504 var candidateType = null; 19505 19506 switch (tag) { 19507 case FunctionComponent: 19508 case SimpleMemoComponent: 19509 case ClassComponent: 19510 candidateType = type; 19511 break; 19512 19513 case ForwardRef: 19514 candidateType = type.render; 19515 break; 19516 } 19517 19518 if (resolveFamily === null) { 19519 throw new Error('Expected resolveFamily to be set during hot reload.'); 19520 } 19521 19522 var needsRender = false; 19523 var needsRemount = false; 19524 19525 if (candidateType !== null) { 19526 var family = resolveFamily(candidateType); 19527 19528 if (family !== undefined) { 19529 if (staleFamilies.has(family)) { 19530 needsRemount = true; 19531 } else if (updatedFamilies.has(family)) { 19532 if (tag === ClassComponent) { 19533 needsRemount = true; 19534 } else { 19535 needsRender = true; 19536 } 19537 } 19538 } 19539 } 19540 19541 if (failedBoundaries !== null) { 19542 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { 19543 needsRemount = true; 19544 } 19545 } 19546 19547 if (needsRemount) { 19548 fiber._debugNeedsRemount = true; 19549 } 19550 19551 if (needsRemount || needsRender) { 19552 scheduleWork(fiber, Sync); 19553 } 19554 19555 if (child !== null && !needsRemount) { 19556 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); 19557 } 19558 19559 if (sibling !== null) { 19560 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); 19561 } 19562 } 19563} 19564 19565var findHostInstancesForRefresh = function (root, families) { 19566 { 19567 var hostInstances = new Set(); 19568 var types = new Set(families.map(function (family) { 19569 return family.current; 19570 })); 19571 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); 19572 return hostInstances; 19573 } 19574}; 19575 19576function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { 19577 { 19578 var child = fiber.child, 19579 sibling = fiber.sibling, 19580 tag = fiber.tag, 19581 type = fiber.type; 19582 var candidateType = null; 19583 19584 switch (tag) { 19585 case FunctionComponent: 19586 case SimpleMemoComponent: 19587 case ClassComponent: 19588 candidateType = type; 19589 break; 19590 19591 case ForwardRef: 19592 candidateType = type.render; 19593 break; 19594 } 19595 19596 var didMatch = false; 19597 19598 if (candidateType !== null) { 19599 if (types.has(candidateType)) { 19600 didMatch = true; 19601 } 19602 } 19603 19604 if (didMatch) { 19605 // We have a match. This only drills down to the closest host components. 19606 // There's no need to search deeper because for the purpose of giving 19607 // visual feedback, "flashing" outermost parent rectangles is sufficient. 19608 findHostInstancesForFiberShallowly(fiber, hostInstances); 19609 } else { 19610 // If there's no match, maybe there will be one further down in the child tree. 19611 if (child !== null) { 19612 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); 19613 } 19614 } 19615 19616 if (sibling !== null) { 19617 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); 19618 } 19619 } 19620} 19621 19622function findHostInstancesForFiberShallowly(fiber, hostInstances) { 19623 { 19624 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); 19625 19626 if (foundHostInstances) { 19627 return; 19628 } // If we didn't find any host children, fallback to closest host parent. 19629 19630 19631 var node = fiber; 19632 19633 while (true) { 19634 switch (node.tag) { 19635 case HostComponent: 19636 hostInstances.add(node.stateNode); 19637 return; 19638 19639 case HostPortal: 19640 hostInstances.add(node.stateNode.containerInfo); 19641 return; 19642 19643 case HostRoot: 19644 hostInstances.add(node.stateNode.containerInfo); 19645 return; 19646 } 19647 19648 if (node.return === null) { 19649 throw new Error('Expected to reach root first.'); 19650 } 19651 19652 node = node.return; 19653 } 19654 } 19655} 19656 19657function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { 19658 { 19659 var node = fiber; 19660 var foundHostInstances = false; 19661 19662 while (true) { 19663 if (node.tag === HostComponent) { 19664 // We got a match. 19665 foundHostInstances = true; 19666 hostInstances.add(node.stateNode); // There may still be more, so keep searching. 19667 } else if (node.child !== null) { 19668 node.child.return = node; 19669 node = node.child; 19670 continue; 19671 } 19672 19673 if (node === fiber) { 19674 return foundHostInstances; 19675 } 19676 19677 while (node.sibling === null) { 19678 if (node.return === null || node.return === fiber) { 19679 return foundHostInstances; 19680 } 19681 19682 node = node.return; 19683 } 19684 19685 node.sibling.return = node.return; 19686 node = node.sibling; 19687 } 19688 } 19689 19690 return false; 19691} 19692 19693function resolveDefaultProps(Component, baseProps) { 19694 if (Component && Component.defaultProps) { 19695 // Resolve default props. Taken from ReactElement 19696 var props = _assign({}, baseProps); 19697 19698 var defaultProps = Component.defaultProps; 19699 19700 for (var propName in defaultProps) { 19701 if (props[propName] === undefined) { 19702 props[propName] = defaultProps[propName]; 19703 } 19704 } 19705 19706 return props; 19707 } 19708 19709 return baseProps; 19710} 19711function readLazyComponentType(lazyComponent) { 19712 initializeLazyComponentType(lazyComponent); 19713 19714 if (lazyComponent._status !== Resolved) { 19715 throw lazyComponent._result; 19716 } 19717 19718 return lazyComponent._result; 19719} 19720 19721var valueCursor = createCursor(null); 19722var rendererSigil; 19723 19724{ 19725 // Use this to detect multiple renderers using the same context 19726 rendererSigil = {}; 19727} 19728 19729var currentlyRenderingFiber = null; 19730var lastContextDependency = null; 19731var lastContextWithAllBitsObserved = null; 19732var isDisallowedContextReadInDEV = false; 19733function resetContextDependencies() { 19734 // This is called right before React yields execution, to ensure `readContext` 19735 // cannot be called outside the render phase. 19736 currentlyRenderingFiber = null; 19737 lastContextDependency = null; 19738 lastContextWithAllBitsObserved = null; 19739 19740 { 19741 isDisallowedContextReadInDEV = false; 19742 } 19743} 19744function enterDisallowedContextReadInDEV() { 19745 { 19746 isDisallowedContextReadInDEV = true; 19747 } 19748} 19749function exitDisallowedContextReadInDEV() { 19750 { 19751 isDisallowedContextReadInDEV = false; 19752 } 19753} 19754function pushProvider(providerFiber, nextValue) { 19755 var context = providerFiber.type._context; 19756 19757 { 19758 push(valueCursor, context._currentValue, providerFiber); 19759 context._currentValue = nextValue; 19760 19761 { 19762 if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { 19763 error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); 19764 } 19765 19766 context._currentRenderer = rendererSigil; 19767 } 19768 } 19769} 19770function popProvider(providerFiber) { 19771 var currentValue = valueCursor.current; 19772 pop(valueCursor, providerFiber); 19773 var context = providerFiber.type._context; 19774 19775 { 19776 context._currentValue = currentValue; 19777 } 19778} 19779function calculateChangedBits(context, newValue, oldValue) { 19780 if (objectIs(oldValue, newValue)) { 19781 // No change 19782 return 0; 19783 } else { 19784 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; 19785 19786 { 19787 if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { 19788 error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); 19789 } 19790 } 19791 19792 return changedBits | 0; 19793 } 19794} 19795function scheduleWorkOnParentPath(parent, renderExpirationTime) { 19796 // Update the child expiration time of all the ancestors, including 19797 // the alternates. 19798 var node = parent; 19799 19800 while (node !== null) { 19801 var alternate = node.alternate; 19802 19803 if (node.childExpirationTime < renderExpirationTime) { 19804 node.childExpirationTime = renderExpirationTime; 19805 19806 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { 19807 alternate.childExpirationTime = renderExpirationTime; 19808 } 19809 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { 19810 alternate.childExpirationTime = renderExpirationTime; 19811 } else { 19812 // Neither alternate was updated, which means the rest of the 19813 // ancestor path already has sufficient priority. 19814 break; 19815 } 19816 19817 node = node.return; 19818 } 19819} 19820function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) { 19821 var fiber = workInProgress.child; 19822 19823 if (fiber !== null) { 19824 // Set the return pointer of the child to the work-in-progress fiber. 19825 fiber.return = workInProgress; 19826 } 19827 19828 while (fiber !== null) { 19829 var nextFiber = void 0; // Visit this fiber. 19830 19831 var list = fiber.dependencies; 19832 19833 if (list !== null) { 19834 nextFiber = fiber.child; 19835 var dependency = list.firstContext; 19836 19837 while (dependency !== null) { 19838 // Check if the context matches. 19839 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { 19840 // Match! Schedule an update on this fiber. 19841 if (fiber.tag === ClassComponent) { 19842 // Schedule a force update on the work-in-progress. 19843 var update = createUpdate(renderExpirationTime, null); 19844 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the 19845 // update to the current fiber, too, which means it will persist even if 19846 // this render is thrown away. Since it's a race condition, not sure it's 19847 // worth fixing. 19848 19849 enqueueUpdate(fiber, update); 19850 } 19851 19852 if (fiber.expirationTime < renderExpirationTime) { 19853 fiber.expirationTime = renderExpirationTime; 19854 } 19855 19856 var alternate = fiber.alternate; 19857 19858 if (alternate !== null && alternate.expirationTime < renderExpirationTime) { 19859 alternate.expirationTime = renderExpirationTime; 19860 } 19861 19862 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. 19863 19864 if (list.expirationTime < renderExpirationTime) { 19865 list.expirationTime = renderExpirationTime; 19866 } // Since we already found a match, we can stop traversing the 19867 // dependency list. 19868 19869 19870 break; 19871 } 19872 19873 dependency = dependency.next; 19874 } 19875 } else if (fiber.tag === ContextProvider) { 19876 // Don't scan deeper if this is a matching provider 19877 nextFiber = fiber.type === workInProgress.type ? null : fiber.child; 19878 } else { 19879 // Traverse down. 19880 nextFiber = fiber.child; 19881 } 19882 19883 if (nextFiber !== null) { 19884 // Set the return pointer of the child to the work-in-progress fiber. 19885 nextFiber.return = fiber; 19886 } else { 19887 // No child. Traverse to next sibling. 19888 nextFiber = fiber; 19889 19890 while (nextFiber !== null) { 19891 if (nextFiber === workInProgress) { 19892 // We're back to the root of this subtree. Exit. 19893 nextFiber = null; 19894 break; 19895 } 19896 19897 var sibling = nextFiber.sibling; 19898 19899 if (sibling !== null) { 19900 // Set the return pointer of the sibling to the work-in-progress fiber. 19901 sibling.return = nextFiber.return; 19902 nextFiber = sibling; 19903 break; 19904 } // No more siblings. Traverse up. 19905 19906 19907 nextFiber = nextFiber.return; 19908 } 19909 } 19910 19911 fiber = nextFiber; 19912 } 19913} 19914function prepareToReadContext(workInProgress, renderExpirationTime) { 19915 currentlyRenderingFiber = workInProgress; 19916 lastContextDependency = null; 19917 lastContextWithAllBitsObserved = null; 19918 var dependencies = workInProgress.dependencies; 19919 19920 if (dependencies !== null) { 19921 var firstContext = dependencies.firstContext; 19922 19923 if (firstContext !== null) { 19924 if (dependencies.expirationTime >= renderExpirationTime) { 19925 // Context list has a pending update. Mark that this fiber performed work. 19926 markWorkInProgressReceivedUpdate(); 19927 } // Reset the work-in-progress list 19928 19929 19930 dependencies.firstContext = null; 19931 } 19932 } 19933} 19934function readContext(context, observedBits) { 19935 { 19936 // This warning would fire if you read context inside a Hook like useMemo. 19937 // Unlike the class check below, it's not enforced in production for perf. 19938 if (isDisallowedContextReadInDEV) { 19939 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 19940 } 19941 } 19942 19943 if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { 19944 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. 19945 19946 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { 19947 // Observe all updates. 19948 lastContextWithAllBitsObserved = context; 19949 resolvedObservedBits = MAX_SIGNED_31_BIT_INT; 19950 } else { 19951 resolvedObservedBits = observedBits; 19952 } 19953 19954 var contextItem = { 19955 context: context, 19956 observedBits: resolvedObservedBits, 19957 next: null 19958 }; 19959 19960 if (lastContextDependency === null) { 19961 if (!(currentlyRenderingFiber !== null)) { 19962 { 19963 throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." ); 19964 } 19965 } // This is the first dependency for this component. Create a new list. 19966 19967 19968 lastContextDependency = contextItem; 19969 currentlyRenderingFiber.dependencies = { 19970 expirationTime: NoWork, 19971 firstContext: contextItem, 19972 responders: null 19973 }; 19974 } else { 19975 // Append a new context item. 19976 lastContextDependency = lastContextDependency.next = contextItem; 19977 } 19978 } 19979 19980 return context._currentValue ; 19981} 19982 19983var UpdateState = 0; 19984var ReplaceState = 1; 19985var ForceUpdate = 2; 19986var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. 19987// It should only be read right after calling `processUpdateQueue`, via 19988// `checkHasForceUpdateAfterProcessing`. 19989 19990var hasForceUpdate = false; 19991var didWarnUpdateInsideUpdate; 19992var currentlyProcessingQueue; 19993 19994{ 19995 didWarnUpdateInsideUpdate = false; 19996 currentlyProcessingQueue = null; 19997} 19998 19999function initializeUpdateQueue(fiber) { 20000 var queue = { 20001 baseState: fiber.memoizedState, 20002 baseQueue: null, 20003 shared: { 20004 pending: null 20005 }, 20006 effects: null 20007 }; 20008 fiber.updateQueue = queue; 20009} 20010function cloneUpdateQueue(current, workInProgress) { 20011 // Clone the update queue from current. Unless it's already a clone. 20012 var queue = workInProgress.updateQueue; 20013 var currentQueue = current.updateQueue; 20014 20015 if (queue === currentQueue) { 20016 var clone = { 20017 baseState: currentQueue.baseState, 20018 baseQueue: currentQueue.baseQueue, 20019 shared: currentQueue.shared, 20020 effects: currentQueue.effects 20021 }; 20022 workInProgress.updateQueue = clone; 20023 } 20024} 20025function createUpdate(expirationTime, suspenseConfig) { 20026 var update = { 20027 expirationTime: expirationTime, 20028 suspenseConfig: suspenseConfig, 20029 tag: UpdateState, 20030 payload: null, 20031 callback: null, 20032 next: null 20033 }; 20034 update.next = update; 20035 20036 { 20037 update.priority = getCurrentPriorityLevel(); 20038 } 20039 20040 return update; 20041} 20042function enqueueUpdate(fiber, update) { 20043 var updateQueue = fiber.updateQueue; 20044 20045 if (updateQueue === null) { 20046 // Only occurs if the fiber has been unmounted. 20047 return; 20048 } 20049 20050 var sharedQueue = updateQueue.shared; 20051 var pending = sharedQueue.pending; 20052 20053 if (pending === null) { 20054 // This is the first update. Create a circular list. 20055 update.next = update; 20056 } else { 20057 update.next = pending.next; 20058 pending.next = update; 20059 } 20060 20061 sharedQueue.pending = update; 20062 20063 { 20064 if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { 20065 error('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.'); 20066 20067 didWarnUpdateInsideUpdate = true; 20068 } 20069 } 20070} 20071function enqueueCapturedUpdate(workInProgress, update) { 20072 var current = workInProgress.alternate; 20073 20074 if (current !== null) { 20075 // Ensure the work-in-progress queue is a clone 20076 cloneUpdateQueue(current, workInProgress); 20077 } // Captured updates go only on the work-in-progress queue. 20078 20079 20080 var queue = workInProgress.updateQueue; // Append the update to the end of the list. 20081 20082 var last = queue.baseQueue; 20083 20084 if (last === null) { 20085 queue.baseQueue = update.next = update; 20086 update.next = update; 20087 } else { 20088 update.next = last.next; 20089 last.next = update; 20090 } 20091} 20092 20093function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { 20094 switch (update.tag) { 20095 case ReplaceState: 20096 { 20097 var payload = update.payload; 20098 20099 if (typeof payload === 'function') { 20100 // Updater function 20101 { 20102 enterDisallowedContextReadInDEV(); 20103 20104 if ( workInProgress.mode & StrictMode) { 20105 payload.call(instance, prevState, nextProps); 20106 } 20107 } 20108 20109 var nextState = payload.call(instance, prevState, nextProps); 20110 20111 { 20112 exitDisallowedContextReadInDEV(); 20113 } 20114 20115 return nextState; 20116 } // State object 20117 20118 20119 return payload; 20120 } 20121 20122 case CaptureUpdate: 20123 { 20124 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture; 20125 } 20126 // Intentional fallthrough 20127 20128 case UpdateState: 20129 { 20130 var _payload = update.payload; 20131 var partialState; 20132 20133 if (typeof _payload === 'function') { 20134 // Updater function 20135 { 20136 enterDisallowedContextReadInDEV(); 20137 20138 if ( workInProgress.mode & StrictMode) { 20139 _payload.call(instance, prevState, nextProps); 20140 } 20141 } 20142 20143 partialState = _payload.call(instance, prevState, nextProps); 20144 20145 { 20146 exitDisallowedContextReadInDEV(); 20147 } 20148 } else { 20149 // Partial state object 20150 partialState = _payload; 20151 } 20152 20153 if (partialState === null || partialState === undefined) { 20154 // Null and undefined are treated as no-ops. 20155 return prevState; 20156 } // Merge the partial state and the previous state. 20157 20158 20159 return _assign({}, prevState, partialState); 20160 } 20161 20162 case ForceUpdate: 20163 { 20164 hasForceUpdate = true; 20165 return prevState; 20166 } 20167 } 20168 20169 return prevState; 20170} 20171 20172function processUpdateQueue(workInProgress, props, instance, renderExpirationTime) { 20173 // This is always non-null on a ClassComponent or HostRoot 20174 var queue = workInProgress.updateQueue; 20175 hasForceUpdate = false; 20176 20177 { 20178 currentlyProcessingQueue = queue.shared; 20179 } // The last rebase update that is NOT part of the base state. 20180 20181 20182 var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. 20183 20184 var pendingQueue = queue.shared.pending; 20185 20186 if (pendingQueue !== null) { 20187 // We have new updates that haven't been processed yet. 20188 // We'll add them to the base queue. 20189 if (baseQueue !== null) { 20190 // Merge the pending queue and the base queue. 20191 var baseFirst = baseQueue.next; 20192 var pendingFirst = pendingQueue.next; 20193 baseQueue.next = pendingFirst; 20194 pendingQueue.next = baseFirst; 20195 } 20196 20197 baseQueue = pendingQueue; 20198 queue.shared.pending = null; // TODO: Pass `current` as argument 20199 20200 var current = workInProgress.alternate; 20201 20202 if (current !== null) { 20203 var currentQueue = current.updateQueue; 20204 20205 if (currentQueue !== null) { 20206 currentQueue.baseQueue = pendingQueue; 20207 } 20208 } 20209 } // These values may change as we process the queue. 20210 20211 20212 if (baseQueue !== null) { 20213 var first = baseQueue.next; // Iterate through the list of updates to compute the result. 20214 20215 var newState = queue.baseState; 20216 var newExpirationTime = NoWork; 20217 var newBaseState = null; 20218 var newBaseQueueFirst = null; 20219 var newBaseQueueLast = null; 20220 20221 if (first !== null) { 20222 var update = first; 20223 20224 do { 20225 var updateExpirationTime = update.expirationTime; 20226 20227 if (updateExpirationTime < renderExpirationTime) { 20228 // Priority is insufficient. Skip this update. If this is the first 20229 // skipped update, the previous update/state is the new base 20230 // update/state. 20231 var clone = { 20232 expirationTime: update.expirationTime, 20233 suspenseConfig: update.suspenseConfig, 20234 tag: update.tag, 20235 payload: update.payload, 20236 callback: update.callback, 20237 next: null 20238 }; 20239 20240 if (newBaseQueueLast === null) { 20241 newBaseQueueFirst = newBaseQueueLast = clone; 20242 newBaseState = newState; 20243 } else { 20244 newBaseQueueLast = newBaseQueueLast.next = clone; 20245 } // Update the remaining priority in the queue. 20246 20247 20248 if (updateExpirationTime > newExpirationTime) { 20249 newExpirationTime = updateExpirationTime; 20250 } 20251 } else { 20252 // This update does have sufficient priority. 20253 if (newBaseQueueLast !== null) { 20254 var _clone = { 20255 expirationTime: Sync, 20256 // This update is going to be committed so we never want uncommit it. 20257 suspenseConfig: update.suspenseConfig, 20258 tag: update.tag, 20259 payload: update.payload, 20260 callback: update.callback, 20261 next: null 20262 }; 20263 newBaseQueueLast = newBaseQueueLast.next = _clone; 20264 } // Mark the event time of this update as relevant to this render pass. 20265 // TODO: This should ideally use the true event time of this update rather than 20266 // its priority which is a derived and not reverseable value. 20267 // TODO: We should skip this update if it was already committed but currently 20268 // we have no way of detecting the difference between a committed and suspended 20269 // update here. 20270 20271 20272 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. 20273 20274 newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); 20275 var callback = update.callback; 20276 20277 if (callback !== null) { 20278 workInProgress.effectTag |= Callback; 20279 var effects = queue.effects; 20280 20281 if (effects === null) { 20282 queue.effects = [update]; 20283 } else { 20284 effects.push(update); 20285 } 20286 } 20287 } 20288 20289 update = update.next; 20290 20291 if (update === null || update === first) { 20292 pendingQueue = queue.shared.pending; 20293 20294 if (pendingQueue === null) { 20295 break; 20296 } else { 20297 // An update was scheduled from inside a reducer. Add the new 20298 // pending updates to the end of the list and keep processing. 20299 update = baseQueue.next = pendingQueue.next; 20300 pendingQueue.next = first; 20301 queue.baseQueue = baseQueue = pendingQueue; 20302 queue.shared.pending = null; 20303 } 20304 } 20305 } while (true); 20306 } 20307 20308 if (newBaseQueueLast === null) { 20309 newBaseState = newState; 20310 } else { 20311 newBaseQueueLast.next = newBaseQueueFirst; 20312 } 20313 20314 queue.baseState = newBaseState; 20315 queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. 20316 // This should be fine because the only two other things that contribute to 20317 // expiration time are props and context. We're already in the middle of the 20318 // begin phase by the time we start processing the queue, so we've already 20319 // dealt with the props. Context in components that specify 20320 // shouldComponentUpdate is tricky; but we'll have to account for 20321 // that regardless. 20322 20323 markUnprocessedUpdateTime(newExpirationTime); 20324 workInProgress.expirationTime = newExpirationTime; 20325 workInProgress.memoizedState = newState; 20326 } 20327 20328 { 20329 currentlyProcessingQueue = null; 20330 } 20331} 20332 20333function callCallback(callback, context) { 20334 if (!(typeof callback === 'function')) { 20335 { 20336 throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); 20337 } 20338 } 20339 20340 callback.call(context); 20341} 20342 20343function resetHasForceUpdateBeforeProcessing() { 20344 hasForceUpdate = false; 20345} 20346function checkHasForceUpdateAfterProcessing() { 20347 return hasForceUpdate; 20348} 20349function commitUpdateQueue(finishedWork, finishedQueue, instance) { 20350 // Commit the effects 20351 var effects = finishedQueue.effects; 20352 finishedQueue.effects = null; 20353 20354 if (effects !== null) { 20355 for (var i = 0; i < effects.length; i++) { 20356 var effect = effects[i]; 20357 var callback = effect.callback; 20358 20359 if (callback !== null) { 20360 effect.callback = null; 20361 callCallback(callback, instance); 20362 } 20363 } 20364 } 20365} 20366 20367var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; 20368function requestCurrentSuspenseConfig() { 20369 return ReactCurrentBatchConfig.suspense; 20370} 20371 20372var fakeInternalInstance = {}; 20373var isArray = Array.isArray; // React.Component uses a shared frozen object by default. 20374// We'll use it to determine whether we need to initialize legacy refs. 20375 20376var emptyRefsObject = new React.Component().refs; 20377var didWarnAboutStateAssignmentForComponent; 20378var didWarnAboutUninitializedState; 20379var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; 20380var didWarnAboutLegacyLifecyclesAndDerivedState; 20381var didWarnAboutUndefinedDerivedState; 20382var warnOnUndefinedDerivedState; 20383var warnOnInvalidCallback; 20384var didWarnAboutDirectlyAssigningPropsToState; 20385var didWarnAboutContextTypeAndContextTypes; 20386var didWarnAboutInvalidateContextType; 20387 20388{ 20389 didWarnAboutStateAssignmentForComponent = new Set(); 20390 didWarnAboutUninitializedState = new Set(); 20391 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); 20392 didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); 20393 didWarnAboutDirectlyAssigningPropsToState = new Set(); 20394 didWarnAboutUndefinedDerivedState = new Set(); 20395 didWarnAboutContextTypeAndContextTypes = new Set(); 20396 didWarnAboutInvalidateContextType = new Set(); 20397 var didWarnOnInvalidCallback = new Set(); 20398 20399 warnOnInvalidCallback = function (callback, callerName) { 20400 if (callback === null || typeof callback === 'function') { 20401 return; 20402 } 20403 20404 var key = callerName + "_" + callback; 20405 20406 if (!didWarnOnInvalidCallback.has(key)) { 20407 didWarnOnInvalidCallback.add(key); 20408 20409 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 20410 } 20411 }; 20412 20413 warnOnUndefinedDerivedState = function (type, partialState) { 20414 if (partialState === undefined) { 20415 var componentName = getComponentName(type) || 'Component'; 20416 20417 if (!didWarnAboutUndefinedDerivedState.has(componentName)) { 20418 didWarnAboutUndefinedDerivedState.add(componentName); 20419 20420 error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); 20421 } 20422 } 20423 }; // This is so gross but it's at least non-critical and can be removed if 20424 // it causes problems. This is meant to give a nicer error message for 20425 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 20426 // ...)) which otherwise throws a "_processChildContext is not a function" 20427 // exception. 20428 20429 20430 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 20431 enumerable: false, 20432 value: function () { 20433 { 20434 { 20435 throw Error( "_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)." ); 20436 } 20437 } 20438 } 20439 }); 20440 Object.freeze(fakeInternalInstance); 20441} 20442 20443function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { 20444 var prevState = workInProgress.memoizedState; 20445 20446 { 20447 if ( workInProgress.mode & StrictMode) { 20448 // Invoke the function an extra time to help detect side-effects. 20449 getDerivedStateFromProps(nextProps, prevState); 20450 } 20451 } 20452 20453 var partialState = getDerivedStateFromProps(nextProps, prevState); 20454 20455 { 20456 warnOnUndefinedDerivedState(ctor, partialState); 20457 } // Merge the partial state and the previous state. 20458 20459 20460 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); 20461 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the 20462 // base state. 20463 20464 if (workInProgress.expirationTime === NoWork) { 20465 // Queue is always non-null for classes 20466 var updateQueue = workInProgress.updateQueue; 20467 updateQueue.baseState = memoizedState; 20468 } 20469} 20470var classComponentUpdater = { 20471 isMounted: isMounted, 20472 enqueueSetState: function (inst, payload, callback) { 20473 var fiber = get(inst); 20474 var currentTime = requestCurrentTimeForUpdate(); 20475 var suspenseConfig = requestCurrentSuspenseConfig(); 20476 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 20477 var update = createUpdate(expirationTime, suspenseConfig); 20478 update.payload = payload; 20479 20480 if (callback !== undefined && callback !== null) { 20481 { 20482 warnOnInvalidCallback(callback, 'setState'); 20483 } 20484 20485 update.callback = callback; 20486 } 20487 20488 enqueueUpdate(fiber, update); 20489 scheduleWork(fiber, expirationTime); 20490 }, 20491 enqueueReplaceState: function (inst, payload, callback) { 20492 var fiber = get(inst); 20493 var currentTime = requestCurrentTimeForUpdate(); 20494 var suspenseConfig = requestCurrentSuspenseConfig(); 20495 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 20496 var update = createUpdate(expirationTime, suspenseConfig); 20497 update.tag = ReplaceState; 20498 update.payload = payload; 20499 20500 if (callback !== undefined && callback !== null) { 20501 { 20502 warnOnInvalidCallback(callback, 'replaceState'); 20503 } 20504 20505 update.callback = callback; 20506 } 20507 20508 enqueueUpdate(fiber, update); 20509 scheduleWork(fiber, expirationTime); 20510 }, 20511 enqueueForceUpdate: function (inst, callback) { 20512 var fiber = get(inst); 20513 var currentTime = requestCurrentTimeForUpdate(); 20514 var suspenseConfig = requestCurrentSuspenseConfig(); 20515 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 20516 var update = createUpdate(expirationTime, suspenseConfig); 20517 update.tag = ForceUpdate; 20518 20519 if (callback !== undefined && callback !== null) { 20520 { 20521 warnOnInvalidCallback(callback, 'forceUpdate'); 20522 } 20523 20524 update.callback = callback; 20525 } 20526 20527 enqueueUpdate(fiber, update); 20528 scheduleWork(fiber, expirationTime); 20529 } 20530}; 20531 20532function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { 20533 var instance = workInProgress.stateNode; 20534 20535 if (typeof instance.shouldComponentUpdate === 'function') { 20536 { 20537 if ( workInProgress.mode & StrictMode) { 20538 // Invoke the function an extra time to help detect side-effects. 20539 instance.shouldComponentUpdate(newProps, newState, nextContext); 20540 } 20541 } 20542 20543 startPhaseTimer(workInProgress, 'shouldComponentUpdate'); 20544 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); 20545 stopPhaseTimer(); 20546 20547 { 20548 if (shouldUpdate === undefined) { 20549 error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); 20550 } 20551 } 20552 20553 return shouldUpdate; 20554 } 20555 20556 if (ctor.prototype && ctor.prototype.isPureReactComponent) { 20557 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 20558 } 20559 20560 return true; 20561} 20562 20563function checkClassInstance(workInProgress, ctor, newProps) { 20564 var instance = workInProgress.stateNode; 20565 20566 { 20567 var name = getComponentName(ctor) || 'Component'; 20568 var renderPresent = instance.render; 20569 20570 if (!renderPresent) { 20571 if (ctor.prototype && typeof ctor.prototype.render === 'function') { 20572 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 20573 } else { 20574 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 20575 } 20576 } 20577 20578 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { 20579 error('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); 20580 } 20581 20582 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { 20583 error('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); 20584 } 20585 20586 if (instance.propTypes) { 20587 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); 20588 } 20589 20590 if (instance.contextType) { 20591 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); 20592 } 20593 20594 { 20595 if (instance.contextTypes) { 20596 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); 20597 } 20598 20599 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { 20600 didWarnAboutContextTypeAndContextTypes.add(ctor); 20601 20602 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); 20603 } 20604 } 20605 20606 if (typeof instance.componentShouldUpdate === 'function') { 20607 error('%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); 20608 } 20609 20610 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 20611 error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component'); 20612 } 20613 20614 if (typeof instance.componentDidUnmount === 'function') { 20615 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); 20616 } 20617 20618 if (typeof instance.componentDidReceiveProps === 'function') { 20619 error('%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); 20620 } 20621 20622 if (typeof instance.componentWillRecieveProps === 'function') { 20623 error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); 20624 } 20625 20626 if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { 20627 error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); 20628 } 20629 20630 var hasMutatedProps = instance.props !== newProps; 20631 20632 if (instance.props !== undefined && hasMutatedProps) { 20633 error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); 20634 } 20635 20636 if (instance.defaultProps) { 20637 error('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); 20638 } 20639 20640 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { 20641 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); 20642 20643 error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); 20644 } 20645 20646 if (typeof instance.getDerivedStateFromProps === 'function') { 20647 error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 20648 } 20649 20650 if (typeof instance.getDerivedStateFromError === 'function') { 20651 error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 20652 } 20653 20654 if (typeof ctor.getSnapshotBeforeUpdate === 'function') { 20655 error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); 20656 } 20657 20658 var _state = instance.state; 20659 20660 if (_state && (typeof _state !== 'object' || isArray(_state))) { 20661 error('%s.state: must be set to an object or null', name); 20662 } 20663 20664 if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { 20665 error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); 20666 } 20667 } 20668} 20669 20670function adoptClassInstance(workInProgress, instance) { 20671 instance.updater = classComponentUpdater; 20672 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates 20673 20674 set(instance, workInProgress); 20675 20676 { 20677 instance._reactInternalInstance = fakeInternalInstance; 20678 } 20679} 20680 20681function constructClassInstance(workInProgress, ctor, props) { 20682 var isLegacyContextConsumer = false; 20683 var unmaskedContext = emptyContextObject; 20684 var context = emptyContextObject; 20685 var contextType = ctor.contextType; 20686 20687 { 20688 if ('contextType' in ctor) { 20689 var isValid = // Allow null for conditional declaration 20690 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> 20691 20692 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { 20693 didWarnAboutInvalidateContextType.add(ctor); 20694 var addendum = ''; 20695 20696 if (contextType === undefined) { 20697 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; 20698 } else if (typeof contextType !== 'object') { 20699 addendum = ' However, it is set to a ' + typeof contextType + '.'; 20700 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { 20701 addendum = ' Did you accidentally pass the Context.Provider instead?'; 20702 } else if (contextType._context !== undefined) { 20703 // <Context.Consumer> 20704 addendum = ' Did you accidentally pass the Context.Consumer instead?'; 20705 } else { 20706 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; 20707 } 20708 20709 error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); 20710 } 20711 } 20712 } 20713 20714 if (typeof contextType === 'object' && contextType !== null) { 20715 context = readContext(contextType); 20716 } else { 20717 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 20718 var contextTypes = ctor.contextTypes; 20719 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; 20720 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; 20721 } // Instantiate twice to help detect side-effects. 20722 20723 20724 { 20725 if ( workInProgress.mode & StrictMode) { 20726 new ctor(props, context); // eslint-disable-line no-new 20727 } 20728 } 20729 20730 var instance = new ctor(props, context); 20731 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; 20732 adoptClassInstance(workInProgress, instance); 20733 20734 { 20735 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { 20736 var componentName = getComponentName(ctor) || 'Component'; 20737 20738 if (!didWarnAboutUninitializedState.has(componentName)) { 20739 didWarnAboutUninitializedState.add(componentName); 20740 20741 error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); 20742 } 20743 } // If new component APIs are defined, "unsafe" lifecycles won't be called. 20744 // Warn about these lifecycles if they are present. 20745 // Don't warn about react-lifecycles-compat polyfilled methods though. 20746 20747 20748 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { 20749 var foundWillMountName = null; 20750 var foundWillReceivePropsName = null; 20751 var foundWillUpdateName = null; 20752 20753 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 20754 foundWillMountName = 'componentWillMount'; 20755 } else if (typeof instance.UNSAFE_componentWillMount === 'function') { 20756 foundWillMountName = 'UNSAFE_componentWillMount'; 20757 } 20758 20759 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 20760 foundWillReceivePropsName = 'componentWillReceiveProps'; 20761 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 20762 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; 20763 } 20764 20765 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 20766 foundWillUpdateName = 'componentWillUpdate'; 20767 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 20768 foundWillUpdateName = 'UNSAFE_componentWillUpdate'; 20769 } 20770 20771 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { 20772 var _componentName = getComponentName(ctor) || 'Component'; 20773 20774 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; 20775 20776 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { 20777 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); 20778 20779 error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); 20780 } 20781 } 20782 } 20783 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 20784 // ReactFiberContext usually updates this cache but can't for newly-created instances. 20785 20786 20787 if (isLegacyContextConsumer) { 20788 cacheContext(workInProgress, unmaskedContext, context); 20789 } 20790 20791 return instance; 20792} 20793 20794function callComponentWillMount(workInProgress, instance) { 20795 startPhaseTimer(workInProgress, 'componentWillMount'); 20796 var oldState = instance.state; 20797 20798 if (typeof instance.componentWillMount === 'function') { 20799 instance.componentWillMount(); 20800 } 20801 20802 if (typeof instance.UNSAFE_componentWillMount === 'function') { 20803 instance.UNSAFE_componentWillMount(); 20804 } 20805 20806 stopPhaseTimer(); 20807 20808 if (oldState !== instance.state) { 20809 { 20810 error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); 20811 } 20812 20813 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 20814 } 20815} 20816 20817function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { 20818 var oldState = instance.state; 20819 startPhaseTimer(workInProgress, 'componentWillReceiveProps'); 20820 20821 if (typeof instance.componentWillReceiveProps === 'function') { 20822 instance.componentWillReceiveProps(newProps, nextContext); 20823 } 20824 20825 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 20826 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); 20827 } 20828 20829 stopPhaseTimer(); 20830 20831 if (instance.state !== oldState) { 20832 { 20833 var componentName = getComponentName(workInProgress.type) || 'Component'; 20834 20835 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { 20836 didWarnAboutStateAssignmentForComponent.add(componentName); 20837 20838 error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 20839 } 20840 } 20841 20842 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 20843 } 20844} // Invokes the mount life-cycles on a previously never rendered instance. 20845 20846 20847function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { 20848 { 20849 checkClassInstance(workInProgress, ctor, newProps); 20850 } 20851 20852 var instance = workInProgress.stateNode; 20853 instance.props = newProps; 20854 instance.state = workInProgress.memoizedState; 20855 instance.refs = emptyRefsObject; 20856 initializeUpdateQueue(workInProgress); 20857 var contextType = ctor.contextType; 20858 20859 if (typeof contextType === 'object' && contextType !== null) { 20860 instance.context = readContext(contextType); 20861 } else { 20862 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 20863 instance.context = getMaskedContext(workInProgress, unmaskedContext); 20864 } 20865 20866 { 20867 if (instance.state === newProps) { 20868 var componentName = getComponentName(ctor) || 'Component'; 20869 20870 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { 20871 didWarnAboutDirectlyAssigningPropsToState.add(componentName); 20872 20873 error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); 20874 } 20875 } 20876 20877 if (workInProgress.mode & StrictMode) { 20878 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); 20879 } 20880 20881 { 20882 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); 20883 } 20884 } 20885 20886 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 20887 instance.state = workInProgress.memoizedState; 20888 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 20889 20890 if (typeof getDerivedStateFromProps === 'function') { 20891 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 20892 instance.state = workInProgress.memoizedState; 20893 } // In order to support react-lifecycles-compat polyfilled components, 20894 // Unsafe lifecycles should not be invoked for components using the new APIs. 20895 20896 20897 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 20898 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's 20899 // process them now. 20900 20901 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 20902 instance.state = workInProgress.memoizedState; 20903 } 20904 20905 if (typeof instance.componentDidMount === 'function') { 20906 workInProgress.effectTag |= Update; 20907 } 20908} 20909 20910function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { 20911 var instance = workInProgress.stateNode; 20912 var oldProps = workInProgress.memoizedProps; 20913 instance.props = oldProps; 20914 var oldContext = instance.context; 20915 var contextType = ctor.contextType; 20916 var nextContext = emptyContextObject; 20917 20918 if (typeof contextType === 'object' && contextType !== null) { 20919 nextContext = readContext(contextType); 20920 } else { 20921 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 20922 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); 20923 } 20924 20925 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 20926 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 20927 // ever the previously attempted to render - not the "current". However, 20928 // during componentDidUpdate we pass the "current" props. 20929 // In order to support react-lifecycles-compat polyfilled components, 20930 // Unsafe lifecycles should not be invoked for components using the new APIs. 20931 20932 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 20933 if (oldProps !== newProps || oldContext !== nextContext) { 20934 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 20935 } 20936 } 20937 20938 resetHasForceUpdateBeforeProcessing(); 20939 var oldState = workInProgress.memoizedState; 20940 var newState = instance.state = oldState; 20941 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 20942 newState = workInProgress.memoizedState; 20943 20944 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 20945 // If an update was already in progress, we should schedule an Update 20946 // effect even though we're bailing out, so that cWU/cDU are called. 20947 if (typeof instance.componentDidMount === 'function') { 20948 workInProgress.effectTag |= Update; 20949 } 20950 20951 return false; 20952 } 20953 20954 if (typeof getDerivedStateFromProps === 'function') { 20955 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 20956 newState = workInProgress.memoizedState; 20957 } 20958 20959 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 20960 20961 if (shouldUpdate) { 20962 // In order to support react-lifecycles-compat polyfilled components, 20963 // Unsafe lifecycles should not be invoked for components using the new APIs. 20964 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 20965 startPhaseTimer(workInProgress, 'componentWillMount'); 20966 20967 if (typeof instance.componentWillMount === 'function') { 20968 instance.componentWillMount(); 20969 } 20970 20971 if (typeof instance.UNSAFE_componentWillMount === 'function') { 20972 instance.UNSAFE_componentWillMount(); 20973 } 20974 20975 stopPhaseTimer(); 20976 } 20977 20978 if (typeof instance.componentDidMount === 'function') { 20979 workInProgress.effectTag |= Update; 20980 } 20981 } else { 20982 // If an update was already in progress, we should schedule an Update 20983 // effect even though we're bailing out, so that cWU/cDU are called. 20984 if (typeof instance.componentDidMount === 'function') { 20985 workInProgress.effectTag |= Update; 20986 } // If shouldComponentUpdate returned false, we should still update the 20987 // memoized state to indicate that this work can be reused. 20988 20989 20990 workInProgress.memoizedProps = newProps; 20991 workInProgress.memoizedState = newState; 20992 } // Update the existing instance's state, props, and context pointers even 20993 // if shouldComponentUpdate returns false. 20994 20995 20996 instance.props = newProps; 20997 instance.state = newState; 20998 instance.context = nextContext; 20999 return shouldUpdate; 21000} // Invokes the update life-cycles and returns false if it shouldn't rerender. 21001 21002 21003function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) { 21004 var instance = workInProgress.stateNode; 21005 cloneUpdateQueue(current, workInProgress); 21006 var oldProps = workInProgress.memoizedProps; 21007 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps); 21008 var oldContext = instance.context; 21009 var contextType = ctor.contextType; 21010 var nextContext = emptyContextObject; 21011 21012 if (typeof contextType === 'object' && contextType !== null) { 21013 nextContext = readContext(contextType); 21014 } else { 21015 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 21016 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); 21017 } 21018 21019 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 21020 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 21021 // ever the previously attempted to render - not the "current". However, 21022 // during componentDidUpdate we pass the "current" props. 21023 // In order to support react-lifecycles-compat polyfilled components, 21024 // Unsafe lifecycles should not be invoked for components using the new APIs. 21025 21026 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 21027 if (oldProps !== newProps || oldContext !== nextContext) { 21028 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 21029 } 21030 } 21031 21032 resetHasForceUpdateBeforeProcessing(); 21033 var oldState = workInProgress.memoizedState; 21034 var newState = instance.state = oldState; 21035 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 21036 newState = workInProgress.memoizedState; 21037 21038 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 21039 // If an update was already in progress, we should schedule an Update 21040 // effect even though we're bailing out, so that cWU/cDU are called. 21041 if (typeof instance.componentDidUpdate === 'function') { 21042 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 21043 workInProgress.effectTag |= Update; 21044 } 21045 } 21046 21047 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 21048 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 21049 workInProgress.effectTag |= Snapshot; 21050 } 21051 } 21052 21053 return false; 21054 } 21055 21056 if (typeof getDerivedStateFromProps === 'function') { 21057 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 21058 newState = workInProgress.memoizedState; 21059 } 21060 21061 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 21062 21063 if (shouldUpdate) { 21064 // In order to support react-lifecycles-compat polyfilled components, 21065 // Unsafe lifecycles should not be invoked for components using the new APIs. 21066 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { 21067 startPhaseTimer(workInProgress, 'componentWillUpdate'); 21068 21069 if (typeof instance.componentWillUpdate === 'function') { 21070 instance.componentWillUpdate(newProps, newState, nextContext); 21071 } 21072 21073 if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 21074 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); 21075 } 21076 21077 stopPhaseTimer(); 21078 } 21079 21080 if (typeof instance.componentDidUpdate === 'function') { 21081 workInProgress.effectTag |= Update; 21082 } 21083 21084 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 21085 workInProgress.effectTag |= Snapshot; 21086 } 21087 } else { 21088 // If an update was already in progress, we should schedule an Update 21089 // effect even though we're bailing out, so that cWU/cDU are called. 21090 if (typeof instance.componentDidUpdate === 'function') { 21091 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 21092 workInProgress.effectTag |= Update; 21093 } 21094 } 21095 21096 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 21097 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 21098 workInProgress.effectTag |= Snapshot; 21099 } 21100 } // If shouldComponentUpdate returned false, we should still update the 21101 // memoized props/state to indicate that this work can be reused. 21102 21103 21104 workInProgress.memoizedProps = newProps; 21105 workInProgress.memoizedState = newState; 21106 } // Update the existing instance's state, props, and context pointers even 21107 // if shouldComponentUpdate returns false. 21108 21109 21110 instance.props = newProps; 21111 instance.state = newState; 21112 instance.context = nextContext; 21113 return shouldUpdate; 21114} 21115 21116var didWarnAboutMaps; 21117var didWarnAboutGenerators; 21118var didWarnAboutStringRefs; 21119var ownerHasKeyUseWarning; 21120var ownerHasFunctionTypeWarning; 21121 21122var warnForMissingKey = function (child) {}; 21123 21124{ 21125 didWarnAboutMaps = false; 21126 didWarnAboutGenerators = false; 21127 didWarnAboutStringRefs = {}; 21128 /** 21129 * Warn if there's no key explicitly set on dynamic arrays of children or 21130 * object keys are not valid. This allows us to keep track of children between 21131 * updates. 21132 */ 21133 21134 ownerHasKeyUseWarning = {}; 21135 ownerHasFunctionTypeWarning = {}; 21136 21137 warnForMissingKey = function (child) { 21138 if (child === null || typeof child !== 'object') { 21139 return; 21140 } 21141 21142 if (!child._store || child._store.validated || child.key != null) { 21143 return; 21144 } 21145 21146 if (!(typeof child._store === 'object')) { 21147 { 21148 throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); 21149 } 21150 } 21151 21152 child._store.validated = true; 21153 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev(); 21154 21155 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 21156 return; 21157 } 21158 21159 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 21160 21161 error('Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.'); 21162 }; 21163} 21164 21165var isArray$1 = Array.isArray; 21166 21167function coerceRef(returnFiber, current, element) { 21168 var mixedRef = element.ref; 21169 21170 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { 21171 { 21172 // TODO: Clean this up once we turn on the string ref warning for 21173 // everyone, because the strict mode case will no longer be relevant 21174 if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs 21175 // because these cannot be automatically converted to an arrow function 21176 // using a codemod. Therefore, we don't have to warn about string refs again. 21177 !(element._owner && element._self && element._owner.stateNode !== element._self)) { 21178 var componentName = getComponentName(returnFiber.type) || 'Component'; 21179 21180 if (!didWarnAboutStringRefs[componentName]) { 21181 { 21182 error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber)); 21183 } 21184 21185 didWarnAboutStringRefs[componentName] = true; 21186 } 21187 } 21188 } 21189 21190 if (element._owner) { 21191 var owner = element._owner; 21192 var inst; 21193 21194 if (owner) { 21195 var ownerFiber = owner; 21196 21197 if (!(ownerFiber.tag === ClassComponent)) { 21198 { 21199 throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" ); 21200 } 21201 } 21202 21203 inst = ownerFiber.stateNode; 21204 } 21205 21206 if (!inst) { 21207 { 21208 throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); 21209 } 21210 } 21211 21212 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref 21213 21214 if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { 21215 return current.ref; 21216 } 21217 21218 var ref = function (value) { 21219 var refs = inst.refs; 21220 21221 if (refs === emptyRefsObject) { 21222 // This is a lazy pooled frozen object, so we need to initialize. 21223 refs = inst.refs = {}; 21224 } 21225 21226 if (value === null) { 21227 delete refs[stringRef]; 21228 } else { 21229 refs[stringRef] = value; 21230 } 21231 }; 21232 21233 ref._stringRef = stringRef; 21234 return ref; 21235 } else { 21236 if (!(typeof mixedRef === 'string')) { 21237 { 21238 throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); 21239 } 21240 } 21241 21242 if (!element._owner) { 21243 { 21244 throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." ); 21245 } 21246 } 21247 } 21248 } 21249 21250 return mixedRef; 21251} 21252 21253function throwOnInvalidObjectType(returnFiber, newChild) { 21254 if (returnFiber.type !== 'textarea') { 21255 var addendum = ''; 21256 21257 { 21258 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev(); 21259 } 21260 21261 { 21262 { 21263 throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum ); 21264 } 21265 } 21266 } 21267} 21268 21269function warnOnFunctionType() { 21270 { 21271 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.' + getCurrentFiberStackInDev(); 21272 21273 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { 21274 return; 21275 } 21276 21277 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; 21278 21279 error('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.'); 21280 } 21281} // This wrapper function exists because I expect to clone the code in each path 21282// to be able to optimize each path individually by branching early. This needs 21283// a compiler or we can do it manually. Helpers that don't need this branching 21284// live outside of this function. 21285 21286 21287function ChildReconciler(shouldTrackSideEffects) { 21288 function deleteChild(returnFiber, childToDelete) { 21289 if (!shouldTrackSideEffects) { 21290 // Noop. 21291 return; 21292 } // Deletions are added in reversed order so we add it to the front. 21293 // At this point, the return fiber's effect list is empty except for 21294 // deletions, so we can just append the deletion to the list. The remaining 21295 // effects aren't added until the complete phase. Once we implement 21296 // resuming, this may not be true. 21297 21298 21299 var last = returnFiber.lastEffect; 21300 21301 if (last !== null) { 21302 last.nextEffect = childToDelete; 21303 returnFiber.lastEffect = childToDelete; 21304 } else { 21305 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 21306 } 21307 21308 childToDelete.nextEffect = null; 21309 childToDelete.effectTag = Deletion; 21310 } 21311 21312 function deleteRemainingChildren(returnFiber, currentFirstChild) { 21313 if (!shouldTrackSideEffects) { 21314 // Noop. 21315 return null; 21316 } // TODO: For the shouldClone case, this could be micro-optimized a bit by 21317 // assuming that after the first child we've already added everything. 21318 21319 21320 var childToDelete = currentFirstChild; 21321 21322 while (childToDelete !== null) { 21323 deleteChild(returnFiber, childToDelete); 21324 childToDelete = childToDelete.sibling; 21325 } 21326 21327 return null; 21328 } 21329 21330 function mapRemainingChildren(returnFiber, currentFirstChild) { 21331 // Add the remaining children to a temporary map so that we can find them by 21332 // keys quickly. Implicit (null) keys get added to this set with their index 21333 // instead. 21334 var existingChildren = new Map(); 21335 var existingChild = currentFirstChild; 21336 21337 while (existingChild !== null) { 21338 if (existingChild.key !== null) { 21339 existingChildren.set(existingChild.key, existingChild); 21340 } else { 21341 existingChildren.set(existingChild.index, existingChild); 21342 } 21343 21344 existingChild = existingChild.sibling; 21345 } 21346 21347 return existingChildren; 21348 } 21349 21350 function useFiber(fiber, pendingProps) { 21351 // We currently set sibling to null and index to 0 here because it is easy 21352 // to forget to do before returning it. E.g. for the single child case. 21353 var clone = createWorkInProgress(fiber, pendingProps); 21354 clone.index = 0; 21355 clone.sibling = null; 21356 return clone; 21357 } 21358 21359 function placeChild(newFiber, lastPlacedIndex, newIndex) { 21360 newFiber.index = newIndex; 21361 21362 if (!shouldTrackSideEffects) { 21363 // Noop. 21364 return lastPlacedIndex; 21365 } 21366 21367 var current = newFiber.alternate; 21368 21369 if (current !== null) { 21370 var oldIndex = current.index; 21371 21372 if (oldIndex < lastPlacedIndex) { 21373 // This is a move. 21374 newFiber.effectTag = Placement; 21375 return lastPlacedIndex; 21376 } else { 21377 // This item can stay in place. 21378 return oldIndex; 21379 } 21380 } else { 21381 // This is an insertion. 21382 newFiber.effectTag = Placement; 21383 return lastPlacedIndex; 21384 } 21385 } 21386 21387 function placeSingleChild(newFiber) { 21388 // This is simpler for the single child case. We only need to do a 21389 // placement for inserting new children. 21390 if (shouldTrackSideEffects && newFiber.alternate === null) { 21391 newFiber.effectTag = Placement; 21392 } 21393 21394 return newFiber; 21395 } 21396 21397 function updateTextNode(returnFiber, current, textContent, expirationTime) { 21398 if (current === null || current.tag !== HostText) { 21399 // Insert 21400 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 21401 created.return = returnFiber; 21402 return created; 21403 } else { 21404 // Update 21405 var existing = useFiber(current, textContent); 21406 existing.return = returnFiber; 21407 return existing; 21408 } 21409 } 21410 21411 function updateElement(returnFiber, current, element, expirationTime) { 21412 if (current !== null) { 21413 if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 21414 isCompatibleFamilyForHotReloading(current, element) )) { 21415 // Move based on index 21416 var existing = useFiber(current, element.props); 21417 existing.ref = coerceRef(returnFiber, current, element); 21418 existing.return = returnFiber; 21419 21420 { 21421 existing._debugSource = element._source; 21422 existing._debugOwner = element._owner; 21423 } 21424 21425 return existing; 21426 } 21427 } // Insert 21428 21429 21430 var created = createFiberFromElement(element, returnFiber.mode, expirationTime); 21431 created.ref = coerceRef(returnFiber, current, element); 21432 created.return = returnFiber; 21433 return created; 21434 } 21435 21436 function updatePortal(returnFiber, current, portal, expirationTime) { 21437 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 21438 // Insert 21439 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 21440 created.return = returnFiber; 21441 return created; 21442 } else { 21443 // Update 21444 var existing = useFiber(current, portal.children || []); 21445 existing.return = returnFiber; 21446 return existing; 21447 } 21448 } 21449 21450 function updateFragment(returnFiber, current, fragment, expirationTime, key) { 21451 if (current === null || current.tag !== Fragment) { 21452 // Insert 21453 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key); 21454 created.return = returnFiber; 21455 return created; 21456 } else { 21457 // Update 21458 var existing = useFiber(current, fragment); 21459 existing.return = returnFiber; 21460 return existing; 21461 } 21462 } 21463 21464 function createChild(returnFiber, newChild, expirationTime) { 21465 if (typeof newChild === 'string' || typeof newChild === 'number') { 21466 // Text nodes don't have keys. If the previous node is implicitly keyed 21467 // we can continue to replace it without aborting even if it is not a text 21468 // node. 21469 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime); 21470 created.return = returnFiber; 21471 return created; 21472 } 21473 21474 if (typeof newChild === 'object' && newChild !== null) { 21475 switch (newChild.$$typeof) { 21476 case REACT_ELEMENT_TYPE: 21477 { 21478 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime); 21479 21480 _created.ref = coerceRef(returnFiber, null, newChild); 21481 _created.return = returnFiber; 21482 return _created; 21483 } 21484 21485 case REACT_PORTAL_TYPE: 21486 { 21487 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime); 21488 21489 _created2.return = returnFiber; 21490 return _created2; 21491 } 21492 } 21493 21494 if (isArray$1(newChild) || getIteratorFn(newChild)) { 21495 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null); 21496 21497 _created3.return = returnFiber; 21498 return _created3; 21499 } 21500 21501 throwOnInvalidObjectType(returnFiber, newChild); 21502 } 21503 21504 { 21505 if (typeof newChild === 'function') { 21506 warnOnFunctionType(); 21507 } 21508 } 21509 21510 return null; 21511 } 21512 21513 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { 21514 // Update the fiber if the keys match, otherwise return null. 21515 var key = oldFiber !== null ? oldFiber.key : null; 21516 21517 if (typeof newChild === 'string' || typeof newChild === 'number') { 21518 // Text nodes don't have keys. If the previous node is implicitly keyed 21519 // we can continue to replace it without aborting even if it is not a text 21520 // node. 21521 if (key !== null) { 21522 return null; 21523 } 21524 21525 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); 21526 } 21527 21528 if (typeof newChild === 'object' && newChild !== null) { 21529 switch (newChild.$$typeof) { 21530 case REACT_ELEMENT_TYPE: 21531 { 21532 if (newChild.key === key) { 21533 if (newChild.type === REACT_FRAGMENT_TYPE) { 21534 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); 21535 } 21536 21537 return updateElement(returnFiber, oldFiber, newChild, expirationTime); 21538 } else { 21539 return null; 21540 } 21541 } 21542 21543 case REACT_PORTAL_TYPE: 21544 { 21545 if (newChild.key === key) { 21546 return updatePortal(returnFiber, oldFiber, newChild, expirationTime); 21547 } else { 21548 return null; 21549 } 21550 } 21551 } 21552 21553 if (isArray$1(newChild) || getIteratorFn(newChild)) { 21554 if (key !== null) { 21555 return null; 21556 } 21557 21558 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); 21559 } 21560 21561 throwOnInvalidObjectType(returnFiber, newChild); 21562 } 21563 21564 { 21565 if (typeof newChild === 'function') { 21566 warnOnFunctionType(); 21567 } 21568 } 21569 21570 return null; 21571 } 21572 21573 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { 21574 if (typeof newChild === 'string' || typeof newChild === 'number') { 21575 // Text nodes don't have keys, so we neither have to check the old nor 21576 // new node for the key. If both are text nodes, they match. 21577 var matchedFiber = existingChildren.get(newIdx) || null; 21578 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); 21579 } 21580 21581 if (typeof newChild === 'object' && newChild !== null) { 21582 switch (newChild.$$typeof) { 21583 case REACT_ELEMENT_TYPE: 21584 { 21585 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 21586 21587 if (newChild.type === REACT_FRAGMENT_TYPE) { 21588 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); 21589 } 21590 21591 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); 21592 } 21593 21594 case REACT_PORTAL_TYPE: 21595 { 21596 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 21597 21598 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime); 21599 } 21600 } 21601 21602 if (isArray$1(newChild) || getIteratorFn(newChild)) { 21603 var _matchedFiber3 = existingChildren.get(newIdx) || null; 21604 21605 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null); 21606 } 21607 21608 throwOnInvalidObjectType(returnFiber, newChild); 21609 } 21610 21611 { 21612 if (typeof newChild === 'function') { 21613 warnOnFunctionType(); 21614 } 21615 } 21616 21617 return null; 21618 } 21619 /** 21620 * Warns if there is a duplicate or missing key 21621 */ 21622 21623 21624 function warnOnInvalidKey(child, knownKeys) { 21625 { 21626 if (typeof child !== 'object' || child === null) { 21627 return knownKeys; 21628 } 21629 21630 switch (child.$$typeof) { 21631 case REACT_ELEMENT_TYPE: 21632 case REACT_PORTAL_TYPE: 21633 warnForMissingKey(child); 21634 var key = child.key; 21635 21636 if (typeof key !== 'string') { 21637 break; 21638 } 21639 21640 if (knownKeys === null) { 21641 knownKeys = new Set(); 21642 knownKeys.add(key); 21643 break; 21644 } 21645 21646 if (!knownKeys.has(key)) { 21647 knownKeys.add(key); 21648 break; 21649 } 21650 21651 error('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.', key); 21652 21653 break; 21654 } 21655 } 21656 21657 return knownKeys; 21658 } 21659 21660 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { 21661 // This algorithm can't optimize by searching from both ends since we 21662 // don't have backpointers on fibers. I'm trying to see how far we can get 21663 // with that model. If it ends up not being worth the tradeoffs, we can 21664 // add it later. 21665 // Even with a two ended optimization, we'd want to optimize for the case 21666 // where there are few changes and brute force the comparison instead of 21667 // going for the Map. It'd like to explore hitting that path first in 21668 // forward-only mode and only go for the Map once we notice that we need 21669 // lots of look ahead. This doesn't handle reversal as well as two ended 21670 // search but that's unusual. Besides, for the two ended optimization to 21671 // work on Iterables, we'd need to copy the whole set. 21672 // In this first iteration, we'll just live with hitting the bad case 21673 // (adding everything to a Map) in for every insert/move. 21674 // If you change this code, also update reconcileChildrenIterator() which 21675 // uses the same algorithm. 21676 { 21677 // First, validate keys. 21678 var knownKeys = null; 21679 21680 for (var i = 0; i < newChildren.length; i++) { 21681 var child = newChildren[i]; 21682 knownKeys = warnOnInvalidKey(child, knownKeys); 21683 } 21684 } 21685 21686 var resultingFirstChild = null; 21687 var previousNewFiber = null; 21688 var oldFiber = currentFirstChild; 21689 var lastPlacedIndex = 0; 21690 var newIdx = 0; 21691 var nextOldFiber = null; 21692 21693 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 21694 if (oldFiber.index > newIdx) { 21695 nextOldFiber = oldFiber; 21696 oldFiber = null; 21697 } else { 21698 nextOldFiber = oldFiber.sibling; 21699 } 21700 21701 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); 21702 21703 if (newFiber === null) { 21704 // TODO: This breaks on empty slots like null children. That's 21705 // unfortunate because it triggers the slow path all the time. We need 21706 // a better way to communicate whether this was a miss or null, 21707 // boolean, undefined, etc. 21708 if (oldFiber === null) { 21709 oldFiber = nextOldFiber; 21710 } 21711 21712 break; 21713 } 21714 21715 if (shouldTrackSideEffects) { 21716 if (oldFiber && newFiber.alternate === null) { 21717 // We matched the slot, but we didn't reuse the existing fiber, so we 21718 // need to delete the existing child. 21719 deleteChild(returnFiber, oldFiber); 21720 } 21721 } 21722 21723 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 21724 21725 if (previousNewFiber === null) { 21726 // TODO: Move out of the loop. This only happens for the first run. 21727 resultingFirstChild = newFiber; 21728 } else { 21729 // TODO: Defer siblings if we're not at the right index for this slot. 21730 // I.e. if we had null values before, then we want to defer this 21731 // for each null value. However, we also don't want to call updateSlot 21732 // with the previous one. 21733 previousNewFiber.sibling = newFiber; 21734 } 21735 21736 previousNewFiber = newFiber; 21737 oldFiber = nextOldFiber; 21738 } 21739 21740 if (newIdx === newChildren.length) { 21741 // We've reached the end of the new children. We can delete the rest. 21742 deleteRemainingChildren(returnFiber, oldFiber); 21743 return resultingFirstChild; 21744 } 21745 21746 if (oldFiber === null) { 21747 // If we don't have any more existing children we can choose a fast path 21748 // since the rest will all be insertions. 21749 for (; newIdx < newChildren.length; newIdx++) { 21750 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); 21751 21752 if (_newFiber === null) { 21753 continue; 21754 } 21755 21756 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 21757 21758 if (previousNewFiber === null) { 21759 // TODO: Move out of the loop. This only happens for the first run. 21760 resultingFirstChild = _newFiber; 21761 } else { 21762 previousNewFiber.sibling = _newFiber; 21763 } 21764 21765 previousNewFiber = _newFiber; 21766 } 21767 21768 return resultingFirstChild; 21769 } // Add all children to a key map for quick lookups. 21770 21771 21772 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 21773 21774 for (; newIdx < newChildren.length; newIdx++) { 21775 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); 21776 21777 if (_newFiber2 !== null) { 21778 if (shouldTrackSideEffects) { 21779 if (_newFiber2.alternate !== null) { 21780 // The new fiber is a work in progress, but if there exists a 21781 // current, that means that we reused the fiber. We need to delete 21782 // it from the child list so that we don't add it to the deletion 21783 // list. 21784 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); 21785 } 21786 } 21787 21788 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 21789 21790 if (previousNewFiber === null) { 21791 resultingFirstChild = _newFiber2; 21792 } else { 21793 previousNewFiber.sibling = _newFiber2; 21794 } 21795 21796 previousNewFiber = _newFiber2; 21797 } 21798 } 21799 21800 if (shouldTrackSideEffects) { 21801 // Any existing children that weren't consumed above were deleted. We need 21802 // to add them to the deletion list. 21803 existingChildren.forEach(function (child) { 21804 return deleteChild(returnFiber, child); 21805 }); 21806 } 21807 21808 return resultingFirstChild; 21809 } 21810 21811 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { 21812 // This is the same implementation as reconcileChildrenArray(), 21813 // but using the iterator instead. 21814 var iteratorFn = getIteratorFn(newChildrenIterable); 21815 21816 if (!(typeof iteratorFn === 'function')) { 21817 { 21818 throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); 21819 } 21820 } 21821 21822 { 21823 // We don't support rendering Generators because it's a mutation. 21824 // See https://github.com/facebook/react/issues/12995 21825 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag 21826 newChildrenIterable[Symbol.toStringTag] === 'Generator') { 21827 if (!didWarnAboutGenerators) { 21828 error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); 21829 } 21830 21831 didWarnAboutGenerators = true; 21832 } // Warn about using Maps as children 21833 21834 21835 if (newChildrenIterable.entries === iteratorFn) { 21836 if (!didWarnAboutMaps) { 21837 error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.'); 21838 } 21839 21840 didWarnAboutMaps = true; 21841 } // First, validate keys. 21842 // We'll get a different iterator later for the main pass. 21843 21844 21845 var _newChildren = iteratorFn.call(newChildrenIterable); 21846 21847 if (_newChildren) { 21848 var knownKeys = null; 21849 21850 var _step = _newChildren.next(); 21851 21852 for (; !_step.done; _step = _newChildren.next()) { 21853 var child = _step.value; 21854 knownKeys = warnOnInvalidKey(child, knownKeys); 21855 } 21856 } 21857 } 21858 21859 var newChildren = iteratorFn.call(newChildrenIterable); 21860 21861 if (!(newChildren != null)) { 21862 { 21863 throw Error( "An iterable object provided no iterator." ); 21864 } 21865 } 21866 21867 var resultingFirstChild = null; 21868 var previousNewFiber = null; 21869 var oldFiber = currentFirstChild; 21870 var lastPlacedIndex = 0; 21871 var newIdx = 0; 21872 var nextOldFiber = null; 21873 var step = newChildren.next(); 21874 21875 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 21876 if (oldFiber.index > newIdx) { 21877 nextOldFiber = oldFiber; 21878 oldFiber = null; 21879 } else { 21880 nextOldFiber = oldFiber.sibling; 21881 } 21882 21883 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); 21884 21885 if (newFiber === null) { 21886 // TODO: This breaks on empty slots like null children. That's 21887 // unfortunate because it triggers the slow path all the time. We need 21888 // a better way to communicate whether this was a miss or null, 21889 // boolean, undefined, etc. 21890 if (oldFiber === null) { 21891 oldFiber = nextOldFiber; 21892 } 21893 21894 break; 21895 } 21896 21897 if (shouldTrackSideEffects) { 21898 if (oldFiber && newFiber.alternate === null) { 21899 // We matched the slot, but we didn't reuse the existing fiber, so we 21900 // need to delete the existing child. 21901 deleteChild(returnFiber, oldFiber); 21902 } 21903 } 21904 21905 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 21906 21907 if (previousNewFiber === null) { 21908 // TODO: Move out of the loop. This only happens for the first run. 21909 resultingFirstChild = newFiber; 21910 } else { 21911 // TODO: Defer siblings if we're not at the right index for this slot. 21912 // I.e. if we had null values before, then we want to defer this 21913 // for each null value. However, we also don't want to call updateSlot 21914 // with the previous one. 21915 previousNewFiber.sibling = newFiber; 21916 } 21917 21918 previousNewFiber = newFiber; 21919 oldFiber = nextOldFiber; 21920 } 21921 21922 if (step.done) { 21923 // We've reached the end of the new children. We can delete the rest. 21924 deleteRemainingChildren(returnFiber, oldFiber); 21925 return resultingFirstChild; 21926 } 21927 21928 if (oldFiber === null) { 21929 // If we don't have any more existing children we can choose a fast path 21930 // since the rest will all be insertions. 21931 for (; !step.done; newIdx++, step = newChildren.next()) { 21932 var _newFiber3 = createChild(returnFiber, step.value, expirationTime); 21933 21934 if (_newFiber3 === null) { 21935 continue; 21936 } 21937 21938 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 21939 21940 if (previousNewFiber === null) { 21941 // TODO: Move out of the loop. This only happens for the first run. 21942 resultingFirstChild = _newFiber3; 21943 } else { 21944 previousNewFiber.sibling = _newFiber3; 21945 } 21946 21947 previousNewFiber = _newFiber3; 21948 } 21949 21950 return resultingFirstChild; 21951 } // Add all children to a key map for quick lookups. 21952 21953 21954 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 21955 21956 for (; !step.done; newIdx++, step = newChildren.next()) { 21957 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); 21958 21959 if (_newFiber4 !== null) { 21960 if (shouldTrackSideEffects) { 21961 if (_newFiber4.alternate !== null) { 21962 // The new fiber is a work in progress, but if there exists a 21963 // current, that means that we reused the fiber. We need to delete 21964 // it from the child list so that we don't add it to the deletion 21965 // list. 21966 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); 21967 } 21968 } 21969 21970 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 21971 21972 if (previousNewFiber === null) { 21973 resultingFirstChild = _newFiber4; 21974 } else { 21975 previousNewFiber.sibling = _newFiber4; 21976 } 21977 21978 previousNewFiber = _newFiber4; 21979 } 21980 } 21981 21982 if (shouldTrackSideEffects) { 21983 // Any existing children that weren't consumed above were deleted. We need 21984 // to add them to the deletion list. 21985 existingChildren.forEach(function (child) { 21986 return deleteChild(returnFiber, child); 21987 }); 21988 } 21989 21990 return resultingFirstChild; 21991 } 21992 21993 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { 21994 // There's no need to check for keys on text nodes since we don't have a 21995 // way to define them. 21996 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 21997 // We already have an existing node so let's just update it and delete 21998 // the rest. 21999 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 22000 var existing = useFiber(currentFirstChild, textContent); 22001 existing.return = returnFiber; 22002 return existing; 22003 } // The existing first child is not a text node so we need to create one 22004 // and delete the existing ones. 22005 22006 22007 deleteRemainingChildren(returnFiber, currentFirstChild); 22008 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 22009 created.return = returnFiber; 22010 return created; 22011 } 22012 22013 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { 22014 var key = element.key; 22015 var child = currentFirstChild; 22016 22017 while (child !== null) { 22018 // TODO: If key === null and child.key === null, then this only applies to 22019 // the first item in the list. 22020 if (child.key === key) { 22021 switch (child.tag) { 22022 case Fragment: 22023 { 22024 if (element.type === REACT_FRAGMENT_TYPE) { 22025 deleteRemainingChildren(returnFiber, child.sibling); 22026 var existing = useFiber(child, element.props.children); 22027 existing.return = returnFiber; 22028 22029 { 22030 existing._debugSource = element._source; 22031 existing._debugOwner = element._owner; 22032 } 22033 22034 return existing; 22035 } 22036 22037 break; 22038 } 22039 22040 case Block: 22041 22042 // We intentionally fallthrough here if enableBlocksAPI is not on. 22043 // eslint-disable-next-lined no-fallthrough 22044 22045 default: 22046 { 22047 if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 22048 isCompatibleFamilyForHotReloading(child, element) )) { 22049 deleteRemainingChildren(returnFiber, child.sibling); 22050 22051 var _existing3 = useFiber(child, element.props); 22052 22053 _existing3.ref = coerceRef(returnFiber, child, element); 22054 _existing3.return = returnFiber; 22055 22056 { 22057 _existing3._debugSource = element._source; 22058 _existing3._debugOwner = element._owner; 22059 } 22060 22061 return _existing3; 22062 } 22063 22064 break; 22065 } 22066 } // Didn't match. 22067 22068 22069 deleteRemainingChildren(returnFiber, child); 22070 break; 22071 } else { 22072 deleteChild(returnFiber, child); 22073 } 22074 22075 child = child.sibling; 22076 } 22077 22078 if (element.type === REACT_FRAGMENT_TYPE) { 22079 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key); 22080 created.return = returnFiber; 22081 return created; 22082 } else { 22083 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime); 22084 22085 _created4.ref = coerceRef(returnFiber, currentFirstChild, element); 22086 _created4.return = returnFiber; 22087 return _created4; 22088 } 22089 } 22090 22091 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { 22092 var key = portal.key; 22093 var child = currentFirstChild; 22094 22095 while (child !== null) { 22096 // TODO: If key === null and child.key === null, then this only applies to 22097 // the first item in the list. 22098 if (child.key === key) { 22099 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 22100 deleteRemainingChildren(returnFiber, child.sibling); 22101 var existing = useFiber(child, portal.children || []); 22102 existing.return = returnFiber; 22103 return existing; 22104 } else { 22105 deleteRemainingChildren(returnFiber, child); 22106 break; 22107 } 22108 } else { 22109 deleteChild(returnFiber, child); 22110 } 22111 22112 child = child.sibling; 22113 } 22114 22115 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 22116 created.return = returnFiber; 22117 return created; 22118 } // This API will tag the children with the side-effect of the reconciliation 22119 // itself. They will be added to the side-effect list as we pass through the 22120 // children and the parent. 22121 22122 22123 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { 22124 // This function is not recursive. 22125 // If the top level item is an array, we treat it as a set of children, 22126 // not as a fragment. Nested arrays on the other hand will be treated as 22127 // fragment nodes. Recursion happens at the normal flow. 22128 // Handle top level unkeyed fragments as if they were arrays. 22129 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 22130 // We treat the ambiguous cases above the same. 22131 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; 22132 22133 if (isUnkeyedTopLevelFragment) { 22134 newChild = newChild.props.children; 22135 } // Handle object types 22136 22137 22138 var isObject = typeof newChild === 'object' && newChild !== null; 22139 22140 if (isObject) { 22141 switch (newChild.$$typeof) { 22142 case REACT_ELEMENT_TYPE: 22143 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); 22144 22145 case REACT_PORTAL_TYPE: 22146 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); 22147 } 22148 } 22149 22150 if (typeof newChild === 'string' || typeof newChild === 'number') { 22151 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); 22152 } 22153 22154 if (isArray$1(newChild)) { 22155 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); 22156 } 22157 22158 if (getIteratorFn(newChild)) { 22159 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); 22160 } 22161 22162 if (isObject) { 22163 throwOnInvalidObjectType(returnFiber, newChild); 22164 } 22165 22166 { 22167 if (typeof newChild === 'function') { 22168 warnOnFunctionType(); 22169 } 22170 } 22171 22172 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { 22173 // If the new child is undefined, and the return fiber is a composite 22174 // component, throw an error. If Fiber return types are disabled, 22175 // we already threw above. 22176 switch (returnFiber.tag) { 22177 case ClassComponent: 22178 { 22179 { 22180 var instance = returnFiber.stateNode; 22181 22182 if (instance.render._isMockFunction) { 22183 // We allow auto-mocks to proceed as if they're returning null. 22184 break; 22185 } 22186 } 22187 } 22188 // Intentionally fall through to the next case, which handles both 22189 // functions and classes 22190 // eslint-disable-next-lined no-fallthrough 22191 22192 case FunctionComponent: 22193 { 22194 var Component = returnFiber.type; 22195 22196 { 22197 { 22198 throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); 22199 } 22200 } 22201 } 22202 } 22203 } // Remaining cases are all treated as empty. 22204 22205 22206 return deleteRemainingChildren(returnFiber, currentFirstChild); 22207 } 22208 22209 return reconcileChildFibers; 22210} 22211 22212var reconcileChildFibers = ChildReconciler(true); 22213var mountChildFibers = ChildReconciler(false); 22214function cloneChildFibers(current, workInProgress) { 22215 if (!(current === null || workInProgress.child === current.child)) { 22216 { 22217 throw Error( "Resuming work not yet implemented." ); 22218 } 22219 } 22220 22221 if (workInProgress.child === null) { 22222 return; 22223 } 22224 22225 var currentChild = workInProgress.child; 22226 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); 22227 workInProgress.child = newChild; 22228 newChild.return = workInProgress; 22229 22230 while (currentChild.sibling !== null) { 22231 currentChild = currentChild.sibling; 22232 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); 22233 newChild.return = workInProgress; 22234 } 22235 22236 newChild.sibling = null; 22237} // Reset a workInProgress child set to prepare it for a second pass. 22238 22239function resetChildFibers(workInProgress, renderExpirationTime) { 22240 var child = workInProgress.child; 22241 22242 while (child !== null) { 22243 resetWorkInProgress(child, renderExpirationTime); 22244 child = child.sibling; 22245 } 22246} 22247 22248var NO_CONTEXT = {}; 22249var contextStackCursor$1 = createCursor(NO_CONTEXT); 22250var contextFiberStackCursor = createCursor(NO_CONTEXT); 22251var rootInstanceStackCursor = createCursor(NO_CONTEXT); 22252 22253function requiredContext(c) { 22254 if (!(c !== NO_CONTEXT)) { 22255 { 22256 throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); 22257 } 22258 } 22259 22260 return c; 22261} 22262 22263function getRootHostContainer() { 22264 var rootInstance = requiredContext(rootInstanceStackCursor.current); 22265 return rootInstance; 22266} 22267 22268function pushHostContainer(fiber, nextRootInstance) { 22269 // Push current root instance onto the stack; 22270 // This allows us to reset root when portals are popped. 22271 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. 22272 // This enables us to pop only Fibers that provide unique contexts. 22273 22274 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. 22275 // However, we can't just call getRootHostContext() and push it because 22276 // we'd have a different number of entries on the stack depending on 22277 // whether getRootHostContext() throws somewhere in renderer code or not. 22278 // So we push an empty value first. This lets us safely unwind on errors. 22279 22280 push(contextStackCursor$1, NO_CONTEXT, fiber); 22281 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. 22282 22283 pop(contextStackCursor$1, fiber); 22284 push(contextStackCursor$1, nextRootContext, fiber); 22285} 22286 22287function popHostContainer(fiber) { 22288 pop(contextStackCursor$1, fiber); 22289 pop(contextFiberStackCursor, fiber); 22290 pop(rootInstanceStackCursor, fiber); 22291} 22292 22293function getHostContext() { 22294 var context = requiredContext(contextStackCursor$1.current); 22295 return context; 22296} 22297 22298function pushHostContext(fiber) { 22299 var rootInstance = requiredContext(rootInstanceStackCursor.current); 22300 var context = requiredContext(contextStackCursor$1.current); 22301 var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. 22302 22303 if (context === nextContext) { 22304 return; 22305 } // Track the context and the Fiber that provided it. 22306 // This enables us to pop only Fibers that provide unique contexts. 22307 22308 22309 push(contextFiberStackCursor, fiber, fiber); 22310 push(contextStackCursor$1, nextContext, fiber); 22311} 22312 22313function popHostContext(fiber) { 22314 // Do not pop unless this Fiber provided the current context. 22315 // pushHostContext() only pushes Fibers that provide unique contexts. 22316 if (contextFiberStackCursor.current !== fiber) { 22317 return; 22318 } 22319 22320 pop(contextStackCursor$1, fiber); 22321 pop(contextFiberStackCursor, fiber); 22322} 22323 22324var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is 22325// inherited deeply down the subtree. The upper bits only affect 22326// this immediate suspense boundary and gets reset each new 22327// boundary or suspense list. 22328 22329var SubtreeSuspenseContextMask = 1; // Subtree Flags: 22330// InvisibleParentSuspenseContext indicates that one of our parent Suspense 22331// boundaries is not currently showing visible main content. 22332// Either because it is already showing a fallback or is not mounted at all. 22333// We can use this to determine if it is desirable to trigger a fallback at 22334// the parent. If not, then we might need to trigger undesirable boundaries 22335// and/or suspend the commit to avoid hiding the parent content. 22336 22337var InvisibleParentSuspenseContext = 1; // Shallow Flags: 22338// ForceSuspenseFallback can be used by SuspenseList to force newly added 22339// items into their fallback state during one of the render passes. 22340 22341var ForceSuspenseFallback = 2; 22342var suspenseStackCursor = createCursor(DefaultSuspenseContext); 22343function hasSuspenseContext(parentContext, flag) { 22344 return (parentContext & flag) !== 0; 22345} 22346function setDefaultShallowSuspenseContext(parentContext) { 22347 return parentContext & SubtreeSuspenseContextMask; 22348} 22349function setShallowSuspenseContext(parentContext, shallowContext) { 22350 return parentContext & SubtreeSuspenseContextMask | shallowContext; 22351} 22352function addSubtreeSuspenseContext(parentContext, subtreeContext) { 22353 return parentContext | subtreeContext; 22354} 22355function pushSuspenseContext(fiber, newContext) { 22356 push(suspenseStackCursor, newContext, fiber); 22357} 22358function popSuspenseContext(fiber) { 22359 pop(suspenseStackCursor, fiber); 22360} 22361 22362function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { 22363 // If it was the primary children that just suspended, capture and render the 22364 // fallback. Otherwise, don't capture and bubble to the next boundary. 22365 var nextState = workInProgress.memoizedState; 22366 22367 if (nextState !== null) { 22368 if (nextState.dehydrated !== null) { 22369 // A dehydrated boundary always captures. 22370 return true; 22371 } 22372 22373 return false; 22374 } 22375 22376 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. 22377 22378 if (props.fallback === undefined) { 22379 return false; 22380 } // Regular boundaries always capture. 22381 22382 22383 if (props.unstable_avoidThisFallback !== true) { 22384 return true; 22385 } // If it's a boundary we should avoid, then we prefer to bubble up to the 22386 // parent boundary if it is currently invisible. 22387 22388 22389 if (hasInvisibleParent) { 22390 return false; 22391 } // If the parent is not able to handle it, we must handle it. 22392 22393 22394 return true; 22395} 22396function findFirstSuspended(row) { 22397 var node = row; 22398 22399 while (node !== null) { 22400 if (node.tag === SuspenseComponent) { 22401 var state = node.memoizedState; 22402 22403 if (state !== null) { 22404 var dehydrated = state.dehydrated; 22405 22406 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { 22407 return node; 22408 } 22409 } 22410 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't 22411 // keep track of whether it suspended or not. 22412 node.memoizedProps.revealOrder !== undefined) { 22413 var didSuspend = (node.effectTag & DidCapture) !== NoEffect; 22414 22415 if (didSuspend) { 22416 return node; 22417 } 22418 } else if (node.child !== null) { 22419 node.child.return = node; 22420 node = node.child; 22421 continue; 22422 } 22423 22424 if (node === row) { 22425 return null; 22426 } 22427 22428 while (node.sibling === null) { 22429 if (node.return === null || node.return === row) { 22430 return null; 22431 } 22432 22433 node = node.return; 22434 } 22435 22436 node.sibling.return = node.return; 22437 node = node.sibling; 22438 } 22439 22440 return null; 22441} 22442 22443function createDeprecatedResponderListener(responder, props) { 22444 var eventResponderListener = { 22445 responder: responder, 22446 props: props 22447 }; 22448 22449 { 22450 Object.freeze(eventResponderListener); 22451 } 22452 22453 return eventResponderListener; 22454} 22455 22456var HasEffect = 22457/* */ 224581; // Represents the phase in which the effect (not the clean-up) fires. 22459 22460var Layout = 22461/* */ 224622; 22463var Passive$1 = 22464/* */ 224654; 22466 22467var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, 22468 ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; 22469var didWarnAboutMismatchedHooksForComponent; 22470 22471{ 22472 didWarnAboutMismatchedHooksForComponent = new Set(); 22473} 22474 22475// These are set right before calling the component. 22476var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from 22477// the work-in-progress hook. 22478 22479var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The 22480// current hook list is the list that belongs to the current fiber. The 22481// work-in-progress hook list is a new list that will be added to the 22482// work-in-progress fiber. 22483 22484var currentHook = null; 22485var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This 22486// does not get reset if we do another render pass; only when we're completely 22487// finished evaluating this component. This is an optimization so we know 22488// whether we need to clear render phase updates after a throw. 22489 22490var didScheduleRenderPhaseUpdate = false; 22491var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook 22492 22493var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. 22494// The list stores the order of hooks used during the initial render (mount). 22495// Subsequent renders (updates) reference this list. 22496 22497var hookTypesDev = null; 22498var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore 22499// the dependencies for Hooks that need them (e.g. useEffect or useMemo). 22500// When true, such Hooks will always be "remounted". Only used during hot reload. 22501 22502var ignorePreviousDependencies = false; 22503 22504function mountHookTypesDev() { 22505 { 22506 var hookName = currentHookNameInDev; 22507 22508 if (hookTypesDev === null) { 22509 hookTypesDev = [hookName]; 22510 } else { 22511 hookTypesDev.push(hookName); 22512 } 22513 } 22514} 22515 22516function updateHookTypesDev() { 22517 { 22518 var hookName = currentHookNameInDev; 22519 22520 if (hookTypesDev !== null) { 22521 hookTypesUpdateIndexDev++; 22522 22523 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { 22524 warnOnHookMismatchInDev(hookName); 22525 } 22526 } 22527 } 22528} 22529 22530function checkDepsAreArrayDev(deps) { 22531 { 22532 if (deps !== undefined && deps !== null && !Array.isArray(deps)) { 22533 // Verify deps, but only on mount to avoid extra checks. 22534 // It's unlikely their type would change as usually you define them inline. 22535 error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps); 22536 } 22537 } 22538} 22539 22540function warnOnHookMismatchInDev(currentHookName) { 22541 { 22542 var componentName = getComponentName(currentlyRenderingFiber$1.type); 22543 22544 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { 22545 didWarnAboutMismatchedHooksForComponent.add(componentName); 22546 22547 if (hookTypesDev !== null) { 22548 var table = ''; 22549 var secondColumnStart = 30; 22550 22551 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { 22552 var oldHookName = hookTypesDev[i]; 22553 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; 22554 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up 22555 // lol @ IE not supporting String#repeat 22556 22557 while (row.length < secondColumnStart) { 22558 row += ' '; 22559 } 22560 22561 row += newHookName + '\n'; 22562 table += row; 22563 } 22564 22565 error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table); 22566 } 22567 } 22568 } 22569} 22570 22571function throwInvalidHookError() { 22572 { 22573 { 22574 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); 22575 } 22576 } 22577} 22578 22579function areHookInputsEqual(nextDeps, prevDeps) { 22580 { 22581 if (ignorePreviousDependencies) { 22582 // Only true when this component is being hot reloaded. 22583 return false; 22584 } 22585 } 22586 22587 if (prevDeps === null) { 22588 { 22589 error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); 22590 } 22591 22592 return false; 22593 } 22594 22595 { 22596 // Don't bother comparing lengths in prod because these arrays should be 22597 // passed inline. 22598 if (nextDeps.length !== prevDeps.length) { 22599 error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]"); 22600 } 22601 } 22602 22603 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { 22604 if (objectIs(nextDeps[i], prevDeps[i])) { 22605 continue; 22606 } 22607 22608 return false; 22609 } 22610 22611 return true; 22612} 22613 22614function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderExpirationTime) { 22615 renderExpirationTime = nextRenderExpirationTime; 22616 currentlyRenderingFiber$1 = workInProgress; 22617 22618 { 22619 hookTypesDev = current !== null ? current._debugHookTypes : null; 22620 hookTypesUpdateIndexDev = -1; // Used for hot reloading: 22621 22622 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; 22623 } 22624 22625 workInProgress.memoizedState = null; 22626 workInProgress.updateQueue = null; 22627 workInProgress.expirationTime = NoWork; // The following should have already been reset 22628 // currentHook = null; 22629 // workInProgressHook = null; 22630 // didScheduleRenderPhaseUpdate = false; 22631 // TODO Warn if no hooks are used at all during mount, then some are used during update. 22632 // Currently we will identify the update render as a mount because memoizedState === null. 22633 // This is tricky because it's valid for certain types of components (e.g. React.lazy) 22634 // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. 22635 // Non-stateful hooks (e.g. context) don't get added to memoizedState, 22636 // so memoizedState would be null during updates and mounts. 22637 22638 { 22639 if (current !== null && current.memoizedState !== null) { 22640 ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; 22641 } else if (hookTypesDev !== null) { 22642 // This dispatcher handles an edge case where a component is updating, 22643 // but no stateful hooks have been used. 22644 // We want to match the production code behavior (which will use HooksDispatcherOnMount), 22645 // but with the extra DEV validation to ensure hooks ordering hasn't changed. 22646 // This dispatcher does that. 22647 ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; 22648 } else { 22649 ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; 22650 } 22651 } 22652 22653 var children = Component(props, secondArg); // Check if there was a render phase update 22654 22655 if (workInProgress.expirationTime === renderExpirationTime) { 22656 // Keep rendering in a loop for as long as render phase updates continue to 22657 // be scheduled. Use a counter to prevent infinite loops. 22658 var numberOfReRenders = 0; 22659 22660 do { 22661 workInProgress.expirationTime = NoWork; 22662 22663 if (!(numberOfReRenders < RE_RENDER_LIMIT)) { 22664 { 22665 throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); 22666 } 22667 } 22668 22669 numberOfReRenders += 1; 22670 22671 { 22672 // Even when hot reloading, allow dependencies to stabilize 22673 // after first render to prevent infinite render phase updates. 22674 ignorePreviousDependencies = false; 22675 } // Start over from the beginning of the list 22676 22677 22678 currentHook = null; 22679 workInProgressHook = null; 22680 workInProgress.updateQueue = null; 22681 22682 { 22683 // Also validate hook order for cascading updates. 22684 hookTypesUpdateIndexDev = -1; 22685 } 22686 22687 ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV ; 22688 children = Component(props, secondArg); 22689 } while (workInProgress.expirationTime === renderExpirationTime); 22690 } // We can assume the previous dispatcher is always this one, since we set it 22691 // at the beginning of the render phase and there's no re-entrancy. 22692 22693 22694 ReactCurrentDispatcher.current = ContextOnlyDispatcher; 22695 22696 { 22697 workInProgress._debugHookTypes = hookTypesDev; 22698 } // This check uses currentHook so that it works the same in DEV and prod bundles. 22699 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. 22700 22701 22702 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; 22703 renderExpirationTime = NoWork; 22704 currentlyRenderingFiber$1 = null; 22705 currentHook = null; 22706 workInProgressHook = null; 22707 22708 { 22709 currentHookNameInDev = null; 22710 hookTypesDev = null; 22711 hookTypesUpdateIndexDev = -1; 22712 } 22713 22714 didScheduleRenderPhaseUpdate = false; 22715 22716 if (!!didRenderTooFewHooks) { 22717 { 22718 throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); 22719 } 22720 } 22721 22722 return children; 22723} 22724function bailoutHooks(current, workInProgress, expirationTime) { 22725 workInProgress.updateQueue = current.updateQueue; 22726 workInProgress.effectTag &= ~(Passive | Update); 22727 22728 if (current.expirationTime <= expirationTime) { 22729 current.expirationTime = NoWork; 22730 } 22731} 22732function resetHooksAfterThrow() { 22733 // We can assume the previous dispatcher is always this one, since we set it 22734 // at the beginning of the render phase and there's no re-entrancy. 22735 ReactCurrentDispatcher.current = ContextOnlyDispatcher; 22736 22737 if (didScheduleRenderPhaseUpdate) { 22738 // There were render phase updates. These are only valid for this render 22739 // phase, which we are now aborting. Remove the updates from the queues so 22740 // they do not persist to the next render. Do not remove updates from hooks 22741 // that weren't processed. 22742 // 22743 // Only reset the updates from the queue if it has a clone. If it does 22744 // not have a clone, that means it wasn't processed, and the updates were 22745 // scheduled before we entered the render phase. 22746 var hook = currentlyRenderingFiber$1.memoizedState; 22747 22748 while (hook !== null) { 22749 var queue = hook.queue; 22750 22751 if (queue !== null) { 22752 queue.pending = null; 22753 } 22754 22755 hook = hook.next; 22756 } 22757 } 22758 22759 renderExpirationTime = NoWork; 22760 currentlyRenderingFiber$1 = null; 22761 currentHook = null; 22762 workInProgressHook = null; 22763 22764 { 22765 hookTypesDev = null; 22766 hookTypesUpdateIndexDev = -1; 22767 currentHookNameInDev = null; 22768 } 22769 22770 didScheduleRenderPhaseUpdate = false; 22771} 22772 22773function mountWorkInProgressHook() { 22774 var hook = { 22775 memoizedState: null, 22776 baseState: null, 22777 baseQueue: null, 22778 queue: null, 22779 next: null 22780 }; 22781 22782 if (workInProgressHook === null) { 22783 // This is the first hook in the list 22784 currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; 22785 } else { 22786 // Append to the end of the list 22787 workInProgressHook = workInProgressHook.next = hook; 22788 } 22789 22790 return workInProgressHook; 22791} 22792 22793function updateWorkInProgressHook() { 22794 // This function is used both for updates and for re-renders triggered by a 22795 // render phase update. It assumes there is either a current hook we can 22796 // clone, or a work-in-progress hook from a previous render pass that we can 22797 // use as a base. When we reach the end of the base list, we must switch to 22798 // the dispatcher used for mounts. 22799 var nextCurrentHook; 22800 22801 if (currentHook === null) { 22802 var current = currentlyRenderingFiber$1.alternate; 22803 22804 if (current !== null) { 22805 nextCurrentHook = current.memoizedState; 22806 } else { 22807 nextCurrentHook = null; 22808 } 22809 } else { 22810 nextCurrentHook = currentHook.next; 22811 } 22812 22813 var nextWorkInProgressHook; 22814 22815 if (workInProgressHook === null) { 22816 nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; 22817 } else { 22818 nextWorkInProgressHook = workInProgressHook.next; 22819 } 22820 22821 if (nextWorkInProgressHook !== null) { 22822 // There's already a work-in-progress. Reuse it. 22823 workInProgressHook = nextWorkInProgressHook; 22824 nextWorkInProgressHook = workInProgressHook.next; 22825 currentHook = nextCurrentHook; 22826 } else { 22827 // Clone from the current hook. 22828 if (!(nextCurrentHook !== null)) { 22829 { 22830 throw Error( "Rendered more hooks than during the previous render." ); 22831 } 22832 } 22833 22834 currentHook = nextCurrentHook; 22835 var newHook = { 22836 memoizedState: currentHook.memoizedState, 22837 baseState: currentHook.baseState, 22838 baseQueue: currentHook.baseQueue, 22839 queue: currentHook.queue, 22840 next: null 22841 }; 22842 22843 if (workInProgressHook === null) { 22844 // This is the first hook in the list. 22845 currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; 22846 } else { 22847 // Append to the end of the list. 22848 workInProgressHook = workInProgressHook.next = newHook; 22849 } 22850 } 22851 22852 return workInProgressHook; 22853} 22854 22855function createFunctionComponentUpdateQueue() { 22856 return { 22857 lastEffect: null 22858 }; 22859} 22860 22861function basicStateReducer(state, action) { 22862 // $FlowFixMe: Flow doesn't like mixed types 22863 return typeof action === 'function' ? action(state) : action; 22864} 22865 22866function mountReducer(reducer, initialArg, init) { 22867 var hook = mountWorkInProgressHook(); 22868 var initialState; 22869 22870 if (init !== undefined) { 22871 initialState = init(initialArg); 22872 } else { 22873 initialState = initialArg; 22874 } 22875 22876 hook.memoizedState = hook.baseState = initialState; 22877 var queue = hook.queue = { 22878 pending: null, 22879 dispatch: null, 22880 lastRenderedReducer: reducer, 22881 lastRenderedState: initialState 22882 }; 22883 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 22884 return [hook.memoizedState, dispatch]; 22885} 22886 22887function updateReducer(reducer, initialArg, init) { 22888 var hook = updateWorkInProgressHook(); 22889 var queue = hook.queue; 22890 22891 if (!(queue !== null)) { 22892 { 22893 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 22894 } 22895 } 22896 22897 queue.lastRenderedReducer = reducer; 22898 var current = currentHook; // The last rebase update that is NOT part of the base state. 22899 22900 var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. 22901 22902 var pendingQueue = queue.pending; 22903 22904 if (pendingQueue !== null) { 22905 // We have new updates that haven't been processed yet. 22906 // We'll add them to the base queue. 22907 if (baseQueue !== null) { 22908 // Merge the pending queue and the base queue. 22909 var baseFirst = baseQueue.next; 22910 var pendingFirst = pendingQueue.next; 22911 baseQueue.next = pendingFirst; 22912 pendingQueue.next = baseFirst; 22913 } 22914 22915 current.baseQueue = baseQueue = pendingQueue; 22916 queue.pending = null; 22917 } 22918 22919 if (baseQueue !== null) { 22920 // We have a queue to process. 22921 var first = baseQueue.next; 22922 var newState = current.baseState; 22923 var newBaseState = null; 22924 var newBaseQueueFirst = null; 22925 var newBaseQueueLast = null; 22926 var update = first; 22927 22928 do { 22929 var updateExpirationTime = update.expirationTime; 22930 22931 if (updateExpirationTime < renderExpirationTime) { 22932 // Priority is insufficient. Skip this update. If this is the first 22933 // skipped update, the previous update/state is the new base 22934 // update/state. 22935 var clone = { 22936 expirationTime: update.expirationTime, 22937 suspenseConfig: update.suspenseConfig, 22938 action: update.action, 22939 eagerReducer: update.eagerReducer, 22940 eagerState: update.eagerState, 22941 next: null 22942 }; 22943 22944 if (newBaseQueueLast === null) { 22945 newBaseQueueFirst = newBaseQueueLast = clone; 22946 newBaseState = newState; 22947 } else { 22948 newBaseQueueLast = newBaseQueueLast.next = clone; 22949 } // Update the remaining priority in the queue. 22950 22951 22952 if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { 22953 currentlyRenderingFiber$1.expirationTime = updateExpirationTime; 22954 markUnprocessedUpdateTime(updateExpirationTime); 22955 } 22956 } else { 22957 // This update does have sufficient priority. 22958 if (newBaseQueueLast !== null) { 22959 var _clone = { 22960 expirationTime: Sync, 22961 // This update is going to be committed so we never want uncommit it. 22962 suspenseConfig: update.suspenseConfig, 22963 action: update.action, 22964 eagerReducer: update.eagerReducer, 22965 eagerState: update.eagerState, 22966 next: null 22967 }; 22968 newBaseQueueLast = newBaseQueueLast.next = _clone; 22969 } // Mark the event time of this update as relevant to this render pass. 22970 // TODO: This should ideally use the true event time of this update rather than 22971 // its priority which is a derived and not reverseable value. 22972 // TODO: We should skip this update if it was already committed but currently 22973 // we have no way of detecting the difference between a committed and suspended 22974 // update here. 22975 22976 22977 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. 22978 22979 if (update.eagerReducer === reducer) { 22980 // If this update was processed eagerly, and its reducer matches the 22981 // current reducer, we can use the eagerly computed state. 22982 newState = update.eagerState; 22983 } else { 22984 var action = update.action; 22985 newState = reducer(newState, action); 22986 } 22987 } 22988 22989 update = update.next; 22990 } while (update !== null && update !== first); 22991 22992 if (newBaseQueueLast === null) { 22993 newBaseState = newState; 22994 } else { 22995 newBaseQueueLast.next = newBaseQueueFirst; 22996 } // Mark that the fiber performed work, but only if the new state is 22997 // different from the current state. 22998 22999 23000 if (!objectIs(newState, hook.memoizedState)) { 23001 markWorkInProgressReceivedUpdate(); 23002 } 23003 23004 hook.memoizedState = newState; 23005 hook.baseState = newBaseState; 23006 hook.baseQueue = newBaseQueueLast; 23007 queue.lastRenderedState = newState; 23008 } 23009 23010 var dispatch = queue.dispatch; 23011 return [hook.memoizedState, dispatch]; 23012} 23013 23014function rerenderReducer(reducer, initialArg, init) { 23015 var hook = updateWorkInProgressHook(); 23016 var queue = hook.queue; 23017 23018 if (!(queue !== null)) { 23019 { 23020 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 23021 } 23022 } 23023 23024 queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous 23025 // work-in-progress hook. 23026 23027 var dispatch = queue.dispatch; 23028 var lastRenderPhaseUpdate = queue.pending; 23029 var newState = hook.memoizedState; 23030 23031 if (lastRenderPhaseUpdate !== null) { 23032 // The queue doesn't persist past this render pass. 23033 queue.pending = null; 23034 var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; 23035 var update = firstRenderPhaseUpdate; 23036 23037 do { 23038 // Process this render phase update. We don't have to check the 23039 // priority because it will always be the same as the current 23040 // render's. 23041 var action = update.action; 23042 newState = reducer(newState, action); 23043 update = update.next; 23044 } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is 23045 // different from the current state. 23046 23047 23048 if (!objectIs(newState, hook.memoizedState)) { 23049 markWorkInProgressReceivedUpdate(); 23050 } 23051 23052 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to 23053 // the base state unless the queue is empty. 23054 // TODO: Not sure if this is the desired semantics, but it's what we 23055 // do for gDSFP. I can't remember why. 23056 23057 if (hook.baseQueue === null) { 23058 hook.baseState = newState; 23059 } 23060 23061 queue.lastRenderedState = newState; 23062 } 23063 23064 return [newState, dispatch]; 23065} 23066 23067function mountState(initialState) { 23068 var hook = mountWorkInProgressHook(); 23069 23070 if (typeof initialState === 'function') { 23071 // $FlowFixMe: Flow doesn't like mixed types 23072 initialState = initialState(); 23073 } 23074 23075 hook.memoizedState = hook.baseState = initialState; 23076 var queue = hook.queue = { 23077 pending: null, 23078 dispatch: null, 23079 lastRenderedReducer: basicStateReducer, 23080 lastRenderedState: initialState 23081 }; 23082 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 23083 return [hook.memoizedState, dispatch]; 23084} 23085 23086function updateState(initialState) { 23087 return updateReducer(basicStateReducer); 23088} 23089 23090function rerenderState(initialState) { 23091 return rerenderReducer(basicStateReducer); 23092} 23093 23094function pushEffect(tag, create, destroy, deps) { 23095 var effect = { 23096 tag: tag, 23097 create: create, 23098 destroy: destroy, 23099 deps: deps, 23100 // Circular 23101 next: null 23102 }; 23103 var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; 23104 23105 if (componentUpdateQueue === null) { 23106 componentUpdateQueue = createFunctionComponentUpdateQueue(); 23107 currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; 23108 componentUpdateQueue.lastEffect = effect.next = effect; 23109 } else { 23110 var lastEffect = componentUpdateQueue.lastEffect; 23111 23112 if (lastEffect === null) { 23113 componentUpdateQueue.lastEffect = effect.next = effect; 23114 } else { 23115 var firstEffect = lastEffect.next; 23116 lastEffect.next = effect; 23117 effect.next = firstEffect; 23118 componentUpdateQueue.lastEffect = effect; 23119 } 23120 } 23121 23122 return effect; 23123} 23124 23125function mountRef(initialValue) { 23126 var hook = mountWorkInProgressHook(); 23127 var ref = { 23128 current: initialValue 23129 }; 23130 23131 { 23132 Object.seal(ref); 23133 } 23134 23135 hook.memoizedState = ref; 23136 return ref; 23137} 23138 23139function updateRef(initialValue) { 23140 var hook = updateWorkInProgressHook(); 23141 return hook.memoizedState; 23142} 23143 23144function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { 23145 var hook = mountWorkInProgressHook(); 23146 var nextDeps = deps === undefined ? null : deps; 23147 currentlyRenderingFiber$1.effectTag |= fiberEffectTag; 23148 hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, undefined, nextDeps); 23149} 23150 23151function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { 23152 var hook = updateWorkInProgressHook(); 23153 var nextDeps = deps === undefined ? null : deps; 23154 var destroy = undefined; 23155 23156 if (currentHook !== null) { 23157 var prevEffect = currentHook.memoizedState; 23158 destroy = prevEffect.destroy; 23159 23160 if (nextDeps !== null) { 23161 var prevDeps = prevEffect.deps; 23162 23163 if (areHookInputsEqual(nextDeps, prevDeps)) { 23164 pushEffect(hookEffectTag, create, destroy, nextDeps); 23165 return; 23166 } 23167 } 23168 } 23169 23170 currentlyRenderingFiber$1.effectTag |= fiberEffectTag; 23171 hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, destroy, nextDeps); 23172} 23173 23174function mountEffect(create, deps) { 23175 { 23176 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 23177 if ('undefined' !== typeof jest) { 23178 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 23179 } 23180 } 23181 23182 return mountEffectImpl(Update | Passive, Passive$1, create, deps); 23183} 23184 23185function updateEffect(create, deps) { 23186 { 23187 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 23188 if ('undefined' !== typeof jest) { 23189 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 23190 } 23191 } 23192 23193 return updateEffectImpl(Update | Passive, Passive$1, create, deps); 23194} 23195 23196function mountLayoutEffect(create, deps) { 23197 return mountEffectImpl(Update, Layout, create, deps); 23198} 23199 23200function updateLayoutEffect(create, deps) { 23201 return updateEffectImpl(Update, Layout, create, deps); 23202} 23203 23204function imperativeHandleEffect(create, ref) { 23205 if (typeof ref === 'function') { 23206 var refCallback = ref; 23207 23208 var _inst = create(); 23209 23210 refCallback(_inst); 23211 return function () { 23212 refCallback(null); 23213 }; 23214 } else if (ref !== null && ref !== undefined) { 23215 var refObject = ref; 23216 23217 { 23218 if (!refObject.hasOwnProperty('current')) { 23219 error('Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}'); 23220 } 23221 } 23222 23223 var _inst2 = create(); 23224 23225 refObject.current = _inst2; 23226 return function () { 23227 refObject.current = null; 23228 }; 23229 } 23230} 23231 23232function mountImperativeHandle(ref, create, deps) { 23233 { 23234 if (typeof create !== 'function') { 23235 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 23236 } 23237 } // TODO: If deps are provided, should we skip comparing the ref itself? 23238 23239 23240 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 23241 return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 23242} 23243 23244function updateImperativeHandle(ref, create, deps) { 23245 { 23246 if (typeof create !== 'function') { 23247 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 23248 } 23249 } // TODO: If deps are provided, should we skip comparing the ref itself? 23250 23251 23252 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 23253 return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 23254} 23255 23256function mountDebugValue(value, formatterFn) {// This hook is normally a no-op. 23257 // The react-debug-hooks package injects its own implementation 23258 // so that e.g. DevTools can display custom hook values. 23259} 23260 23261var updateDebugValue = mountDebugValue; 23262 23263function mountCallback(callback, deps) { 23264 var hook = mountWorkInProgressHook(); 23265 var nextDeps = deps === undefined ? null : deps; 23266 hook.memoizedState = [callback, nextDeps]; 23267 return callback; 23268} 23269 23270function updateCallback(callback, deps) { 23271 var hook = updateWorkInProgressHook(); 23272 var nextDeps = deps === undefined ? null : deps; 23273 var prevState = hook.memoizedState; 23274 23275 if (prevState !== null) { 23276 if (nextDeps !== null) { 23277 var prevDeps = prevState[1]; 23278 23279 if (areHookInputsEqual(nextDeps, prevDeps)) { 23280 return prevState[0]; 23281 } 23282 } 23283 } 23284 23285 hook.memoizedState = [callback, nextDeps]; 23286 return callback; 23287} 23288 23289function mountMemo(nextCreate, deps) { 23290 var hook = mountWorkInProgressHook(); 23291 var nextDeps = deps === undefined ? null : deps; 23292 var nextValue = nextCreate(); 23293 hook.memoizedState = [nextValue, nextDeps]; 23294 return nextValue; 23295} 23296 23297function updateMemo(nextCreate, deps) { 23298 var hook = updateWorkInProgressHook(); 23299 var nextDeps = deps === undefined ? null : deps; 23300 var prevState = hook.memoizedState; 23301 23302 if (prevState !== null) { 23303 // Assume these are defined. If they're not, areHookInputsEqual will warn. 23304 if (nextDeps !== null) { 23305 var prevDeps = prevState[1]; 23306 23307 if (areHookInputsEqual(nextDeps, prevDeps)) { 23308 return prevState[0]; 23309 } 23310 } 23311 } 23312 23313 var nextValue = nextCreate(); 23314 hook.memoizedState = [nextValue, nextDeps]; 23315 return nextValue; 23316} 23317 23318function mountDeferredValue(value, config) { 23319 var _mountState = mountState(value), 23320 prevValue = _mountState[0], 23321 setValue = _mountState[1]; 23322 23323 mountEffect(function () { 23324 var previousConfig = ReactCurrentBatchConfig$1.suspense; 23325 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 23326 23327 try { 23328 setValue(value); 23329 } finally { 23330 ReactCurrentBatchConfig$1.suspense = previousConfig; 23331 } 23332 }, [value, config]); 23333 return prevValue; 23334} 23335 23336function updateDeferredValue(value, config) { 23337 var _updateState = updateState(), 23338 prevValue = _updateState[0], 23339 setValue = _updateState[1]; 23340 23341 updateEffect(function () { 23342 var previousConfig = ReactCurrentBatchConfig$1.suspense; 23343 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 23344 23345 try { 23346 setValue(value); 23347 } finally { 23348 ReactCurrentBatchConfig$1.suspense = previousConfig; 23349 } 23350 }, [value, config]); 23351 return prevValue; 23352} 23353 23354function rerenderDeferredValue(value, config) { 23355 var _rerenderState = rerenderState(), 23356 prevValue = _rerenderState[0], 23357 setValue = _rerenderState[1]; 23358 23359 updateEffect(function () { 23360 var previousConfig = ReactCurrentBatchConfig$1.suspense; 23361 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 23362 23363 try { 23364 setValue(value); 23365 } finally { 23366 ReactCurrentBatchConfig$1.suspense = previousConfig; 23367 } 23368 }, [value, config]); 23369 return prevValue; 23370} 23371 23372function startTransition(setPending, config, callback) { 23373 var priorityLevel = getCurrentPriorityLevel(); 23374 runWithPriority$1(priorityLevel < UserBlockingPriority$1 ? UserBlockingPriority$1 : priorityLevel, function () { 23375 setPending(true); 23376 }); 23377 runWithPriority$1(priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function () { 23378 var previousConfig = ReactCurrentBatchConfig$1.suspense; 23379 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 23380 23381 try { 23382 setPending(false); 23383 callback(); 23384 } finally { 23385 ReactCurrentBatchConfig$1.suspense = previousConfig; 23386 } 23387 }); 23388} 23389 23390function mountTransition(config) { 23391 var _mountState2 = mountState(false), 23392 isPending = _mountState2[0], 23393 setPending = _mountState2[1]; 23394 23395 var start = mountCallback(startTransition.bind(null, setPending, config), [setPending, config]); 23396 return [start, isPending]; 23397} 23398 23399function updateTransition(config) { 23400 var _updateState2 = updateState(), 23401 isPending = _updateState2[0], 23402 setPending = _updateState2[1]; 23403 23404 var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]); 23405 return [start, isPending]; 23406} 23407 23408function rerenderTransition(config) { 23409 var _rerenderState2 = rerenderState(), 23410 isPending = _rerenderState2[0], 23411 setPending = _rerenderState2[1]; 23412 23413 var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]); 23414 return [start, isPending]; 23415} 23416 23417function dispatchAction(fiber, queue, action) { 23418 { 23419 if (typeof arguments[3] === 'function') { 23420 error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().'); 23421 } 23422 } 23423 23424 var currentTime = requestCurrentTimeForUpdate(); 23425 var suspenseConfig = requestCurrentSuspenseConfig(); 23426 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 23427 var update = { 23428 expirationTime: expirationTime, 23429 suspenseConfig: suspenseConfig, 23430 action: action, 23431 eagerReducer: null, 23432 eagerState: null, 23433 next: null 23434 }; 23435 23436 { 23437 update.priority = getCurrentPriorityLevel(); 23438 } // Append the update to the end of the list. 23439 23440 23441 var pending = queue.pending; 23442 23443 if (pending === null) { 23444 // This is the first update. Create a circular list. 23445 update.next = update; 23446 } else { 23447 update.next = pending.next; 23448 pending.next = update; 23449 } 23450 23451 queue.pending = update; 23452 var alternate = fiber.alternate; 23453 23454 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { 23455 // This is a render phase update. Stash it in a lazily-created map of 23456 // queue -> linked list of updates. After this render pass, we'll restart 23457 // and apply the stashed updates on top of the work-in-progress hook. 23458 didScheduleRenderPhaseUpdate = true; 23459 update.expirationTime = renderExpirationTime; 23460 currentlyRenderingFiber$1.expirationTime = renderExpirationTime; 23461 } else { 23462 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) { 23463 // The queue is currently empty, which means we can eagerly compute the 23464 // next state before entering the render phase. If the new state is the 23465 // same as the current state, we may be able to bail out entirely. 23466 var lastRenderedReducer = queue.lastRenderedReducer; 23467 23468 if (lastRenderedReducer !== null) { 23469 var prevDispatcher; 23470 23471 { 23472 prevDispatcher = ReactCurrentDispatcher.current; 23473 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 23474 } 23475 23476 try { 23477 var currentState = queue.lastRenderedState; 23478 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute 23479 // it, on the update object. If the reducer hasn't changed by the 23480 // time we enter the render phase, then the eager state can be used 23481 // without calling the reducer again. 23482 23483 update.eagerReducer = lastRenderedReducer; 23484 update.eagerState = eagerState; 23485 23486 if (objectIs(eagerState, currentState)) { 23487 // Fast path. We can bail out without scheduling React to re-render. 23488 // It's still possible that we'll need to rebase this update later, 23489 // if the component re-renders for a different reason and by that 23490 // time the reducer has changed. 23491 return; 23492 } 23493 } catch (error) {// Suppress the error. It will throw again in the render phase. 23494 } finally { 23495 { 23496 ReactCurrentDispatcher.current = prevDispatcher; 23497 } 23498 } 23499 } 23500 } 23501 23502 { 23503 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 23504 if ('undefined' !== typeof jest) { 23505 warnIfNotScopedWithMatchingAct(fiber); 23506 warnIfNotCurrentlyActingUpdatesInDev(fiber); 23507 } 23508 } 23509 23510 scheduleWork(fiber, expirationTime); 23511 } 23512} 23513 23514var ContextOnlyDispatcher = { 23515 readContext: readContext, 23516 useCallback: throwInvalidHookError, 23517 useContext: throwInvalidHookError, 23518 useEffect: throwInvalidHookError, 23519 useImperativeHandle: throwInvalidHookError, 23520 useLayoutEffect: throwInvalidHookError, 23521 useMemo: throwInvalidHookError, 23522 useReducer: throwInvalidHookError, 23523 useRef: throwInvalidHookError, 23524 useState: throwInvalidHookError, 23525 useDebugValue: throwInvalidHookError, 23526 useResponder: throwInvalidHookError, 23527 useDeferredValue: throwInvalidHookError, 23528 useTransition: throwInvalidHookError 23529}; 23530var HooksDispatcherOnMountInDEV = null; 23531var HooksDispatcherOnMountWithHookTypesInDEV = null; 23532var HooksDispatcherOnUpdateInDEV = null; 23533var HooksDispatcherOnRerenderInDEV = null; 23534var InvalidNestedHooksDispatcherOnMountInDEV = null; 23535var InvalidNestedHooksDispatcherOnUpdateInDEV = null; 23536var InvalidNestedHooksDispatcherOnRerenderInDEV = null; 23537 23538{ 23539 var warnInvalidContextAccess = function () { 23540 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 23541 }; 23542 23543 var warnInvalidHookAccess = function () { 23544 error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks'); 23545 }; 23546 23547 HooksDispatcherOnMountInDEV = { 23548 readContext: function (context, observedBits) { 23549 return readContext(context, observedBits); 23550 }, 23551 useCallback: function (callback, deps) { 23552 currentHookNameInDev = 'useCallback'; 23553 mountHookTypesDev(); 23554 checkDepsAreArrayDev(deps); 23555 return mountCallback(callback, deps); 23556 }, 23557 useContext: function (context, observedBits) { 23558 currentHookNameInDev = 'useContext'; 23559 mountHookTypesDev(); 23560 return readContext(context, observedBits); 23561 }, 23562 useEffect: function (create, deps) { 23563 currentHookNameInDev = 'useEffect'; 23564 mountHookTypesDev(); 23565 checkDepsAreArrayDev(deps); 23566 return mountEffect(create, deps); 23567 }, 23568 useImperativeHandle: function (ref, create, deps) { 23569 currentHookNameInDev = 'useImperativeHandle'; 23570 mountHookTypesDev(); 23571 checkDepsAreArrayDev(deps); 23572 return mountImperativeHandle(ref, create, deps); 23573 }, 23574 useLayoutEffect: function (create, deps) { 23575 currentHookNameInDev = 'useLayoutEffect'; 23576 mountHookTypesDev(); 23577 checkDepsAreArrayDev(deps); 23578 return mountLayoutEffect(create, deps); 23579 }, 23580 useMemo: function (create, deps) { 23581 currentHookNameInDev = 'useMemo'; 23582 mountHookTypesDev(); 23583 checkDepsAreArrayDev(deps); 23584 var prevDispatcher = ReactCurrentDispatcher.current; 23585 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23586 23587 try { 23588 return mountMemo(create, deps); 23589 } finally { 23590 ReactCurrentDispatcher.current = prevDispatcher; 23591 } 23592 }, 23593 useReducer: function (reducer, initialArg, init) { 23594 currentHookNameInDev = 'useReducer'; 23595 mountHookTypesDev(); 23596 var prevDispatcher = ReactCurrentDispatcher.current; 23597 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23598 23599 try { 23600 return mountReducer(reducer, initialArg, init); 23601 } finally { 23602 ReactCurrentDispatcher.current = prevDispatcher; 23603 } 23604 }, 23605 useRef: function (initialValue) { 23606 currentHookNameInDev = 'useRef'; 23607 mountHookTypesDev(); 23608 return mountRef(initialValue); 23609 }, 23610 useState: function (initialState) { 23611 currentHookNameInDev = 'useState'; 23612 mountHookTypesDev(); 23613 var prevDispatcher = ReactCurrentDispatcher.current; 23614 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23615 23616 try { 23617 return mountState(initialState); 23618 } finally { 23619 ReactCurrentDispatcher.current = prevDispatcher; 23620 } 23621 }, 23622 useDebugValue: function (value, formatterFn) { 23623 currentHookNameInDev = 'useDebugValue'; 23624 mountHookTypesDev(); 23625 return mountDebugValue(); 23626 }, 23627 useResponder: function (responder, props) { 23628 currentHookNameInDev = 'useResponder'; 23629 mountHookTypesDev(); 23630 return createDeprecatedResponderListener(responder, props); 23631 }, 23632 useDeferredValue: function (value, config) { 23633 currentHookNameInDev = 'useDeferredValue'; 23634 mountHookTypesDev(); 23635 return mountDeferredValue(value, config); 23636 }, 23637 useTransition: function (config) { 23638 currentHookNameInDev = 'useTransition'; 23639 mountHookTypesDev(); 23640 return mountTransition(config); 23641 } 23642 }; 23643 HooksDispatcherOnMountWithHookTypesInDEV = { 23644 readContext: function (context, observedBits) { 23645 return readContext(context, observedBits); 23646 }, 23647 useCallback: function (callback, deps) { 23648 currentHookNameInDev = 'useCallback'; 23649 updateHookTypesDev(); 23650 return mountCallback(callback, deps); 23651 }, 23652 useContext: function (context, observedBits) { 23653 currentHookNameInDev = 'useContext'; 23654 updateHookTypesDev(); 23655 return readContext(context, observedBits); 23656 }, 23657 useEffect: function (create, deps) { 23658 currentHookNameInDev = 'useEffect'; 23659 updateHookTypesDev(); 23660 return mountEffect(create, deps); 23661 }, 23662 useImperativeHandle: function (ref, create, deps) { 23663 currentHookNameInDev = 'useImperativeHandle'; 23664 updateHookTypesDev(); 23665 return mountImperativeHandle(ref, create, deps); 23666 }, 23667 useLayoutEffect: function (create, deps) { 23668 currentHookNameInDev = 'useLayoutEffect'; 23669 updateHookTypesDev(); 23670 return mountLayoutEffect(create, deps); 23671 }, 23672 useMemo: function (create, deps) { 23673 currentHookNameInDev = 'useMemo'; 23674 updateHookTypesDev(); 23675 var prevDispatcher = ReactCurrentDispatcher.current; 23676 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23677 23678 try { 23679 return mountMemo(create, deps); 23680 } finally { 23681 ReactCurrentDispatcher.current = prevDispatcher; 23682 } 23683 }, 23684 useReducer: function (reducer, initialArg, init) { 23685 currentHookNameInDev = 'useReducer'; 23686 updateHookTypesDev(); 23687 var prevDispatcher = ReactCurrentDispatcher.current; 23688 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23689 23690 try { 23691 return mountReducer(reducer, initialArg, init); 23692 } finally { 23693 ReactCurrentDispatcher.current = prevDispatcher; 23694 } 23695 }, 23696 useRef: function (initialValue) { 23697 currentHookNameInDev = 'useRef'; 23698 updateHookTypesDev(); 23699 return mountRef(initialValue); 23700 }, 23701 useState: function (initialState) { 23702 currentHookNameInDev = 'useState'; 23703 updateHookTypesDev(); 23704 var prevDispatcher = ReactCurrentDispatcher.current; 23705 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23706 23707 try { 23708 return mountState(initialState); 23709 } finally { 23710 ReactCurrentDispatcher.current = prevDispatcher; 23711 } 23712 }, 23713 useDebugValue: function (value, formatterFn) { 23714 currentHookNameInDev = 'useDebugValue'; 23715 updateHookTypesDev(); 23716 return mountDebugValue(); 23717 }, 23718 useResponder: function (responder, props) { 23719 currentHookNameInDev = 'useResponder'; 23720 updateHookTypesDev(); 23721 return createDeprecatedResponderListener(responder, props); 23722 }, 23723 useDeferredValue: function (value, config) { 23724 currentHookNameInDev = 'useDeferredValue'; 23725 updateHookTypesDev(); 23726 return mountDeferredValue(value, config); 23727 }, 23728 useTransition: function (config) { 23729 currentHookNameInDev = 'useTransition'; 23730 updateHookTypesDev(); 23731 return mountTransition(config); 23732 } 23733 }; 23734 HooksDispatcherOnUpdateInDEV = { 23735 readContext: function (context, observedBits) { 23736 return readContext(context, observedBits); 23737 }, 23738 useCallback: function (callback, deps) { 23739 currentHookNameInDev = 'useCallback'; 23740 updateHookTypesDev(); 23741 return updateCallback(callback, deps); 23742 }, 23743 useContext: function (context, observedBits) { 23744 currentHookNameInDev = 'useContext'; 23745 updateHookTypesDev(); 23746 return readContext(context, observedBits); 23747 }, 23748 useEffect: function (create, deps) { 23749 currentHookNameInDev = 'useEffect'; 23750 updateHookTypesDev(); 23751 return updateEffect(create, deps); 23752 }, 23753 useImperativeHandle: function (ref, create, deps) { 23754 currentHookNameInDev = 'useImperativeHandle'; 23755 updateHookTypesDev(); 23756 return updateImperativeHandle(ref, create, deps); 23757 }, 23758 useLayoutEffect: function (create, deps) { 23759 currentHookNameInDev = 'useLayoutEffect'; 23760 updateHookTypesDev(); 23761 return updateLayoutEffect(create, deps); 23762 }, 23763 useMemo: function (create, deps) { 23764 currentHookNameInDev = 'useMemo'; 23765 updateHookTypesDev(); 23766 var prevDispatcher = ReactCurrentDispatcher.current; 23767 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 23768 23769 try { 23770 return updateMemo(create, deps); 23771 } finally { 23772 ReactCurrentDispatcher.current = prevDispatcher; 23773 } 23774 }, 23775 useReducer: function (reducer, initialArg, init) { 23776 currentHookNameInDev = 'useReducer'; 23777 updateHookTypesDev(); 23778 var prevDispatcher = ReactCurrentDispatcher.current; 23779 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 23780 23781 try { 23782 return updateReducer(reducer, initialArg, init); 23783 } finally { 23784 ReactCurrentDispatcher.current = prevDispatcher; 23785 } 23786 }, 23787 useRef: function (initialValue) { 23788 currentHookNameInDev = 'useRef'; 23789 updateHookTypesDev(); 23790 return updateRef(); 23791 }, 23792 useState: function (initialState) { 23793 currentHookNameInDev = 'useState'; 23794 updateHookTypesDev(); 23795 var prevDispatcher = ReactCurrentDispatcher.current; 23796 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 23797 23798 try { 23799 return updateState(initialState); 23800 } finally { 23801 ReactCurrentDispatcher.current = prevDispatcher; 23802 } 23803 }, 23804 useDebugValue: function (value, formatterFn) { 23805 currentHookNameInDev = 'useDebugValue'; 23806 updateHookTypesDev(); 23807 return updateDebugValue(); 23808 }, 23809 useResponder: function (responder, props) { 23810 currentHookNameInDev = 'useResponder'; 23811 updateHookTypesDev(); 23812 return createDeprecatedResponderListener(responder, props); 23813 }, 23814 useDeferredValue: function (value, config) { 23815 currentHookNameInDev = 'useDeferredValue'; 23816 updateHookTypesDev(); 23817 return updateDeferredValue(value, config); 23818 }, 23819 useTransition: function (config) { 23820 currentHookNameInDev = 'useTransition'; 23821 updateHookTypesDev(); 23822 return updateTransition(config); 23823 } 23824 }; 23825 HooksDispatcherOnRerenderInDEV = { 23826 readContext: function (context, observedBits) { 23827 return readContext(context, observedBits); 23828 }, 23829 useCallback: function (callback, deps) { 23830 currentHookNameInDev = 'useCallback'; 23831 updateHookTypesDev(); 23832 return updateCallback(callback, deps); 23833 }, 23834 useContext: function (context, observedBits) { 23835 currentHookNameInDev = 'useContext'; 23836 updateHookTypesDev(); 23837 return readContext(context, observedBits); 23838 }, 23839 useEffect: function (create, deps) { 23840 currentHookNameInDev = 'useEffect'; 23841 updateHookTypesDev(); 23842 return updateEffect(create, deps); 23843 }, 23844 useImperativeHandle: function (ref, create, deps) { 23845 currentHookNameInDev = 'useImperativeHandle'; 23846 updateHookTypesDev(); 23847 return updateImperativeHandle(ref, create, deps); 23848 }, 23849 useLayoutEffect: function (create, deps) { 23850 currentHookNameInDev = 'useLayoutEffect'; 23851 updateHookTypesDev(); 23852 return updateLayoutEffect(create, deps); 23853 }, 23854 useMemo: function (create, deps) { 23855 currentHookNameInDev = 'useMemo'; 23856 updateHookTypesDev(); 23857 var prevDispatcher = ReactCurrentDispatcher.current; 23858 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 23859 23860 try { 23861 return updateMemo(create, deps); 23862 } finally { 23863 ReactCurrentDispatcher.current = prevDispatcher; 23864 } 23865 }, 23866 useReducer: function (reducer, initialArg, init) { 23867 currentHookNameInDev = 'useReducer'; 23868 updateHookTypesDev(); 23869 var prevDispatcher = ReactCurrentDispatcher.current; 23870 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 23871 23872 try { 23873 return rerenderReducer(reducer, initialArg, init); 23874 } finally { 23875 ReactCurrentDispatcher.current = prevDispatcher; 23876 } 23877 }, 23878 useRef: function (initialValue) { 23879 currentHookNameInDev = 'useRef'; 23880 updateHookTypesDev(); 23881 return updateRef(); 23882 }, 23883 useState: function (initialState) { 23884 currentHookNameInDev = 'useState'; 23885 updateHookTypesDev(); 23886 var prevDispatcher = ReactCurrentDispatcher.current; 23887 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 23888 23889 try { 23890 return rerenderState(initialState); 23891 } finally { 23892 ReactCurrentDispatcher.current = prevDispatcher; 23893 } 23894 }, 23895 useDebugValue: function (value, formatterFn) { 23896 currentHookNameInDev = 'useDebugValue'; 23897 updateHookTypesDev(); 23898 return updateDebugValue(); 23899 }, 23900 useResponder: function (responder, props) { 23901 currentHookNameInDev = 'useResponder'; 23902 updateHookTypesDev(); 23903 return createDeprecatedResponderListener(responder, props); 23904 }, 23905 useDeferredValue: function (value, config) { 23906 currentHookNameInDev = 'useDeferredValue'; 23907 updateHookTypesDev(); 23908 return rerenderDeferredValue(value, config); 23909 }, 23910 useTransition: function (config) { 23911 currentHookNameInDev = 'useTransition'; 23912 updateHookTypesDev(); 23913 return rerenderTransition(config); 23914 } 23915 }; 23916 InvalidNestedHooksDispatcherOnMountInDEV = { 23917 readContext: function (context, observedBits) { 23918 warnInvalidContextAccess(); 23919 return readContext(context, observedBits); 23920 }, 23921 useCallback: function (callback, deps) { 23922 currentHookNameInDev = 'useCallback'; 23923 warnInvalidHookAccess(); 23924 mountHookTypesDev(); 23925 return mountCallback(callback, deps); 23926 }, 23927 useContext: function (context, observedBits) { 23928 currentHookNameInDev = 'useContext'; 23929 warnInvalidHookAccess(); 23930 mountHookTypesDev(); 23931 return readContext(context, observedBits); 23932 }, 23933 useEffect: function (create, deps) { 23934 currentHookNameInDev = 'useEffect'; 23935 warnInvalidHookAccess(); 23936 mountHookTypesDev(); 23937 return mountEffect(create, deps); 23938 }, 23939 useImperativeHandle: function (ref, create, deps) { 23940 currentHookNameInDev = 'useImperativeHandle'; 23941 warnInvalidHookAccess(); 23942 mountHookTypesDev(); 23943 return mountImperativeHandle(ref, create, deps); 23944 }, 23945 useLayoutEffect: function (create, deps) { 23946 currentHookNameInDev = 'useLayoutEffect'; 23947 warnInvalidHookAccess(); 23948 mountHookTypesDev(); 23949 return mountLayoutEffect(create, deps); 23950 }, 23951 useMemo: function (create, deps) { 23952 currentHookNameInDev = 'useMemo'; 23953 warnInvalidHookAccess(); 23954 mountHookTypesDev(); 23955 var prevDispatcher = ReactCurrentDispatcher.current; 23956 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23957 23958 try { 23959 return mountMemo(create, deps); 23960 } finally { 23961 ReactCurrentDispatcher.current = prevDispatcher; 23962 } 23963 }, 23964 useReducer: function (reducer, initialArg, init) { 23965 currentHookNameInDev = 'useReducer'; 23966 warnInvalidHookAccess(); 23967 mountHookTypesDev(); 23968 var prevDispatcher = ReactCurrentDispatcher.current; 23969 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23970 23971 try { 23972 return mountReducer(reducer, initialArg, init); 23973 } finally { 23974 ReactCurrentDispatcher.current = prevDispatcher; 23975 } 23976 }, 23977 useRef: function (initialValue) { 23978 currentHookNameInDev = 'useRef'; 23979 warnInvalidHookAccess(); 23980 mountHookTypesDev(); 23981 return mountRef(initialValue); 23982 }, 23983 useState: function (initialState) { 23984 currentHookNameInDev = 'useState'; 23985 warnInvalidHookAccess(); 23986 mountHookTypesDev(); 23987 var prevDispatcher = ReactCurrentDispatcher.current; 23988 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 23989 23990 try { 23991 return mountState(initialState); 23992 } finally { 23993 ReactCurrentDispatcher.current = prevDispatcher; 23994 } 23995 }, 23996 useDebugValue: function (value, formatterFn) { 23997 currentHookNameInDev = 'useDebugValue'; 23998 warnInvalidHookAccess(); 23999 mountHookTypesDev(); 24000 return mountDebugValue(); 24001 }, 24002 useResponder: function (responder, props) { 24003 currentHookNameInDev = 'useResponder'; 24004 warnInvalidHookAccess(); 24005 mountHookTypesDev(); 24006 return createDeprecatedResponderListener(responder, props); 24007 }, 24008 useDeferredValue: function (value, config) { 24009 currentHookNameInDev = 'useDeferredValue'; 24010 warnInvalidHookAccess(); 24011 mountHookTypesDev(); 24012 return mountDeferredValue(value, config); 24013 }, 24014 useTransition: function (config) { 24015 currentHookNameInDev = 'useTransition'; 24016 warnInvalidHookAccess(); 24017 mountHookTypesDev(); 24018 return mountTransition(config); 24019 } 24020 }; 24021 InvalidNestedHooksDispatcherOnUpdateInDEV = { 24022 readContext: function (context, observedBits) { 24023 warnInvalidContextAccess(); 24024 return readContext(context, observedBits); 24025 }, 24026 useCallback: function (callback, deps) { 24027 currentHookNameInDev = 'useCallback'; 24028 warnInvalidHookAccess(); 24029 updateHookTypesDev(); 24030 return updateCallback(callback, deps); 24031 }, 24032 useContext: function (context, observedBits) { 24033 currentHookNameInDev = 'useContext'; 24034 warnInvalidHookAccess(); 24035 updateHookTypesDev(); 24036 return readContext(context, observedBits); 24037 }, 24038 useEffect: function (create, deps) { 24039 currentHookNameInDev = 'useEffect'; 24040 warnInvalidHookAccess(); 24041 updateHookTypesDev(); 24042 return updateEffect(create, deps); 24043 }, 24044 useImperativeHandle: function (ref, create, deps) { 24045 currentHookNameInDev = 'useImperativeHandle'; 24046 warnInvalidHookAccess(); 24047 updateHookTypesDev(); 24048 return updateImperativeHandle(ref, create, deps); 24049 }, 24050 useLayoutEffect: function (create, deps) { 24051 currentHookNameInDev = 'useLayoutEffect'; 24052 warnInvalidHookAccess(); 24053 updateHookTypesDev(); 24054 return updateLayoutEffect(create, deps); 24055 }, 24056 useMemo: function (create, deps) { 24057 currentHookNameInDev = 'useMemo'; 24058 warnInvalidHookAccess(); 24059 updateHookTypesDev(); 24060 var prevDispatcher = ReactCurrentDispatcher.current; 24061 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24062 24063 try { 24064 return updateMemo(create, deps); 24065 } finally { 24066 ReactCurrentDispatcher.current = prevDispatcher; 24067 } 24068 }, 24069 useReducer: function (reducer, initialArg, init) { 24070 currentHookNameInDev = 'useReducer'; 24071 warnInvalidHookAccess(); 24072 updateHookTypesDev(); 24073 var prevDispatcher = ReactCurrentDispatcher.current; 24074 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24075 24076 try { 24077 return updateReducer(reducer, initialArg, init); 24078 } finally { 24079 ReactCurrentDispatcher.current = prevDispatcher; 24080 } 24081 }, 24082 useRef: function (initialValue) { 24083 currentHookNameInDev = 'useRef'; 24084 warnInvalidHookAccess(); 24085 updateHookTypesDev(); 24086 return updateRef(); 24087 }, 24088 useState: function (initialState) { 24089 currentHookNameInDev = 'useState'; 24090 warnInvalidHookAccess(); 24091 updateHookTypesDev(); 24092 var prevDispatcher = ReactCurrentDispatcher.current; 24093 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24094 24095 try { 24096 return updateState(initialState); 24097 } finally { 24098 ReactCurrentDispatcher.current = prevDispatcher; 24099 } 24100 }, 24101 useDebugValue: function (value, formatterFn) { 24102 currentHookNameInDev = 'useDebugValue'; 24103 warnInvalidHookAccess(); 24104 updateHookTypesDev(); 24105 return updateDebugValue(); 24106 }, 24107 useResponder: function (responder, props) { 24108 currentHookNameInDev = 'useResponder'; 24109 warnInvalidHookAccess(); 24110 updateHookTypesDev(); 24111 return createDeprecatedResponderListener(responder, props); 24112 }, 24113 useDeferredValue: function (value, config) { 24114 currentHookNameInDev = 'useDeferredValue'; 24115 warnInvalidHookAccess(); 24116 updateHookTypesDev(); 24117 return updateDeferredValue(value, config); 24118 }, 24119 useTransition: function (config) { 24120 currentHookNameInDev = 'useTransition'; 24121 warnInvalidHookAccess(); 24122 updateHookTypesDev(); 24123 return updateTransition(config); 24124 } 24125 }; 24126 InvalidNestedHooksDispatcherOnRerenderInDEV = { 24127 readContext: function (context, observedBits) { 24128 warnInvalidContextAccess(); 24129 return readContext(context, observedBits); 24130 }, 24131 useCallback: function (callback, deps) { 24132 currentHookNameInDev = 'useCallback'; 24133 warnInvalidHookAccess(); 24134 updateHookTypesDev(); 24135 return updateCallback(callback, deps); 24136 }, 24137 useContext: function (context, observedBits) { 24138 currentHookNameInDev = 'useContext'; 24139 warnInvalidHookAccess(); 24140 updateHookTypesDev(); 24141 return readContext(context, observedBits); 24142 }, 24143 useEffect: function (create, deps) { 24144 currentHookNameInDev = 'useEffect'; 24145 warnInvalidHookAccess(); 24146 updateHookTypesDev(); 24147 return updateEffect(create, deps); 24148 }, 24149 useImperativeHandle: function (ref, create, deps) { 24150 currentHookNameInDev = 'useImperativeHandle'; 24151 warnInvalidHookAccess(); 24152 updateHookTypesDev(); 24153 return updateImperativeHandle(ref, create, deps); 24154 }, 24155 useLayoutEffect: function (create, deps) { 24156 currentHookNameInDev = 'useLayoutEffect'; 24157 warnInvalidHookAccess(); 24158 updateHookTypesDev(); 24159 return updateLayoutEffect(create, deps); 24160 }, 24161 useMemo: function (create, deps) { 24162 currentHookNameInDev = 'useMemo'; 24163 warnInvalidHookAccess(); 24164 updateHookTypesDev(); 24165 var prevDispatcher = ReactCurrentDispatcher.current; 24166 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24167 24168 try { 24169 return updateMemo(create, deps); 24170 } finally { 24171 ReactCurrentDispatcher.current = prevDispatcher; 24172 } 24173 }, 24174 useReducer: function (reducer, initialArg, init) { 24175 currentHookNameInDev = 'useReducer'; 24176 warnInvalidHookAccess(); 24177 updateHookTypesDev(); 24178 var prevDispatcher = ReactCurrentDispatcher.current; 24179 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24180 24181 try { 24182 return rerenderReducer(reducer, initialArg, init); 24183 } finally { 24184 ReactCurrentDispatcher.current = prevDispatcher; 24185 } 24186 }, 24187 useRef: function (initialValue) { 24188 currentHookNameInDev = 'useRef'; 24189 warnInvalidHookAccess(); 24190 updateHookTypesDev(); 24191 return updateRef(); 24192 }, 24193 useState: function (initialState) { 24194 currentHookNameInDev = 'useState'; 24195 warnInvalidHookAccess(); 24196 updateHookTypesDev(); 24197 var prevDispatcher = ReactCurrentDispatcher.current; 24198 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 24199 24200 try { 24201 return rerenderState(initialState); 24202 } finally { 24203 ReactCurrentDispatcher.current = prevDispatcher; 24204 } 24205 }, 24206 useDebugValue: function (value, formatterFn) { 24207 currentHookNameInDev = 'useDebugValue'; 24208 warnInvalidHookAccess(); 24209 updateHookTypesDev(); 24210 return updateDebugValue(); 24211 }, 24212 useResponder: function (responder, props) { 24213 currentHookNameInDev = 'useResponder'; 24214 warnInvalidHookAccess(); 24215 updateHookTypesDev(); 24216 return createDeprecatedResponderListener(responder, props); 24217 }, 24218 useDeferredValue: function (value, config) { 24219 currentHookNameInDev = 'useDeferredValue'; 24220 warnInvalidHookAccess(); 24221 updateHookTypesDev(); 24222 return rerenderDeferredValue(value, config); 24223 }, 24224 useTransition: function (config) { 24225 currentHookNameInDev = 'useTransition'; 24226 warnInvalidHookAccess(); 24227 updateHookTypesDev(); 24228 return rerenderTransition(config); 24229 } 24230 }; 24231} 24232 24233var now$1 = Scheduler.unstable_now; 24234var commitTime = 0; 24235var profilerStartTime = -1; 24236 24237function getCommitTime() { 24238 return commitTime; 24239} 24240 24241function recordCommitTime() { 24242 24243 commitTime = now$1(); 24244} 24245 24246function startProfilerTimer(fiber) { 24247 24248 profilerStartTime = now$1(); 24249 24250 if (fiber.actualStartTime < 0) { 24251 fiber.actualStartTime = now$1(); 24252 } 24253} 24254 24255function stopProfilerTimerIfRunning(fiber) { 24256 24257 profilerStartTime = -1; 24258} 24259 24260function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { 24261 24262 if (profilerStartTime >= 0) { 24263 var elapsedTime = now$1() - profilerStartTime; 24264 fiber.actualDuration += elapsedTime; 24265 24266 if (overrideBaseTime) { 24267 fiber.selfBaseDuration = elapsedTime; 24268 } 24269 24270 profilerStartTime = -1; 24271 } 24272} 24273 24274// This may have been an insertion or a hydration. 24275 24276var hydrationParentFiber = null; 24277var nextHydratableInstance = null; 24278var isHydrating = false; 24279 24280function enterHydrationState(fiber) { 24281 24282 var parentInstance = fiber.stateNode.containerInfo; 24283 nextHydratableInstance = getFirstHydratableChild(parentInstance); 24284 hydrationParentFiber = fiber; 24285 isHydrating = true; 24286 return true; 24287} 24288 24289function deleteHydratableInstance(returnFiber, instance) { 24290 { 24291 switch (returnFiber.tag) { 24292 case HostRoot: 24293 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 24294 break; 24295 24296 case HostComponent: 24297 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 24298 break; 24299 } 24300 } 24301 24302 var childToDelete = createFiberFromHostInstanceForDeletion(); 24303 childToDelete.stateNode = instance; 24304 childToDelete.return = returnFiber; 24305 childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, 24306 // these children are not part of the reconciliation list of children. 24307 // Even if we abort and rereconcile the children, that will try to hydrate 24308 // again and the nodes are still in the host tree so these will be 24309 // recreated. 24310 24311 if (returnFiber.lastEffect !== null) { 24312 returnFiber.lastEffect.nextEffect = childToDelete; 24313 returnFiber.lastEffect = childToDelete; 24314 } else { 24315 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 24316 } 24317} 24318 24319function insertNonHydratedInstance(returnFiber, fiber) { 24320 fiber.effectTag = fiber.effectTag & ~Hydrating | Placement; 24321 24322 { 24323 switch (returnFiber.tag) { 24324 case HostRoot: 24325 { 24326 var parentContainer = returnFiber.stateNode.containerInfo; 24327 24328 switch (fiber.tag) { 24329 case HostComponent: 24330 var type = fiber.type; 24331 var props = fiber.pendingProps; 24332 didNotFindHydratableContainerInstance(parentContainer, type); 24333 break; 24334 24335 case HostText: 24336 var text = fiber.pendingProps; 24337 didNotFindHydratableContainerTextInstance(parentContainer, text); 24338 break; 24339 } 24340 24341 break; 24342 } 24343 24344 case HostComponent: 24345 { 24346 var parentType = returnFiber.type; 24347 var parentProps = returnFiber.memoizedProps; 24348 var parentInstance = returnFiber.stateNode; 24349 24350 switch (fiber.tag) { 24351 case HostComponent: 24352 var _type = fiber.type; 24353 var _props = fiber.pendingProps; 24354 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type); 24355 break; 24356 24357 case HostText: 24358 var _text = fiber.pendingProps; 24359 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 24360 break; 24361 24362 case SuspenseComponent: 24363 didNotFindHydratableSuspenseInstance(parentType, parentProps); 24364 break; 24365 } 24366 24367 break; 24368 } 24369 24370 default: 24371 return; 24372 } 24373 } 24374} 24375 24376function tryHydrate(fiber, nextInstance) { 24377 switch (fiber.tag) { 24378 case HostComponent: 24379 { 24380 var type = fiber.type; 24381 var props = fiber.pendingProps; 24382 var instance = canHydrateInstance(nextInstance, type); 24383 24384 if (instance !== null) { 24385 fiber.stateNode = instance; 24386 return true; 24387 } 24388 24389 return false; 24390 } 24391 24392 case HostText: 24393 { 24394 var text = fiber.pendingProps; 24395 var textInstance = canHydrateTextInstance(nextInstance, text); 24396 24397 if (textInstance !== null) { 24398 fiber.stateNode = textInstance; 24399 return true; 24400 } 24401 24402 return false; 24403 } 24404 24405 case SuspenseComponent: 24406 { 24407 24408 return false; 24409 } 24410 24411 default: 24412 return false; 24413 } 24414} 24415 24416function tryToClaimNextHydratableInstance(fiber) { 24417 if (!isHydrating) { 24418 return; 24419 } 24420 24421 var nextInstance = nextHydratableInstance; 24422 24423 if (!nextInstance) { 24424 // Nothing to hydrate. Make it an insertion. 24425 insertNonHydratedInstance(hydrationParentFiber, fiber); 24426 isHydrating = false; 24427 hydrationParentFiber = fiber; 24428 return; 24429 } 24430 24431 var firstAttemptedInstance = nextInstance; 24432 24433 if (!tryHydrate(fiber, nextInstance)) { 24434 // If we can't hydrate this instance let's try the next one. 24435 // We use this as a heuristic. It's based on intuition and not data so it 24436 // might be flawed or unnecessary. 24437 nextInstance = getNextHydratableSibling(firstAttemptedInstance); 24438 24439 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 24440 // Nothing to hydrate. Make it an insertion. 24441 insertNonHydratedInstance(hydrationParentFiber, fiber); 24442 isHydrating = false; 24443 hydrationParentFiber = fiber; 24444 return; 24445 } // We matched the next one, we'll now assume that the first one was 24446 // superfluous and we'll delete it. Since we can't eagerly delete it 24447 // we'll have to schedule a deletion. To do that, this node needs a dummy 24448 // fiber associated with it. 24449 24450 24451 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); 24452 } 24453 24454 hydrationParentFiber = fiber; 24455 nextHydratableInstance = getFirstHydratableChild(nextInstance); 24456} 24457 24458function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 24459 24460 var instance = fiber.stateNode; 24461 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component. 24462 24463 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 24464 // is a new ref we mark this as an update. 24465 24466 if (updatePayload !== null) { 24467 return true; 24468 } 24469 24470 return false; 24471} 24472 24473function prepareToHydrateHostTextInstance(fiber) { 24474 24475 var textInstance = fiber.stateNode; 24476 var textContent = fiber.memoizedProps; 24477 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 24478 24479 { 24480 if (shouldUpdate) { 24481 // We assume that prepareToHydrateHostTextInstance is called in a context where the 24482 // hydration parent is the parent host component of this host text. 24483 var returnFiber = hydrationParentFiber; 24484 24485 if (returnFiber !== null) { 24486 switch (returnFiber.tag) { 24487 case HostRoot: 24488 { 24489 var parentContainer = returnFiber.stateNode.containerInfo; 24490 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 24491 break; 24492 } 24493 24494 case HostComponent: 24495 { 24496 var parentType = returnFiber.type; 24497 var parentProps = returnFiber.memoizedProps; 24498 var parentInstance = returnFiber.stateNode; 24499 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 24500 break; 24501 } 24502 } 24503 } 24504 } 24505 } 24506 24507 return shouldUpdate; 24508} 24509 24510function skipPastDehydratedSuspenseInstance(fiber) { 24511 24512 var suspenseState = fiber.memoizedState; 24513 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null; 24514 24515 if (!suspenseInstance) { 24516 { 24517 throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." ); 24518 } 24519 } 24520 24521 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); 24522} 24523 24524function popToNextHostParent(fiber) { 24525 var parent = fiber.return; 24526 24527 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) { 24528 parent = parent.return; 24529 } 24530 24531 hydrationParentFiber = parent; 24532} 24533 24534function popHydrationState(fiber) { 24535 24536 if (fiber !== hydrationParentFiber) { 24537 // We're deeper than the current hydration context, inside an inserted 24538 // tree. 24539 return false; 24540 } 24541 24542 if (!isHydrating) { 24543 // If we're not currently hydrating but we're in a hydration context, then 24544 // we were an insertion and now need to pop up reenter hydration of our 24545 // siblings. 24546 popToNextHostParent(fiber); 24547 isHydrating = true; 24548 return false; 24549 } 24550 24551 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now. 24552 // We only do this deeper than head and body since they tend to have random 24553 // other nodes in them. We also ignore components with pure text content in 24554 // side of them. 24555 // TODO: Better heuristic. 24556 24557 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 24558 var nextInstance = nextHydratableInstance; 24559 24560 while (nextInstance) { 24561 deleteHydratableInstance(fiber, nextInstance); 24562 nextInstance = getNextHydratableSibling(nextInstance); 24563 } 24564 } 24565 24566 popToNextHostParent(fiber); 24567 24568 if (fiber.tag === SuspenseComponent) { 24569 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); 24570 } else { 24571 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 24572 } 24573 24574 return true; 24575} 24576 24577function resetHydrationState() { 24578 24579 hydrationParentFiber = null; 24580 nextHydratableInstance = null; 24581 isHydrating = false; 24582} 24583 24584var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; 24585var didReceiveUpdate = false; 24586var didWarnAboutBadClass; 24587var didWarnAboutModulePatternComponent; 24588var didWarnAboutContextTypeOnFunctionComponent; 24589var didWarnAboutGetDerivedStateOnFunctionComponent; 24590var didWarnAboutFunctionRefs; 24591var didWarnAboutReassigningProps; 24592var didWarnAboutRevealOrder; 24593var didWarnAboutTailOptions; 24594 24595{ 24596 didWarnAboutBadClass = {}; 24597 didWarnAboutModulePatternComponent = {}; 24598 didWarnAboutContextTypeOnFunctionComponent = {}; 24599 didWarnAboutGetDerivedStateOnFunctionComponent = {}; 24600 didWarnAboutFunctionRefs = {}; 24601 didWarnAboutReassigningProps = false; 24602 didWarnAboutRevealOrder = {}; 24603 didWarnAboutTailOptions = {}; 24604} 24605 24606function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) { 24607 if (current === null) { 24608 // If this is a fresh new component that hasn't been rendered yet, we 24609 // won't update its child set by applying minimal side-effects. Instead, 24610 // we will add them all to the child before it gets rendered. That means 24611 // we can optimize this reconciliation pass by not tracking side-effects. 24612 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 24613 } else { 24614 // If the current child is the same as the work in progress, it means that 24615 // we haven't yet started any work on these children. Therefore, we use 24616 // the clone algorithm to create a copy of all the current children. 24617 // If we had any progressed work already, that is invalid at this point so 24618 // let's throw it out. 24619 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime); 24620 } 24621} 24622 24623function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) { 24624 // This function is fork of reconcileChildren. It's used in cases where we 24625 // want to reconcile without matching against the existing set. This has the 24626 // effect of all current children being unmounted; even if the type and key 24627 // are the same, the old child is unmounted and a new child is created. 24628 // 24629 // To do this, we're going to go through the reconcile algorithm twice. In 24630 // the first pass, we schedule a deletion for all the current children by 24631 // passing null. 24632 workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we 24633 // pass null in place of where we usually pass the current child set. This has 24634 // the effect of remounting all children regardless of whether their 24635 // identities match. 24636 24637 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 24638} 24639 24640function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) { 24641 // TODO: current can be non-null here even if the component 24642 // hasn't yet mounted. This happens after the first render suspends. 24643 // We'll need to figure out if this is fine or can cause issues. 24644 { 24645 if (workInProgress.type !== workInProgress.elementType) { 24646 // Lazy component props can't be validated in createElement 24647 // because they're only guaranteed to be resolved here. 24648 var innerPropTypes = Component.propTypes; 24649 24650 if (innerPropTypes) { 24651 checkPropTypes(innerPropTypes, nextProps, // Resolved props 24652 'prop', getComponentName(Component), getCurrentFiberStackInDev); 24653 } 24654 } 24655 } 24656 24657 var render = Component.render; 24658 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent 24659 24660 var nextChildren; 24661 prepareToReadContext(workInProgress, renderExpirationTime); 24662 24663 { 24664 ReactCurrentOwner$1.current = workInProgress; 24665 setIsRendering(true); 24666 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime); 24667 24668 if ( workInProgress.mode & StrictMode) { 24669 // Only double-render components with Hooks 24670 if (workInProgress.memoizedState !== null) { 24671 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime); 24672 } 24673 } 24674 24675 setIsRendering(false); 24676 } 24677 24678 if (current !== null && !didReceiveUpdate) { 24679 bailoutHooks(current, workInProgress, renderExpirationTime); 24680 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 24681 } // React DevTools reads this flag. 24682 24683 24684 workInProgress.effectTag |= PerformedWork; 24685 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 24686 return workInProgress.child; 24687} 24688 24689function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) { 24690 if (current === null) { 24691 var type = Component.type; 24692 24693 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. 24694 Component.defaultProps === undefined) { 24695 var resolvedType = type; 24696 24697 { 24698 resolvedType = resolveFunctionForHotReloading(type); 24699 } // If this is a plain function component without default props, 24700 // and with only the default shallow comparison, we upgrade it 24701 // to a SimpleMemoComponent to allow fast path updates. 24702 24703 24704 workInProgress.tag = SimpleMemoComponent; 24705 workInProgress.type = resolvedType; 24706 24707 { 24708 validateFunctionComponentInDev(workInProgress, type); 24709 } 24710 24711 return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime); 24712 } 24713 24714 { 24715 var innerPropTypes = type.propTypes; 24716 24717 if (innerPropTypes) { 24718 // Inner memo component props aren't currently validated in createElement. 24719 // We could move it there, but we'd still need this for lazy code path. 24720 checkPropTypes(innerPropTypes, nextProps, // Resolved props 24721 'prop', getComponentName(type), getCurrentFiberStackInDev); 24722 } 24723 } 24724 24725 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime); 24726 child.ref = workInProgress.ref; 24727 child.return = workInProgress; 24728 workInProgress.child = child; 24729 return child; 24730 } 24731 24732 { 24733 var _type = Component.type; 24734 var _innerPropTypes = _type.propTypes; 24735 24736 if (_innerPropTypes) { 24737 // Inner memo component props aren't currently validated in createElement. 24738 // We could move it there, but we'd still need this for lazy code path. 24739 checkPropTypes(_innerPropTypes, nextProps, // Resolved props 24740 'prop', getComponentName(_type), getCurrentFiberStackInDev); 24741 } 24742 } 24743 24744 var currentChild = current.child; // This is always exactly one child 24745 24746 if (updateExpirationTime < renderExpirationTime) { 24747 // This will be the props with resolved defaultProps, 24748 // unlike current.memoizedProps which will be the unresolved ones. 24749 var prevProps = currentChild.memoizedProps; // Default to shallow comparison 24750 24751 var compare = Component.compare; 24752 compare = compare !== null ? compare : shallowEqual; 24753 24754 if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { 24755 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 24756 } 24757 } // React DevTools reads this flag. 24758 24759 24760 workInProgress.effectTag |= PerformedWork; 24761 var newChild = createWorkInProgress(currentChild, nextProps); 24762 newChild.ref = workInProgress.ref; 24763 newChild.return = workInProgress; 24764 workInProgress.child = newChild; 24765 return newChild; 24766} 24767 24768function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) { 24769 // TODO: current can be non-null here even if the component 24770 // hasn't yet mounted. This happens when the inner render suspends. 24771 // We'll need to figure out if this is fine or can cause issues. 24772 { 24773 if (workInProgress.type !== workInProgress.elementType) { 24774 // Lazy component props can't be validated in createElement 24775 // because they're only guaranteed to be resolved here. 24776 var outerMemoType = workInProgress.elementType; 24777 24778 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { 24779 // We warn when you define propTypes on lazy() 24780 // so let's just skip over it to find memo() outer wrapper. 24781 // Inner props for memo are validated later. 24782 outerMemoType = refineResolvedLazyComponent(outerMemoType); 24783 } 24784 24785 var outerPropTypes = outerMemoType && outerMemoType.propTypes; 24786 24787 if (outerPropTypes) { 24788 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) 24789 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev); 24790 } // Inner propTypes will be validated in the function component path. 24791 24792 } 24793 } 24794 24795 if (current !== null) { 24796 var prevProps = current.memoizedProps; 24797 24798 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. 24799 workInProgress.type === current.type )) { 24800 didReceiveUpdate = false; 24801 24802 if (updateExpirationTime < renderExpirationTime) { 24803 // The pending update priority was cleared at the beginning of 24804 // beginWork. We're about to bail out, but there might be additional 24805 // updates at a lower priority. Usually, the priority level of the 24806 // remaining updates is accumlated during the evaluation of the 24807 // component (i.e. when processing the update queue). But since since 24808 // we're bailing out early *without* evaluating the component, we need 24809 // to account for it here, too. Reset to the value of the current fiber. 24810 // NOTE: This only applies to SimpleMemoComponent, not MemoComponent, 24811 // because a MemoComponent fiber does not have hooks or an update queue; 24812 // rather, it wraps around an inner component, which may or may not 24813 // contains hooks. 24814 // TODO: Move the reset at in beginWork out of the common path so that 24815 // this is no longer necessary. 24816 workInProgress.expirationTime = current.expirationTime; 24817 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 24818 } 24819 } 24820 } 24821 24822 return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime); 24823} 24824 24825function updateFragment(current, workInProgress, renderExpirationTime) { 24826 var nextChildren = workInProgress.pendingProps; 24827 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 24828 return workInProgress.child; 24829} 24830 24831function updateMode(current, workInProgress, renderExpirationTime) { 24832 var nextChildren = workInProgress.pendingProps.children; 24833 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 24834 return workInProgress.child; 24835} 24836 24837function updateProfiler(current, workInProgress, renderExpirationTime) { 24838 { 24839 workInProgress.effectTag |= Update; 24840 } 24841 24842 var nextProps = workInProgress.pendingProps; 24843 var nextChildren = nextProps.children; 24844 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 24845 return workInProgress.child; 24846} 24847 24848function markRef(current, workInProgress) { 24849 var ref = workInProgress.ref; 24850 24851 if (current === null && ref !== null || current !== null && current.ref !== ref) { 24852 // Schedule a Ref effect 24853 workInProgress.effectTag |= Ref; 24854 } 24855} 24856 24857function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) { 24858 { 24859 if (workInProgress.type !== workInProgress.elementType) { 24860 // Lazy component props can't be validated in createElement 24861 // because they're only guaranteed to be resolved here. 24862 var innerPropTypes = Component.propTypes; 24863 24864 if (innerPropTypes) { 24865 checkPropTypes(innerPropTypes, nextProps, // Resolved props 24866 'prop', getComponentName(Component), getCurrentFiberStackInDev); 24867 } 24868 } 24869 } 24870 24871 var context; 24872 24873 { 24874 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); 24875 context = getMaskedContext(workInProgress, unmaskedContext); 24876 } 24877 24878 var nextChildren; 24879 prepareToReadContext(workInProgress, renderExpirationTime); 24880 24881 { 24882 ReactCurrentOwner$1.current = workInProgress; 24883 setIsRendering(true); 24884 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime); 24885 24886 if ( workInProgress.mode & StrictMode) { 24887 // Only double-render components with Hooks 24888 if (workInProgress.memoizedState !== null) { 24889 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime); 24890 } 24891 } 24892 24893 setIsRendering(false); 24894 } 24895 24896 if (current !== null && !didReceiveUpdate) { 24897 bailoutHooks(current, workInProgress, renderExpirationTime); 24898 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 24899 } // React DevTools reads this flag. 24900 24901 24902 workInProgress.effectTag |= PerformedWork; 24903 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 24904 return workInProgress.child; 24905} 24906 24907function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) { 24908 { 24909 if (workInProgress.type !== workInProgress.elementType) { 24910 // Lazy component props can't be validated in createElement 24911 // because they're only guaranteed to be resolved here. 24912 var innerPropTypes = Component.propTypes; 24913 24914 if (innerPropTypes) { 24915 checkPropTypes(innerPropTypes, nextProps, // Resolved props 24916 'prop', getComponentName(Component), getCurrentFiberStackInDev); 24917 } 24918 } 24919 } // Push context providers early to prevent context stack mismatches. 24920 // During mounting we don't know the child context yet as the instance doesn't exist. 24921 // We will invalidate the child context in finishClassComponent() right after rendering. 24922 24923 24924 var hasContext; 24925 24926 if (isContextProvider(Component)) { 24927 hasContext = true; 24928 pushContextProvider(workInProgress); 24929 } else { 24930 hasContext = false; 24931 } 24932 24933 prepareToReadContext(workInProgress, renderExpirationTime); 24934 var instance = workInProgress.stateNode; 24935 var shouldUpdate; 24936 24937 if (instance === null) { 24938 if (current !== null) { 24939 // A class component without an instance only mounts if it suspended 24940 // inside a non-concurrent tree, in an inconsistent state. We want to 24941 // treat it like a new mount, even though an empty version of it already 24942 // committed. Disconnect the alternate pointers. 24943 current.alternate = null; 24944 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 24945 24946 workInProgress.effectTag |= Placement; 24947 } // In the initial pass we might need to construct the instance. 24948 24949 24950 constructClassInstance(workInProgress, Component, nextProps); 24951 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 24952 shouldUpdate = true; 24953 } else if (current === null) { 24954 // In a resume, we'll already have an instance we can reuse. 24955 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 24956 } else { 24957 shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime); 24958 } 24959 24960 var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime); 24961 24962 { 24963 var inst = workInProgress.stateNode; 24964 24965 if (inst.props !== nextProps) { 24966 if (!didWarnAboutReassigningProps) { 24967 error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component'); 24968 } 24969 24970 didWarnAboutReassigningProps = true; 24971 } 24972 } 24973 24974 return nextUnitOfWork; 24975} 24976 24977function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) { 24978 // Refs should update even if shouldComponentUpdate returns false 24979 markRef(current, workInProgress); 24980 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; 24981 24982 if (!shouldUpdate && !didCaptureError) { 24983 // Context providers should defer to sCU for rendering 24984 if (hasContext) { 24985 invalidateContextProvider(workInProgress, Component, false); 24986 } 24987 24988 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 24989 } 24990 24991 var instance = workInProgress.stateNode; // Rerender 24992 24993 ReactCurrentOwner$1.current = workInProgress; 24994 var nextChildren; 24995 24996 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') { 24997 // If we captured an error, but getDerivedStateFromError is not defined, 24998 // unmount all the children. componentDidCatch will schedule an update to 24999 // re-render a fallback. This is temporary until we migrate everyone to 25000 // the new API. 25001 // TODO: Warn in a future release. 25002 nextChildren = null; 25003 25004 { 25005 stopProfilerTimerIfRunning(); 25006 } 25007 } else { 25008 { 25009 setIsRendering(true); 25010 nextChildren = instance.render(); 25011 25012 if ( workInProgress.mode & StrictMode) { 25013 instance.render(); 25014 } 25015 25016 setIsRendering(false); 25017 } 25018 } // React DevTools reads this flag. 25019 25020 25021 workInProgress.effectTag |= PerformedWork; 25022 25023 if (current !== null && didCaptureError) { 25024 // If we're recovering from an error, reconcile without reusing any of 25025 // the existing children. Conceptually, the normal children and the children 25026 // that are shown on error are two different sets, so we shouldn't reuse 25027 // normal children even if their identities match. 25028 forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime); 25029 } else { 25030 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 25031 } // Memoize state using the values we just used to render. 25032 // TODO: Restructure so we never read values from the instance. 25033 25034 25035 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. 25036 25037 if (hasContext) { 25038 invalidateContextProvider(workInProgress, Component, true); 25039 } 25040 25041 return workInProgress.child; 25042} 25043 25044function pushHostRootContext(workInProgress) { 25045 var root = workInProgress.stateNode; 25046 25047 if (root.pendingContext) { 25048 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 25049 } else if (root.context) { 25050 // Should always be set 25051 pushTopLevelContextObject(workInProgress, root.context, false); 25052 } 25053 25054 pushHostContainer(workInProgress, root.containerInfo); 25055} 25056 25057function updateHostRoot(current, workInProgress, renderExpirationTime) { 25058 pushHostRootContext(workInProgress); 25059 var updateQueue = workInProgress.updateQueue; 25060 25061 if (!(current !== null && updateQueue !== null)) { 25062 { 25063 throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); 25064 } 25065 } 25066 25067 var nextProps = workInProgress.pendingProps; 25068 var prevState = workInProgress.memoizedState; 25069 var prevChildren = prevState !== null ? prevState.element : null; 25070 cloneUpdateQueue(current, workInProgress); 25071 processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); 25072 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property 25073 // being called "element". 25074 25075 var nextChildren = nextState.element; 25076 25077 if (nextChildren === prevChildren) { 25078 // If the state is the same as before, that's a bailout because we had 25079 // no work that expires at this time. 25080 resetHydrationState(); 25081 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 25082 } 25083 25084 var root = workInProgress.stateNode; 25085 25086 if (root.hydrate && enterHydrationState(workInProgress)) { 25087 // If we don't have any current children this might be the first pass. 25088 // We always try to hydrate. If this isn't a hydration pass there won't 25089 // be any children to hydrate which is effectively the same thing as 25090 // not hydrating. 25091 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 25092 workInProgress.child = child; 25093 var node = child; 25094 25095 while (node) { 25096 // Mark each child as hydrating. This is a fast path to know whether this 25097 // tree is part of a hydrating tree. This is used to determine if a child 25098 // node has fully mounted yet, and for scheduling event replaying. 25099 // Conceptually this is similar to Placement in that a new subtree is 25100 // inserted into the React tree here. It just happens to not need DOM 25101 // mutations because it already exists. 25102 node.effectTag = node.effectTag & ~Placement | Hydrating; 25103 node = node.sibling; 25104 } 25105 } else { 25106 // Otherwise reset hydration state in case we aborted and resumed another 25107 // root. 25108 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 25109 resetHydrationState(); 25110 } 25111 25112 return workInProgress.child; 25113} 25114 25115function updateHostComponent(current, workInProgress, renderExpirationTime) { 25116 pushHostContext(workInProgress); 25117 25118 if (current === null) { 25119 tryToClaimNextHydratableInstance(workInProgress); 25120 } 25121 25122 var type = workInProgress.type; 25123 var nextProps = workInProgress.pendingProps; 25124 var prevProps = current !== null ? current.memoizedProps : null; 25125 var nextChildren = nextProps.children; 25126 var isDirectTextChild = shouldSetTextContent(type, nextProps); 25127 25128 if (isDirectTextChild) { 25129 // We special case a direct text child of a host node. This is a common 25130 // case. We won't handle it as a reified child. We will instead handle 25131 // this in the host environment that also has access to this prop. That 25132 // avoids allocating another HostText fiber and traversing it. 25133 nextChildren = null; 25134 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { 25135 // If we're switching from a direct text child to a normal child, or to 25136 // empty, we need to schedule the text content to be reset. 25137 workInProgress.effectTag |= ContentReset; 25138 } 25139 25140 markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. 25141 25142 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) { 25143 { 25144 markSpawnedWork(Never); 25145 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 25146 25147 25148 workInProgress.expirationTime = workInProgress.childExpirationTime = Never; 25149 return null; 25150 } 25151 25152 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 25153 return workInProgress.child; 25154} 25155 25156function updateHostText(current, workInProgress) { 25157 if (current === null) { 25158 tryToClaimNextHydratableInstance(workInProgress); 25159 } // Nothing to do here. This is terminal. We'll do the completion step 25160 // immediately after. 25161 25162 25163 return null; 25164} 25165 25166function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) { 25167 if (_current !== null) { 25168 // A lazy component only mounts if it suspended inside a non- 25169 // concurrent tree, in an inconsistent state. We want to treat it like 25170 // a new mount, even though an empty version of it already committed. 25171 // Disconnect the alternate pointers. 25172 _current.alternate = null; 25173 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 25174 25175 workInProgress.effectTag |= Placement; 25176 } 25177 25178 var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet. 25179 // Cancel and resume right after we know the tag. 25180 25181 cancelWorkTimer(workInProgress); 25182 var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type. 25183 25184 workInProgress.type = Component; 25185 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component); 25186 startWorkTimer(workInProgress); 25187 var resolvedProps = resolveDefaultProps(Component, props); 25188 var child; 25189 25190 switch (resolvedTag) { 25191 case FunctionComponent: 25192 { 25193 { 25194 validateFunctionComponentInDev(workInProgress, Component); 25195 workInProgress.type = Component = resolveFunctionForHotReloading(Component); 25196 } 25197 25198 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime); 25199 return child; 25200 } 25201 25202 case ClassComponent: 25203 { 25204 { 25205 workInProgress.type = Component = resolveClassForHotReloading(Component); 25206 } 25207 25208 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime); 25209 return child; 25210 } 25211 25212 case ForwardRef: 25213 { 25214 { 25215 workInProgress.type = Component = resolveForwardRefForHotReloading(Component); 25216 } 25217 25218 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime); 25219 return child; 25220 } 25221 25222 case MemoComponent: 25223 { 25224 { 25225 if (workInProgress.type !== workInProgress.elementType) { 25226 var outerPropTypes = Component.propTypes; 25227 25228 if (outerPropTypes) { 25229 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only 25230 'prop', getComponentName(Component), getCurrentFiberStackInDev); 25231 } 25232 } 25233 } 25234 25235 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too 25236 updateExpirationTime, renderExpirationTime); 25237 return child; 25238 } 25239 } 25240 25241 var hint = ''; 25242 25243 { 25244 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) { 25245 hint = ' Did you wrap a component in React.lazy() more than once?'; 25246 } 25247 } // This message intentionally doesn't mention ForwardRef or MemoComponent 25248 // because the fact that it's a separate type of work is an 25249 // implementation detail. 25250 25251 25252 { 25253 { 25254 throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint ); 25255 } 25256 } 25257} 25258 25259function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) { 25260 if (_current !== null) { 25261 // An incomplete component only mounts if it suspended inside a non- 25262 // concurrent tree, in an inconsistent state. We want to treat it like 25263 // a new mount, even though an empty version of it already committed. 25264 // Disconnect the alternate pointers. 25265 _current.alternate = null; 25266 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 25267 25268 workInProgress.effectTag |= Placement; 25269 } // Promote the fiber to a class and try rendering again. 25270 25271 25272 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` 25273 // Push context providers early to prevent context stack mismatches. 25274 // During mounting we don't know the child context yet as the instance doesn't exist. 25275 // We will invalidate the child context in finishClassComponent() right after rendering. 25276 25277 var hasContext; 25278 25279 if (isContextProvider(Component)) { 25280 hasContext = true; 25281 pushContextProvider(workInProgress); 25282 } else { 25283 hasContext = false; 25284 } 25285 25286 prepareToReadContext(workInProgress, renderExpirationTime); 25287 constructClassInstance(workInProgress, Component, nextProps); 25288 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 25289 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime); 25290} 25291 25292function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) { 25293 if (_current !== null) { 25294 // An indeterminate component only mounts if it suspended inside a non- 25295 // concurrent tree, in an inconsistent state. We want to treat it like 25296 // a new mount, even though an empty version of it already committed. 25297 // Disconnect the alternate pointers. 25298 _current.alternate = null; 25299 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 25300 25301 workInProgress.effectTag |= Placement; 25302 } 25303 25304 var props = workInProgress.pendingProps; 25305 var context; 25306 25307 { 25308 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); 25309 context = getMaskedContext(workInProgress, unmaskedContext); 25310 } 25311 25312 prepareToReadContext(workInProgress, renderExpirationTime); 25313 var value; 25314 25315 { 25316 if (Component.prototype && typeof Component.prototype.render === 'function') { 25317 var componentName = getComponentName(Component) || 'Unknown'; 25318 25319 if (!didWarnAboutBadClass[componentName]) { 25320 error("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); 25321 25322 didWarnAboutBadClass[componentName] = true; 25323 } 25324 } 25325 25326 if (workInProgress.mode & StrictMode) { 25327 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); 25328 } 25329 25330 setIsRendering(true); 25331 ReactCurrentOwner$1.current = workInProgress; 25332 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime); 25333 setIsRendering(false); 25334 } // React DevTools reads this flag. 25335 25336 25337 workInProgress.effectTag |= PerformedWork; 25338 25339 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 25340 { 25341 var _componentName = getComponentName(Component) || 'Unknown'; 25342 25343 if (!didWarnAboutModulePatternComponent[_componentName]) { 25344 error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName); 25345 25346 didWarnAboutModulePatternComponent[_componentName] = true; 25347 } 25348 } // Proceed under the assumption that this is a class instance 25349 25350 25351 workInProgress.tag = ClassComponent; // Throw out any hooks that were used. 25352 25353 workInProgress.memoizedState = null; 25354 workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches. 25355 // During mounting we don't know the child context yet as the instance doesn't exist. 25356 // We will invalidate the child context in finishClassComponent() right after rendering. 25357 25358 var hasContext = false; 25359 25360 if (isContextProvider(Component)) { 25361 hasContext = true; 25362 pushContextProvider(workInProgress); 25363 } else { 25364 hasContext = false; 25365 } 25366 25367 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; 25368 initializeUpdateQueue(workInProgress); 25369 var getDerivedStateFromProps = Component.getDerivedStateFromProps; 25370 25371 if (typeof getDerivedStateFromProps === 'function') { 25372 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props); 25373 } 25374 25375 adoptClassInstance(workInProgress, value); 25376 mountClassInstance(workInProgress, Component, props, renderExpirationTime); 25377 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime); 25378 } else { 25379 // Proceed under the assumption that this is a function component 25380 workInProgress.tag = FunctionComponent; 25381 25382 { 25383 25384 if ( workInProgress.mode & StrictMode) { 25385 // Only double-render components with Hooks 25386 if (workInProgress.memoizedState !== null) { 25387 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime); 25388 } 25389 } 25390 } 25391 25392 reconcileChildren(null, workInProgress, value, renderExpirationTime); 25393 25394 { 25395 validateFunctionComponentInDev(workInProgress, Component); 25396 } 25397 25398 return workInProgress.child; 25399 } 25400} 25401 25402function validateFunctionComponentInDev(workInProgress, Component) { 25403 { 25404 if (Component) { 25405 if (Component.childContextTypes) { 25406 error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component'); 25407 } 25408 } 25409 25410 if (workInProgress.ref !== null) { 25411 var info = ''; 25412 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 25413 25414 if (ownerName) { 25415 info += '\n\nCheck the render method of `' + ownerName + '`.'; 25416 } 25417 25418 var warningKey = ownerName || workInProgress._debugID || ''; 25419 var debugSource = workInProgress._debugSource; 25420 25421 if (debugSource) { 25422 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 25423 } 25424 25425 if (!didWarnAboutFunctionRefs[warningKey]) { 25426 didWarnAboutFunctionRefs[warningKey] = true; 25427 25428 error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info); 25429 } 25430 } 25431 25432 if (typeof Component.getDerivedStateFromProps === 'function') { 25433 var _componentName2 = getComponentName(Component) || 'Unknown'; 25434 25435 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { 25436 error('%s: Function components do not support getDerivedStateFromProps.', _componentName2); 25437 25438 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; 25439 } 25440 } 25441 25442 if (typeof Component.contextType === 'object' && Component.contextType !== null) { 25443 var _componentName3 = getComponentName(Component) || 'Unknown'; 25444 25445 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { 25446 error('%s: Function components do not support contextType.', _componentName3); 25447 25448 didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; 25449 } 25450 } 25451 } 25452} 25453 25454var SUSPENDED_MARKER = { 25455 dehydrated: null, 25456 retryTime: NoWork 25457}; 25458 25459function shouldRemainOnFallback(suspenseContext, current, workInProgress) { 25460 // If the context is telling us that we should show a fallback, and we're not 25461 // already showing content, then we should show the fallback instead. 25462 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current === null || current.memoizedState !== null); 25463} 25464 25465function updateSuspenseComponent(current, workInProgress, renderExpirationTime) { 25466 var mode = workInProgress.mode; 25467 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. 25468 25469 { 25470 if (shouldSuspend(workInProgress)) { 25471 workInProgress.effectTag |= DidCapture; 25472 } 25473 } 25474 25475 var suspenseContext = suspenseStackCursor.current; 25476 var nextDidTimeout = false; 25477 var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; 25478 25479 if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { 25480 // Something in this boundary's subtree already suspended. Switch to 25481 // rendering the fallback children. 25482 nextDidTimeout = true; 25483 workInProgress.effectTag &= ~DidCapture; 25484 } else { 25485 // Attempting the main content 25486 if (current === null || current.memoizedState !== null) { 25487 // This is a new mount or this boundary is already showing a fallback state. 25488 // Mark this subtree context as having at least one invisible parent that could 25489 // handle the fallback state. 25490 // Boundaries without fallbacks or should be avoided are not considered since 25491 // they cannot handle preferred fallback states. 25492 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) { 25493 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext); 25494 } 25495 } 25496 } 25497 25498 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 25499 pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to 25500 // showing the fallback children in place of the "primary" children. 25501 // However, we don't want to delete the primary children because then their 25502 // state will be lost (both the React state and the host state, e.g. 25503 // uncontrolled form inputs). Instead we keep them mounted and hide them. 25504 // Both the fallback children AND the primary children are rendered at the 25505 // same time. Once the primary children are un-suspended, we can delete 25506 // the fallback children — don't need to preserve their state. 25507 // 25508 // The two sets of children are siblings in the host environment, but 25509 // semantically, for purposes of reconciliation, they are two separate sets. 25510 // So we store them using two fragment fibers. 25511 // 25512 // However, we want to avoid allocating extra fibers for every placeholder. 25513 // They're only necessary when the children time out, because that's the 25514 // only time when both sets are mounted. 25515 // 25516 // So, the extra fragment fibers are only used if the children time out. 25517 // Otherwise, we render the primary children directly. This requires some 25518 // custom reconciliation logic to preserve the state of the primary 25519 // children. It's essentially a very basic form of re-parenting. 25520 25521 if (current === null) { 25522 // If we're currently hydrating, try to hydrate this boundary. 25523 // But only if this has a fallback. 25524 if (nextProps.fallback !== undefined) { 25525 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component. 25526 } // This is the initial mount. This branch is pretty simple because there's 25527 // no previous state that needs to be preserved. 25528 25529 25530 if (nextDidTimeout) { 25531 // Mount separate fragments for primary and fallback children. 25532 var nextFallbackChildren = nextProps.fallback; 25533 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null); 25534 primaryChildFragment.return = workInProgress; 25535 25536 if ((workInProgress.mode & BlockingMode) === NoMode) { 25537 // Outside of blocking mode, we commit the effects from the 25538 // partially completed, timed-out tree, too. 25539 var progressedState = workInProgress.memoizedState; 25540 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child; 25541 primaryChildFragment.child = progressedPrimaryChild; 25542 var progressedChild = progressedPrimaryChild; 25543 25544 while (progressedChild !== null) { 25545 progressedChild.return = primaryChildFragment; 25546 progressedChild = progressedChild.sibling; 25547 } 25548 } 25549 25550 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null); 25551 fallbackChildFragment.return = workInProgress; 25552 primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the 25553 // fallback children. 25554 25555 workInProgress.memoizedState = SUSPENDED_MARKER; 25556 workInProgress.child = primaryChildFragment; 25557 return fallbackChildFragment; 25558 } else { 25559 // Mount the primary children without an intermediate fragment fiber. 25560 var nextPrimaryChildren = nextProps.children; 25561 workInProgress.memoizedState = null; 25562 return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime); 25563 } 25564 } else { 25565 // This is an update. This branch is more complicated because we need to 25566 // ensure the state of the primary children is preserved. 25567 var prevState = current.memoizedState; 25568 25569 if (prevState !== null) { 25570 // wrapped in a fragment fiber. 25571 25572 25573 var currentPrimaryChildFragment = current.child; 25574 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 25575 25576 if (nextDidTimeout) { 25577 // Still timed out. Reuse the current primary children by cloning 25578 // its fragment. We're going to skip over these entirely. 25579 var _nextFallbackChildren2 = nextProps.fallback; 25580 25581 var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps); 25582 25583 _primaryChildFragment2.return = workInProgress; 25584 25585 if ((workInProgress.mode & BlockingMode) === NoMode) { 25586 // Outside of blocking mode, we commit the effects from the 25587 // partially completed, timed-out tree, too. 25588 var _progressedState = workInProgress.memoizedState; 25589 25590 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child; 25591 25592 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { 25593 _primaryChildFragment2.child = _progressedPrimaryChild; 25594 var _progressedChild2 = _progressedPrimaryChild; 25595 25596 while (_progressedChild2 !== null) { 25597 _progressedChild2.return = _primaryChildFragment2; 25598 _progressedChild2 = _progressedChild2.sibling; 25599 } 25600 } 25601 } // Because primaryChildFragment is a new fiber that we're inserting as the 25602 // parent of a new tree, we need to set its treeBaseDuration. 25603 25604 25605 if ( workInProgress.mode & ProfileMode) { 25606 // treeBaseDuration is the sum of all the child tree base durations. 25607 var _treeBaseDuration = 0; 25608 var _hiddenChild = _primaryChildFragment2.child; 25609 25610 while (_hiddenChild !== null) { 25611 _treeBaseDuration += _hiddenChild.treeBaseDuration; 25612 _hiddenChild = _hiddenChild.sibling; 25613 } 25614 25615 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; 25616 } // Clone the fallback child fragment, too. These we'll continue 25617 // working on. 25618 25619 25620 var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2); 25621 25622 _fallbackChildFragment2.return = workInProgress; 25623 _primaryChildFragment2.sibling = _fallbackChildFragment2; 25624 _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the 25625 // fallback children. 25626 25627 workInProgress.memoizedState = SUSPENDED_MARKER; 25628 workInProgress.child = _primaryChildFragment2; 25629 return _fallbackChildFragment2; 25630 } else { 25631 // No longer suspended. Switch back to showing the primary children, 25632 // and remove the intermediate fragment fiber. 25633 var _nextPrimaryChildren = nextProps.children; 25634 var currentPrimaryChild = currentPrimaryChildFragment.child; 25635 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback 25636 // children. Wait until the complete phase, after we've confirmed the 25637 // fallback is no longer needed. 25638 // TODO: Would it be better to store the fallback fragment on 25639 // the stateNode? 25640 // Continue rendering the children, like we normally do. 25641 25642 workInProgress.memoizedState = null; 25643 return workInProgress.child = primaryChild; 25644 } 25645 } else { 25646 // The current tree has not already timed out. That means the primary 25647 // children are not wrapped in a fragment fiber. 25648 var _currentPrimaryChild = current.child; 25649 25650 if (nextDidTimeout) { 25651 // Timed out. Wrap the children in a fragment fiber to keep them 25652 // separate from the fallback children. 25653 var _nextFallbackChildren3 = nextProps.fallback; 25654 25655 var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't 25656 // going to render this fragment. 25657 null, mode, NoWork, null); 25658 25659 _primaryChildFragment3.return = workInProgress; 25660 _primaryChildFragment3.child = _currentPrimaryChild; 25661 25662 if (_currentPrimaryChild !== null) { 25663 _currentPrimaryChild.return = _primaryChildFragment3; 25664 } // Even though we're creating a new fiber, there are no new children, 25665 // because we're reusing an already mounted tree. So we don't need to 25666 // schedule a placement. 25667 // primaryChildFragment.effectTag |= Placement; 25668 25669 25670 if ((workInProgress.mode & BlockingMode) === NoMode) { 25671 // Outside of blocking mode, we commit the effects from the 25672 // partially completed, timed-out tree, too. 25673 var _progressedState2 = workInProgress.memoizedState; 25674 25675 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child; 25676 25677 _primaryChildFragment3.child = _progressedPrimaryChild2; 25678 var _progressedChild3 = _progressedPrimaryChild2; 25679 25680 while (_progressedChild3 !== null) { 25681 _progressedChild3.return = _primaryChildFragment3; 25682 _progressedChild3 = _progressedChild3.sibling; 25683 } 25684 } // Because primaryChildFragment is a new fiber that we're inserting as the 25685 // parent of a new tree, we need to set its treeBaseDuration. 25686 25687 25688 if ( workInProgress.mode & ProfileMode) { 25689 // treeBaseDuration is the sum of all the child tree base durations. 25690 var _treeBaseDuration2 = 0; 25691 var _hiddenChild2 = _primaryChildFragment3.child; 25692 25693 while (_hiddenChild2 !== null) { 25694 _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; 25695 _hiddenChild2 = _hiddenChild2.sibling; 25696 } 25697 25698 _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; 25699 } // Create a fragment from the fallback children, too. 25700 25701 25702 var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null); 25703 25704 _fallbackChildFragment3.return = workInProgress; 25705 _primaryChildFragment3.sibling = _fallbackChildFragment3; 25706 _fallbackChildFragment3.effectTag |= Placement; 25707 _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the 25708 // fallback children. 25709 25710 workInProgress.memoizedState = SUSPENDED_MARKER; 25711 workInProgress.child = _primaryChildFragment3; 25712 return _fallbackChildFragment3; 25713 } else { 25714 // Still haven't timed out. Continue rendering the children, like we 25715 // normally do. 25716 workInProgress.memoizedState = null; 25717 var _nextPrimaryChildren2 = nextProps.children; 25718 return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime); 25719 } 25720 } 25721 } 25722} 25723 25724function scheduleWorkOnFiber(fiber, renderExpirationTime) { 25725 if (fiber.expirationTime < renderExpirationTime) { 25726 fiber.expirationTime = renderExpirationTime; 25727 } 25728 25729 var alternate = fiber.alternate; 25730 25731 if (alternate !== null && alternate.expirationTime < renderExpirationTime) { 25732 alternate.expirationTime = renderExpirationTime; 25733 } 25734 25735 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); 25736} 25737 25738function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) { 25739 // Mark any Suspense boundaries with fallbacks as having work to do. 25740 // If they were previously forced into fallbacks, they may now be able 25741 // to unblock. 25742 var node = firstChild; 25743 25744 while (node !== null) { 25745 if (node.tag === SuspenseComponent) { 25746 var state = node.memoizedState; 25747 25748 if (state !== null) { 25749 scheduleWorkOnFiber(node, renderExpirationTime); 25750 } 25751 } else if (node.tag === SuspenseListComponent) { 25752 // If the tail is hidden there might not be an Suspense boundaries 25753 // to schedule work on. In this case we have to schedule it on the 25754 // list itself. 25755 // We don't have to traverse to the children of the list since 25756 // the list will propagate the change when it rerenders. 25757 scheduleWorkOnFiber(node, renderExpirationTime); 25758 } else if (node.child !== null) { 25759 node.child.return = node; 25760 node = node.child; 25761 continue; 25762 } 25763 25764 if (node === workInProgress) { 25765 return; 25766 } 25767 25768 while (node.sibling === null) { 25769 if (node.return === null || node.return === workInProgress) { 25770 return; 25771 } 25772 25773 node = node.return; 25774 } 25775 25776 node.sibling.return = node.return; 25777 node = node.sibling; 25778 } 25779} 25780 25781function findLastContentRow(firstChild) { 25782 // This is going to find the last row among these children that is already 25783 // showing content on the screen, as opposed to being in fallback state or 25784 // new. If a row has multiple Suspense boundaries, any of them being in the 25785 // fallback state, counts as the whole row being in a fallback state. 25786 // Note that the "rows" will be workInProgress, but any nested children 25787 // will still be current since we haven't rendered them yet. The mounted 25788 // order may not be the same as the new order. We use the new order. 25789 var row = firstChild; 25790 var lastContentRow = null; 25791 25792 while (row !== null) { 25793 var currentRow = row.alternate; // New rows can't be content rows. 25794 25795 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 25796 lastContentRow = row; 25797 } 25798 25799 row = row.sibling; 25800 } 25801 25802 return lastContentRow; 25803} 25804 25805function validateRevealOrder(revealOrder) { 25806 { 25807 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) { 25808 didWarnAboutRevealOrder[revealOrder] = true; 25809 25810 if (typeof revealOrder === 'string') { 25811 switch (revealOrder.toLowerCase()) { 25812 case 'together': 25813 case 'forwards': 25814 case 'backwards': 25815 { 25816 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); 25817 25818 break; 25819 } 25820 25821 case 'forward': 25822 case 'backward': 25823 { 25824 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); 25825 25826 break; 25827 } 25828 25829 default: 25830 error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 25831 25832 break; 25833 } 25834 } else { 25835 error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 25836 } 25837 } 25838 } 25839} 25840 25841function validateTailOptions(tailMode, revealOrder) { 25842 { 25843 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { 25844 if (tailMode !== 'collapsed' && tailMode !== 'hidden') { 25845 didWarnAboutTailOptions[tailMode] = true; 25846 25847 error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode); 25848 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') { 25849 didWarnAboutTailOptions[tailMode] = true; 25850 25851 error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode); 25852 } 25853 } 25854 } 25855} 25856 25857function validateSuspenseListNestedChild(childSlot, index) { 25858 { 25859 var isArray = Array.isArray(childSlot); 25860 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function'; 25861 25862 if (isArray || isIterable) { 25863 var type = isArray ? 'array' : 'iterable'; 25864 25865 error('A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type); 25866 25867 return false; 25868 } 25869 } 25870 25871 return true; 25872} 25873 25874function validateSuspenseListChildren(children, revealOrder) { 25875 { 25876 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) { 25877 if (Array.isArray(children)) { 25878 for (var i = 0; i < children.length; i++) { 25879 if (!validateSuspenseListNestedChild(children[i], i)) { 25880 return; 25881 } 25882 } 25883 } else { 25884 var iteratorFn = getIteratorFn(children); 25885 25886 if (typeof iteratorFn === 'function') { 25887 var childrenIterator = iteratorFn.call(children); 25888 25889 if (childrenIterator) { 25890 var step = childrenIterator.next(); 25891 var _i = 0; 25892 25893 for (; !step.done; step = childrenIterator.next()) { 25894 if (!validateSuspenseListNestedChild(step.value, _i)) { 25895 return; 25896 } 25897 25898 _i++; 25899 } 25900 } 25901 } else { 25902 error('A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder); 25903 } 25904 } 25905 } 25906 } 25907} 25908 25909function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) { 25910 var renderState = workInProgress.memoizedState; 25911 25912 if (renderState === null) { 25913 workInProgress.memoizedState = { 25914 isBackwards: isBackwards, 25915 rendering: null, 25916 renderingStartTime: 0, 25917 last: lastContentRow, 25918 tail: tail, 25919 tailExpiration: 0, 25920 tailMode: tailMode, 25921 lastEffect: lastEffectBeforeRendering 25922 }; 25923 } else { 25924 // We can reuse the existing object from previous renders. 25925 renderState.isBackwards = isBackwards; 25926 renderState.rendering = null; 25927 renderState.renderingStartTime = 0; 25928 renderState.last = lastContentRow; 25929 renderState.tail = tail; 25930 renderState.tailExpiration = 0; 25931 renderState.tailMode = tailMode; 25932 renderState.lastEffect = lastEffectBeforeRendering; 25933 } 25934} // This can end up rendering this component multiple passes. 25935// The first pass splits the children fibers into two sets. A head and tail. 25936// We first render the head. If anything is in fallback state, we do another 25937// pass through beginWork to rerender all children (including the tail) with 25938// the force suspend context. If the first render didn't have anything in 25939// in fallback state. Then we render each row in the tail one-by-one. 25940// That happens in the completeWork phase without going back to beginWork. 25941 25942 25943function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) { 25944 var nextProps = workInProgress.pendingProps; 25945 var revealOrder = nextProps.revealOrder; 25946 var tailMode = nextProps.tail; 25947 var newChildren = nextProps.children; 25948 validateRevealOrder(revealOrder); 25949 validateTailOptions(tailMode, revealOrder); 25950 validateSuspenseListChildren(newChildren, revealOrder); 25951 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 25952 var suspenseContext = suspenseStackCursor.current; 25953 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 25954 25955 if (shouldForceFallback) { 25956 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 25957 workInProgress.effectTag |= DidCapture; 25958 } else { 25959 var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect; 25960 25961 if (didSuspendBefore) { 25962 // If we previously forced a fallback, we need to schedule work 25963 // on any nested boundaries to let them know to try to render 25964 // again. This is the same as context updating. 25965 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime); 25966 } 25967 25968 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 25969 } 25970 25971 pushSuspenseContext(workInProgress, suspenseContext); 25972 25973 if ((workInProgress.mode & BlockingMode) === NoMode) { 25974 // Outside of blocking mode, SuspenseList doesn't work so we just 25975 // use make it a noop by treating it as the default revealOrder. 25976 workInProgress.memoizedState = null; 25977 } else { 25978 switch (revealOrder) { 25979 case 'forwards': 25980 { 25981 var lastContentRow = findLastContentRow(workInProgress.child); 25982 var tail; 25983 25984 if (lastContentRow === null) { 25985 // The whole list is part of the tail. 25986 // TODO: We could fast path by just rendering the tail now. 25987 tail = workInProgress.child; 25988 workInProgress.child = null; 25989 } else { 25990 // Disconnect the tail rows after the content row. 25991 // We're going to render them separately later. 25992 tail = lastContentRow.sibling; 25993 lastContentRow.sibling = null; 25994 } 25995 25996 initSuspenseListRenderState(workInProgress, false, // isBackwards 25997 tail, lastContentRow, tailMode, workInProgress.lastEffect); 25998 break; 25999 } 26000 26001 case 'backwards': 26002 { 26003 // We're going to find the first row that has existing content. 26004 // At the same time we're going to reverse the list of everything 26005 // we pass in the meantime. That's going to be our tail in reverse 26006 // order. 26007 var _tail = null; 26008 var row = workInProgress.child; 26009 workInProgress.child = null; 26010 26011 while (row !== null) { 26012 var currentRow = row.alternate; // New rows can't be content rows. 26013 26014 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 26015 // This is the beginning of the main content. 26016 workInProgress.child = row; 26017 break; 26018 } 26019 26020 var nextRow = row.sibling; 26021 row.sibling = _tail; 26022 _tail = row; 26023 row = nextRow; 26024 } // TODO: If workInProgress.child is null, we can continue on the tail immediately. 26025 26026 26027 initSuspenseListRenderState(workInProgress, true, // isBackwards 26028 _tail, null, // last 26029 tailMode, workInProgress.lastEffect); 26030 break; 26031 } 26032 26033 case 'together': 26034 { 26035 initSuspenseListRenderState(workInProgress, false, // isBackwards 26036 null, // tail 26037 null, // last 26038 undefined, workInProgress.lastEffect); 26039 break; 26040 } 26041 26042 default: 26043 { 26044 // The default reveal order is the same as not having 26045 // a boundary. 26046 workInProgress.memoizedState = null; 26047 } 26048 } 26049 } 26050 26051 return workInProgress.child; 26052} 26053 26054function updatePortalComponent(current, workInProgress, renderExpirationTime) { 26055 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 26056 var nextChildren = workInProgress.pendingProps; 26057 26058 if (current === null) { 26059 // Portals are special because we don't append the children during mount 26060 // but at commit. Therefore we need to track insertions which the normal 26061 // flow doesn't do during mount. This doesn't happen at the root because 26062 // the root always starts with a "current" with a null child. 26063 // TODO: Consider unifying this with how the root works. 26064 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 26065 } else { 26066 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 26067 } 26068 26069 return workInProgress.child; 26070} 26071 26072function updateContextProvider(current, workInProgress, renderExpirationTime) { 26073 var providerType = workInProgress.type; 26074 var context = providerType._context; 26075 var newProps = workInProgress.pendingProps; 26076 var oldProps = workInProgress.memoizedProps; 26077 var newValue = newProps.value; 26078 26079 { 26080 var providerPropTypes = workInProgress.type.propTypes; 26081 26082 if (providerPropTypes) { 26083 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev); 26084 } 26085 } 26086 26087 pushProvider(workInProgress, newValue); 26088 26089 if (oldProps !== null) { 26090 var oldValue = oldProps.value; 26091 var changedBits = calculateChangedBits(context, newValue, oldValue); 26092 26093 if (changedBits === 0) { 26094 // No change. Bailout early if children are the same. 26095 if (oldProps.children === newProps.children && !hasContextChanged()) { 26096 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 26097 } 26098 } else { 26099 // The context value changed. Search for matching consumers and schedule 26100 // them to update. 26101 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime); 26102 } 26103 } 26104 26105 var newChildren = newProps.children; 26106 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 26107 return workInProgress.child; 26108} 26109 26110var hasWarnedAboutUsingContextAsConsumer = false; 26111 26112function updateContextConsumer(current, workInProgress, renderExpirationTime) { 26113 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In 26114 // DEV mode, we create a separate object for Context.Consumer that acts 26115 // like a proxy to Context. This proxy object adds unnecessary code in PROD 26116 // so we use the old behaviour (Context.Consumer references Context) to 26117 // reduce size and overhead. The separate object references context via 26118 // a property called "_context", which also gives us the ability to check 26119 // in DEV mode if this property exists or not and warn if it does not. 26120 26121 { 26122 if (context._context === undefined) { 26123 // This may be because it's a Context (rather than a Consumer). 26124 // Or it may be because it's older React where they're the same thing. 26125 // We only want to warn if we're sure it's a new React. 26126 if (context !== context.Consumer) { 26127 if (!hasWarnedAboutUsingContextAsConsumer) { 26128 hasWarnedAboutUsingContextAsConsumer = true; 26129 26130 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 26131 } 26132 } 26133 } else { 26134 context = context._context; 26135 } 26136 } 26137 26138 var newProps = workInProgress.pendingProps; 26139 var render = newProps.children; 26140 26141 { 26142 if (typeof render !== 'function') { 26143 error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.'); 26144 } 26145 } 26146 26147 prepareToReadContext(workInProgress, renderExpirationTime); 26148 var newValue = readContext(context, newProps.unstable_observedBits); 26149 var newChildren; 26150 26151 { 26152 ReactCurrentOwner$1.current = workInProgress; 26153 setIsRendering(true); 26154 newChildren = render(newValue); 26155 setIsRendering(false); 26156 } // React DevTools reads this flag. 26157 26158 26159 workInProgress.effectTag |= PerformedWork; 26160 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 26161 return workInProgress.child; 26162} 26163 26164function markWorkInProgressReceivedUpdate() { 26165 didReceiveUpdate = true; 26166} 26167 26168function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) { 26169 cancelWorkTimer(workInProgress); 26170 26171 if (current !== null) { 26172 // Reuse previous dependencies 26173 workInProgress.dependencies = current.dependencies; 26174 } 26175 26176 { 26177 // Don't update "base" render times for bailouts. 26178 stopProfilerTimerIfRunning(); 26179 } 26180 26181 var updateExpirationTime = workInProgress.expirationTime; 26182 26183 if (updateExpirationTime !== NoWork) { 26184 markUnprocessedUpdateTime(updateExpirationTime); 26185 } // Check if the children have any pending work. 26186 26187 26188 var childExpirationTime = workInProgress.childExpirationTime; 26189 26190 if (childExpirationTime < renderExpirationTime) { 26191 // The children don't have any work either. We can skip them. 26192 // TODO: Once we add back resuming, we should check if the children are 26193 // a work-in-progress set. If so, we need to transfer their effects. 26194 return null; 26195 } else { 26196 // This fiber doesn't have work, but its subtree does. Clone the child 26197 // fibers and continue. 26198 cloneChildFibers(current, workInProgress); 26199 return workInProgress.child; 26200 } 26201} 26202 26203function remountFiber(current, oldWorkInProgress, newWorkInProgress) { 26204 { 26205 var returnFiber = oldWorkInProgress.return; 26206 26207 if (returnFiber === null) { 26208 throw new Error('Cannot swap the root fiber.'); 26209 } // Disconnect from the old current. 26210 // It will get deleted. 26211 26212 26213 current.alternate = null; 26214 oldWorkInProgress.alternate = null; // Connect to the new tree. 26215 26216 newWorkInProgress.index = oldWorkInProgress.index; 26217 newWorkInProgress.sibling = oldWorkInProgress.sibling; 26218 newWorkInProgress.return = oldWorkInProgress.return; 26219 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. 26220 26221 if (oldWorkInProgress === returnFiber.child) { 26222 returnFiber.child = newWorkInProgress; 26223 } else { 26224 var prevSibling = returnFiber.child; 26225 26226 if (prevSibling === null) { 26227 throw new Error('Expected parent to have a child.'); 26228 } 26229 26230 while (prevSibling.sibling !== oldWorkInProgress) { 26231 prevSibling = prevSibling.sibling; 26232 26233 if (prevSibling === null) { 26234 throw new Error('Expected to find the previous sibling.'); 26235 } 26236 } 26237 26238 prevSibling.sibling = newWorkInProgress; 26239 } // Delete the old fiber and place the new one. 26240 // Since the old fiber is disconnected, we have to schedule it manually. 26241 26242 26243 var last = returnFiber.lastEffect; 26244 26245 if (last !== null) { 26246 last.nextEffect = current; 26247 returnFiber.lastEffect = current; 26248 } else { 26249 returnFiber.firstEffect = returnFiber.lastEffect = current; 26250 } 26251 26252 current.nextEffect = null; 26253 current.effectTag = Deletion; 26254 newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. 26255 26256 return newWorkInProgress; 26257 } 26258} 26259 26260function beginWork(current, workInProgress, renderExpirationTime) { 26261 var updateExpirationTime = workInProgress.expirationTime; 26262 26263 { 26264 if (workInProgress._debugNeedsRemount && current !== null) { 26265 // This will restart the begin phase with a new fiber. 26266 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime)); 26267 } 26268 } 26269 26270 if (current !== null) { 26271 var oldProps = current.memoizedProps; 26272 var newProps = workInProgress.pendingProps; 26273 26274 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload: 26275 workInProgress.type !== current.type )) { 26276 // If props or context changed, mark the fiber as having performed work. 26277 // This may be unset if the props are determined to be equal later (memo). 26278 didReceiveUpdate = true; 26279 } else if (updateExpirationTime < renderExpirationTime) { 26280 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering 26281 // the begin phase. There's still some bookkeeping we that needs to be done 26282 // in this optimized path, mostly pushing stuff onto the stack. 26283 26284 switch (workInProgress.tag) { 26285 case HostRoot: 26286 pushHostRootContext(workInProgress); 26287 resetHydrationState(); 26288 break; 26289 26290 case HostComponent: 26291 pushHostContext(workInProgress); 26292 26293 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) { 26294 { 26295 markSpawnedWork(Never); 26296 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 26297 26298 26299 workInProgress.expirationTime = workInProgress.childExpirationTime = Never; 26300 return null; 26301 } 26302 26303 break; 26304 26305 case ClassComponent: 26306 { 26307 var Component = workInProgress.type; 26308 26309 if (isContextProvider(Component)) { 26310 pushContextProvider(workInProgress); 26311 } 26312 26313 break; 26314 } 26315 26316 case HostPortal: 26317 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 26318 break; 26319 26320 case ContextProvider: 26321 { 26322 var newValue = workInProgress.memoizedProps.value; 26323 pushProvider(workInProgress, newValue); 26324 break; 26325 } 26326 26327 case Profiler: 26328 { 26329 // Profiler should only call onRender when one of its descendants actually rendered. 26330 var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime; 26331 26332 if (hasChildWork) { 26333 workInProgress.effectTag |= Update; 26334 } 26335 } 26336 26337 break; 26338 26339 case SuspenseComponent: 26340 { 26341 var state = workInProgress.memoizedState; 26342 26343 if (state !== null) { 26344 // whether to retry the primary children, or to skip over it and 26345 // go straight to the fallback. Check the priority of the primary 26346 // child fragment. 26347 26348 26349 var primaryChildFragment = workInProgress.child; 26350 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime; 26351 26352 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) { 26353 // The primary children have pending work. Use the normal path 26354 // to attempt to render the primary children again. 26355 return updateSuspenseComponent(current, workInProgress, renderExpirationTime); 26356 } else { 26357 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient 26358 // priority. Bailout. 26359 26360 var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 26361 26362 if (child !== null) { 26363 // The fallback children have pending work. Skip over the 26364 // primary children and work on the fallback. 26365 return child.sibling; 26366 } else { 26367 return null; 26368 } 26369 } 26370 } else { 26371 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); 26372 } 26373 26374 break; 26375 } 26376 26377 case SuspenseListComponent: 26378 { 26379 var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; 26380 26381 var _hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime; 26382 26383 if (didSuspendBefore) { 26384 if (_hasChildWork) { 26385 // If something was in fallback state last time, and we have all the 26386 // same children then we're still in progressive loading state. 26387 // Something might get unblocked by state updates or retries in the 26388 // tree which will affect the tail. So we need to use the normal 26389 // path to compute the correct tail. 26390 return updateSuspenseListComponent(current, workInProgress, renderExpirationTime); 26391 } // If none of the children had any work, that means that none of 26392 // them got retried so they'll still be blocked in the same way 26393 // as before. We can fast bail out. 26394 26395 26396 workInProgress.effectTag |= DidCapture; 26397 } // If nothing suspended before and we're rendering the same children, 26398 // then the tail doesn't matter. Anything new that suspends will work 26399 // in the "together" mode, so we can continue from the state we had. 26400 26401 26402 var renderState = workInProgress.memoizedState; 26403 26404 if (renderState !== null) { 26405 // Reset to the "together" mode in case we've started a different 26406 // update in the past but didn't complete it. 26407 renderState.rendering = null; 26408 renderState.tail = null; 26409 } 26410 26411 pushSuspenseContext(workInProgress, suspenseStackCursor.current); 26412 26413 if (_hasChildWork) { 26414 break; 26415 } else { 26416 // If none of the children had any work, that means that none of 26417 // them got retried so they'll still be blocked in the same way 26418 // as before. We can fast bail out. 26419 return null; 26420 } 26421 } 26422 } 26423 26424 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 26425 } else { 26426 // An update was scheduled on this fiber, but there are no new props 26427 // nor legacy context. Set this to false. If an update queue or context 26428 // consumer produces a changed value, it will set this to true. Otherwise, 26429 // the component will assume the children have not changed and bail out. 26430 didReceiveUpdate = false; 26431 } 26432 } else { 26433 didReceiveUpdate = false; 26434 } // Before entering the begin phase, clear pending update priority. 26435 // TODO: This assumes that we're about to evaluate the component and process 26436 // the update queue. However, there's an exception: SimpleMemoComponent 26437 // sometimes bails out later in the begin phase. This indicates that we should 26438 // move this assignment out of the common path and into each branch. 26439 26440 26441 workInProgress.expirationTime = NoWork; 26442 26443 switch (workInProgress.tag) { 26444 case IndeterminateComponent: 26445 { 26446 return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderExpirationTime); 26447 } 26448 26449 case LazyComponent: 26450 { 26451 var elementType = workInProgress.elementType; 26452 return mountLazyComponent(current, workInProgress, elementType, updateExpirationTime, renderExpirationTime); 26453 } 26454 26455 case FunctionComponent: 26456 { 26457 var _Component = workInProgress.type; 26458 var unresolvedProps = workInProgress.pendingProps; 26459 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps); 26460 return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime); 26461 } 26462 26463 case ClassComponent: 26464 { 26465 var _Component2 = workInProgress.type; 26466 var _unresolvedProps = workInProgress.pendingProps; 26467 26468 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps); 26469 26470 return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime); 26471 } 26472 26473 case HostRoot: 26474 return updateHostRoot(current, workInProgress, renderExpirationTime); 26475 26476 case HostComponent: 26477 return updateHostComponent(current, workInProgress, renderExpirationTime); 26478 26479 case HostText: 26480 return updateHostText(current, workInProgress); 26481 26482 case SuspenseComponent: 26483 return updateSuspenseComponent(current, workInProgress, renderExpirationTime); 26484 26485 case HostPortal: 26486 return updatePortalComponent(current, workInProgress, renderExpirationTime); 26487 26488 case ForwardRef: 26489 { 26490 var type = workInProgress.type; 26491 var _unresolvedProps2 = workInProgress.pendingProps; 26492 26493 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); 26494 26495 return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime); 26496 } 26497 26498 case Fragment: 26499 return updateFragment(current, workInProgress, renderExpirationTime); 26500 26501 case Mode: 26502 return updateMode(current, workInProgress, renderExpirationTime); 26503 26504 case Profiler: 26505 return updateProfiler(current, workInProgress, renderExpirationTime); 26506 26507 case ContextProvider: 26508 return updateContextProvider(current, workInProgress, renderExpirationTime); 26509 26510 case ContextConsumer: 26511 return updateContextConsumer(current, workInProgress, renderExpirationTime); 26512 26513 case MemoComponent: 26514 { 26515 var _type2 = workInProgress.type; 26516 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props. 26517 26518 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); 26519 26520 { 26521 if (workInProgress.type !== workInProgress.elementType) { 26522 var outerPropTypes = _type2.propTypes; 26523 26524 if (outerPropTypes) { 26525 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only 26526 'prop', getComponentName(_type2), getCurrentFiberStackInDev); 26527 } 26528 } 26529 } 26530 26531 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); 26532 return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime); 26533 } 26534 26535 case SimpleMemoComponent: 26536 { 26537 return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime); 26538 } 26539 26540 case IncompleteClassComponent: 26541 { 26542 var _Component3 = workInProgress.type; 26543 var _unresolvedProps4 = workInProgress.pendingProps; 26544 26545 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4); 26546 26547 return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime); 26548 } 26549 26550 case SuspenseListComponent: 26551 { 26552 return updateSuspenseListComponent(current, workInProgress, renderExpirationTime); 26553 } 26554 } 26555 26556 { 26557 { 26558 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 26559 } 26560 } 26561} 26562 26563function markUpdate(workInProgress) { 26564 // Tag the fiber with an update effect. This turns a Placement into 26565 // a PlacementAndUpdate. 26566 workInProgress.effectTag |= Update; 26567} 26568 26569function markRef$1(workInProgress) { 26570 workInProgress.effectTag |= Ref; 26571} 26572 26573var appendAllChildren; 26574var updateHostContainer; 26575var updateHostComponent$1; 26576var updateHostText$1; 26577 26578{ 26579 // Mutation mode 26580 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) { 26581 // We only have the top Fiber that was created but we need recurse down its 26582 // children to find all the terminal nodes. 26583 var node = workInProgress.child; 26584 26585 while (node !== null) { 26586 if (node.tag === HostComponent || node.tag === HostText) { 26587 appendInitialChild(parent, node.stateNode); 26588 } else if (node.tag === HostPortal) ; else if (node.child !== null) { 26589 node.child.return = node; 26590 node = node.child; 26591 continue; 26592 } 26593 26594 if (node === workInProgress) { 26595 return; 26596 } 26597 26598 while (node.sibling === null) { 26599 if (node.return === null || node.return === workInProgress) { 26600 return; 26601 } 26602 26603 node = node.return; 26604 } 26605 26606 node.sibling.return = node.return; 26607 node = node.sibling; 26608 } 26609 }; 26610 26611 updateHostContainer = function (workInProgress) {// Noop 26612 }; 26613 26614 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) { 26615 // If we have an alternate, that means this is an update and we need to 26616 // schedule a side-effect to do the updates. 26617 var oldProps = current.memoizedProps; 26618 26619 if (oldProps === newProps) { 26620 // In mutation mode, this is sufficient for a bailout because 26621 // we won't touch this node even if children changed. 26622 return; 26623 } // If we get updated because one of our children updated, we don't 26624 // have newProps so we'll have to reuse them. 26625 // TODO: Split the update API as separate for the props vs. children. 26626 // Even better would be if children weren't special cased at all tho. 26627 26628 26629 var instance = workInProgress.stateNode; 26630 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host 26631 // component is hitting the resume path. Figure out why. Possibly 26632 // related to `hidden`. 26633 26634 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component. 26635 26636 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 26637 // is a new ref we mark this as an update. All the work is done in commitWork. 26638 26639 if (updatePayload) { 26640 markUpdate(workInProgress); 26641 } 26642 }; 26643 26644 updateHostText$1 = function (current, workInProgress, oldText, newText) { 26645 // If the text differs, mark it as an update. All the work in done in commitWork. 26646 if (oldText !== newText) { 26647 markUpdate(workInProgress); 26648 } 26649 }; 26650} 26651 26652function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { 26653 switch (renderState.tailMode) { 26654 case 'hidden': 26655 { 26656 // Any insertions at the end of the tail list after this point 26657 // should be invisible. If there are already mounted boundaries 26658 // anything before them are not considered for collapsing. 26659 // Therefore we need to go through the whole tail to find if 26660 // there are any. 26661 var tailNode = renderState.tail; 26662 var lastTailNode = null; 26663 26664 while (tailNode !== null) { 26665 if (tailNode.alternate !== null) { 26666 lastTailNode = tailNode; 26667 } 26668 26669 tailNode = tailNode.sibling; 26670 } // Next we're simply going to delete all insertions after the 26671 // last rendered item. 26672 26673 26674 if (lastTailNode === null) { 26675 // All remaining items in the tail are insertions. 26676 renderState.tail = null; 26677 } else { 26678 // Detach the insertion after the last node that was already 26679 // inserted. 26680 lastTailNode.sibling = null; 26681 } 26682 26683 break; 26684 } 26685 26686 case 'collapsed': 26687 { 26688 // Any insertions at the end of the tail list after this point 26689 // should be invisible. If there are already mounted boundaries 26690 // anything before them are not considered for collapsing. 26691 // Therefore we need to go through the whole tail to find if 26692 // there are any. 26693 var _tailNode = renderState.tail; 26694 var _lastTailNode = null; 26695 26696 while (_tailNode !== null) { 26697 if (_tailNode.alternate !== null) { 26698 _lastTailNode = _tailNode; 26699 } 26700 26701 _tailNode = _tailNode.sibling; 26702 } // Next we're simply going to delete all insertions after the 26703 // last rendered item. 26704 26705 26706 if (_lastTailNode === null) { 26707 // All remaining items in the tail are insertions. 26708 if (!hasRenderedATailFallback && renderState.tail !== null) { 26709 // We suspended during the head. We want to show at least one 26710 // row at the tail. So we'll keep on and cut off the rest. 26711 renderState.tail.sibling = null; 26712 } else { 26713 renderState.tail = null; 26714 } 26715 } else { 26716 // Detach the insertion after the last node that was already 26717 // inserted. 26718 _lastTailNode.sibling = null; 26719 } 26720 26721 break; 26722 } 26723 } 26724} 26725 26726function completeWork(current, workInProgress, renderExpirationTime) { 26727 var newProps = workInProgress.pendingProps; 26728 26729 switch (workInProgress.tag) { 26730 case IndeterminateComponent: 26731 case LazyComponent: 26732 case SimpleMemoComponent: 26733 case FunctionComponent: 26734 case ForwardRef: 26735 case Fragment: 26736 case Mode: 26737 case Profiler: 26738 case ContextConsumer: 26739 case MemoComponent: 26740 return null; 26741 26742 case ClassComponent: 26743 { 26744 var Component = workInProgress.type; 26745 26746 if (isContextProvider(Component)) { 26747 popContext(workInProgress); 26748 } 26749 26750 return null; 26751 } 26752 26753 case HostRoot: 26754 { 26755 popHostContainer(workInProgress); 26756 popTopLevelContextObject(workInProgress); 26757 var fiberRoot = workInProgress.stateNode; 26758 26759 if (fiberRoot.pendingContext) { 26760 fiberRoot.context = fiberRoot.pendingContext; 26761 fiberRoot.pendingContext = null; 26762 } 26763 26764 if (current === null || current.child === null) { 26765 // If we hydrated, pop so that we can delete any remaining children 26766 // that weren't hydrated. 26767 var wasHydrated = popHydrationState(workInProgress); 26768 26769 if (wasHydrated) { 26770 // If we hydrated, then we'll need to schedule an update for 26771 // the commit side-effects on the root. 26772 markUpdate(workInProgress); 26773 } 26774 } 26775 26776 updateHostContainer(workInProgress); 26777 return null; 26778 } 26779 26780 case HostComponent: 26781 { 26782 popHostContext(workInProgress); 26783 var rootContainerInstance = getRootHostContainer(); 26784 var type = workInProgress.type; 26785 26786 if (current !== null && workInProgress.stateNode != null) { 26787 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance); 26788 26789 if (current.ref !== workInProgress.ref) { 26790 markRef$1(workInProgress); 26791 } 26792 } else { 26793 if (!newProps) { 26794 if (!(workInProgress.stateNode !== null)) { 26795 { 26796 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 26797 } 26798 } // This can happen when we abort work. 26799 26800 26801 return null; 26802 } 26803 26804 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context 26805 // "stack" as the parent. Then append children as we go in beginWork 26806 // or completeWork depending on whether we want to add them top->down or 26807 // bottom->up. Top->down is faster in IE11. 26808 26809 var _wasHydrated = popHydrationState(workInProgress); 26810 26811 if (_wasHydrated) { 26812 // TODO: Move this and createInstance step into the beginPhase 26813 // to consolidate. 26814 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { 26815 // If changes to the hydrated node need to be applied at the 26816 // commit-phase we mark this as such. 26817 markUpdate(workInProgress); 26818 } 26819 } else { 26820 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); 26821 appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners 26822 26823 workInProgress.stateNode = instance; 26824 // (eg DOM renderer supports auto-focus for certain elements). 26825 // Make sure such renderers get scheduled for later work. 26826 26827 26828 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { 26829 markUpdate(workInProgress); 26830 } 26831 } 26832 26833 if (workInProgress.ref !== null) { 26834 // If there is a ref on a host node we need to schedule a callback 26835 markRef$1(workInProgress); 26836 } 26837 } 26838 26839 return null; 26840 } 26841 26842 case HostText: 26843 { 26844 var newText = newProps; 26845 26846 if (current && workInProgress.stateNode != null) { 26847 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need 26848 // to schedule a side-effect to do the updates. 26849 26850 updateHostText$1(current, workInProgress, oldText, newText); 26851 } else { 26852 if (typeof newText !== 'string') { 26853 if (!(workInProgress.stateNode !== null)) { 26854 { 26855 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 26856 } 26857 } // This can happen when we abort work. 26858 26859 } 26860 26861 var _rootContainerInstance = getRootHostContainer(); 26862 26863 var _currentHostContext = getHostContext(); 26864 26865 var _wasHydrated2 = popHydrationState(workInProgress); 26866 26867 if (_wasHydrated2) { 26868 if (prepareToHydrateHostTextInstance(workInProgress)) { 26869 markUpdate(workInProgress); 26870 } 26871 } else { 26872 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress); 26873 } 26874 } 26875 26876 return null; 26877 } 26878 26879 case SuspenseComponent: 26880 { 26881 popSuspenseContext(workInProgress); 26882 var nextState = workInProgress.memoizedState; 26883 26884 if ((workInProgress.effectTag & DidCapture) !== NoEffect) { 26885 // Something suspended. Re-render with the fallback children. 26886 workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. 26887 26888 return workInProgress; 26889 } 26890 26891 var nextDidTimeout = nextState !== null; 26892 var prevDidTimeout = false; 26893 26894 if (current === null) { 26895 if (workInProgress.memoizedProps.fallback !== undefined) { 26896 popHydrationState(workInProgress); 26897 } 26898 } else { 26899 var prevState = current.memoizedState; 26900 prevDidTimeout = prevState !== null; 26901 26902 if (!nextDidTimeout && prevState !== null) { 26903 // We just switched from the fallback to the normal children. 26904 // Delete the fallback. 26905 // TODO: Would it be better to store the fallback fragment on 26906 // the stateNode during the begin phase? 26907 var currentFallbackChild = current.child.sibling; 26908 26909 if (currentFallbackChild !== null) { 26910 // Deletions go at the beginning of the return fiber's effect list 26911 var first = workInProgress.firstEffect; 26912 26913 if (first !== null) { 26914 workInProgress.firstEffect = currentFallbackChild; 26915 currentFallbackChild.nextEffect = first; 26916 } else { 26917 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; 26918 currentFallbackChild.nextEffect = null; 26919 } 26920 26921 currentFallbackChild.effectTag = Deletion; 26922 } 26923 } 26924 } 26925 26926 if (nextDidTimeout && !prevDidTimeout) { 26927 // If this subtreee is running in blocking mode we can suspend, 26928 // otherwise we won't suspend. 26929 // TODO: This will still suspend a synchronous tree if anything 26930 // in the concurrent tree already suspended during this render. 26931 // This is a known bug. 26932 if ((workInProgress.mode & BlockingMode) !== NoMode) { 26933 // TODO: Move this back to throwException because this is too late 26934 // if this is a large tree which is common for initial loads. We 26935 // don't know if we should restart a render or not until we get 26936 // this marker, and this is too late. 26937 // If this render already had a ping or lower pri updates, 26938 // and this is the first time we know we're going to suspend we 26939 // should be able to immediately restart from within throwException. 26940 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true; 26941 26942 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) { 26943 // If this was in an invisible tree or a new render, then showing 26944 // this boundary is ok. 26945 renderDidSuspend(); 26946 } else { 26947 // Otherwise, we're going to have to hide content so we should 26948 // suspend for longer if possible. 26949 renderDidSuspendDelayIfPossible(); 26950 } 26951 } 26952 } 26953 26954 { 26955 // TODO: Only schedule updates if these values are non equal, i.e. it changed. 26956 if (nextDidTimeout || prevDidTimeout) { 26957 // If this boundary just timed out, schedule an effect to attach a 26958 // retry listener to the promise. This flag is also used to hide the 26959 // primary children. In mutation mode, we also need the flag to 26960 // *unhide* children that were previously hidden, so check if this 26961 // is currently timed out, too. 26962 workInProgress.effectTag |= Update; 26963 } 26964 } 26965 26966 return null; 26967 } 26968 26969 case HostPortal: 26970 popHostContainer(workInProgress); 26971 updateHostContainer(workInProgress); 26972 return null; 26973 26974 case ContextProvider: 26975 // Pop provider fiber 26976 popProvider(workInProgress); 26977 return null; 26978 26979 case IncompleteClassComponent: 26980 { 26981 // Same as class component case. I put it down here so that the tags are 26982 // sequential to ensure this switch is compiled to a jump table. 26983 var _Component = workInProgress.type; 26984 26985 if (isContextProvider(_Component)) { 26986 popContext(workInProgress); 26987 } 26988 26989 return null; 26990 } 26991 26992 case SuspenseListComponent: 26993 { 26994 popSuspenseContext(workInProgress); 26995 var renderState = workInProgress.memoizedState; 26996 26997 if (renderState === null) { 26998 // We're running in the default, "independent" mode. 26999 // We don't do anything in this mode. 27000 return null; 27001 } 27002 27003 var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect; 27004 var renderedTail = renderState.rendering; 27005 27006 if (renderedTail === null) { 27007 // We just rendered the head. 27008 if (!didSuspendAlready) { 27009 // This is the first pass. We need to figure out if anything is still 27010 // suspended in the rendered set. 27011 // If new content unsuspended, but there's still some content that 27012 // didn't. Then we need to do a second pass that forces everything 27013 // to keep showing their fallbacks. 27014 // We might be suspended if something in this render pass suspended, or 27015 // something in the previous committed pass suspended. Otherwise, 27016 // there's no chance so we can skip the expensive call to 27017 // findFirstSuspended. 27018 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect); 27019 27020 if (!cannotBeSuspended) { 27021 var row = workInProgress.child; 27022 27023 while (row !== null) { 27024 var suspended = findFirstSuspended(row); 27025 27026 if (suspended !== null) { 27027 didSuspendAlready = true; 27028 workInProgress.effectTag |= DidCapture; 27029 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as 27030 // part of the second pass. In that case nothing will subscribe to 27031 // its thennables. Instead, we'll transfer its thennables to the 27032 // SuspenseList so that it can retry if they resolve. 27033 // There might be multiple of these in the list but since we're 27034 // going to wait for all of them anyway, it doesn't really matter 27035 // which ones gets to ping. In theory we could get clever and keep 27036 // track of how many dependencies remain but it gets tricky because 27037 // in the meantime, we can add/remove/change items and dependencies. 27038 // We might bail out of the loop before finding any but that 27039 // doesn't matter since that means that the other boundaries that 27040 // we did find already has their listeners attached. 27041 27042 var newThennables = suspended.updateQueue; 27043 27044 if (newThennables !== null) { 27045 workInProgress.updateQueue = newThennables; 27046 workInProgress.effectTag |= Update; 27047 } // Rerender the whole list, but this time, we'll force fallbacks 27048 // to stay in place. 27049 // Reset the effect list before doing the second pass since that's now invalid. 27050 27051 27052 if (renderState.lastEffect === null) { 27053 workInProgress.firstEffect = null; 27054 } 27055 27056 workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. 27057 27058 resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately 27059 // rerender the children. 27060 27061 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); 27062 return workInProgress.child; 27063 } 27064 27065 row = row.sibling; 27066 } 27067 } 27068 } else { 27069 cutOffTailIfNeeded(renderState, false); 27070 } // Next we're going to render the tail. 27071 27072 } else { 27073 // Append the rendered row to the child list. 27074 if (!didSuspendAlready) { 27075 var _suspended = findFirstSuspended(renderedTail); 27076 27077 if (_suspended !== null) { 27078 workInProgress.effectTag |= DidCapture; 27079 didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't 27080 // get lost if this row ends up dropped during a second pass. 27081 27082 var _newThennables = _suspended.updateQueue; 27083 27084 if (_newThennables !== null) { 27085 workInProgress.updateQueue = _newThennables; 27086 workInProgress.effectTag |= Update; 27087 } 27088 27089 cutOffTailIfNeeded(renderState, true); // This might have been modified. 27090 27091 if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate) { 27092 // We need to delete the row we just rendered. 27093 // Reset the effect list to what it was before we rendered this 27094 // child. The nested children have already appended themselves. 27095 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point. 27096 27097 if (lastEffect !== null) { 27098 lastEffect.nextEffect = null; 27099 } // We're done. 27100 27101 27102 return null; 27103 } 27104 } else if ( // The time it took to render last row is greater than time until 27105 // the expiration. 27106 now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && renderExpirationTime > Never) { 27107 // We have now passed our CPU deadline and we'll just give up further 27108 // attempts to render the main content and only render fallbacks. 27109 // The assumption is that this is usually faster. 27110 workInProgress.effectTag |= DidCapture; 27111 didSuspendAlready = true; 27112 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 27113 // to get it started back up to attempt the next item. If we can show 27114 // them, then they really have the same priority as this render. 27115 // So we'll pick it back up the very next render pass once we've had 27116 // an opportunity to yield for paint. 27117 27118 var nextPriority = renderExpirationTime - 1; 27119 workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; 27120 27121 { 27122 markSpawnedWork(nextPriority); 27123 } 27124 } 27125 } 27126 27127 if (renderState.isBackwards) { 27128 // The effect list of the backwards tail will have been added 27129 // to the end. This breaks the guarantee that life-cycles fire in 27130 // sibling order but that isn't a strong guarantee promised by React. 27131 // Especially since these might also just pop in during future commits. 27132 // Append to the beginning of the list. 27133 renderedTail.sibling = workInProgress.child; 27134 workInProgress.child = renderedTail; 27135 } else { 27136 var previousSibling = renderState.last; 27137 27138 if (previousSibling !== null) { 27139 previousSibling.sibling = renderedTail; 27140 } else { 27141 workInProgress.child = renderedTail; 27142 } 27143 27144 renderState.last = renderedTail; 27145 } 27146 } 27147 27148 if (renderState.tail !== null) { 27149 // We still have tail rows to render. 27150 if (renderState.tailExpiration === 0) { 27151 // Heuristic for how long we're willing to spend rendering rows 27152 // until we just give up and show what we have so far. 27153 var TAIL_EXPIRATION_TIMEOUT_MS = 500; 27154 renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this 27155 // is a per component value. It should really be since the start 27156 // of the total render or last commit. Consider using something like 27157 // globalMostRecentFallbackTime. That doesn't account for being 27158 // suspended for part of the time or when it's a new render. 27159 // It should probably use a global start time value instead. 27160 } // Pop a row. 27161 27162 27163 var next = renderState.tail; 27164 renderState.rendering = next; 27165 renderState.tail = next.sibling; 27166 renderState.lastEffect = workInProgress.lastEffect; 27167 renderState.renderingStartTime = now(); 27168 next.sibling = null; // Restore the context. 27169 // TODO: We can probably just avoid popping it instead and only 27170 // setting it the first time we go from not suspended to suspended. 27171 27172 var suspenseContext = suspenseStackCursor.current; 27173 27174 if (didSuspendAlready) { 27175 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 27176 } else { 27177 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 27178 } 27179 27180 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. 27181 27182 return next; 27183 } 27184 27185 return null; 27186 } 27187 } 27188 27189 { 27190 { 27191 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 27192 } 27193 } 27194} 27195 27196function unwindWork(workInProgress, renderExpirationTime) { 27197 switch (workInProgress.tag) { 27198 case ClassComponent: 27199 { 27200 var Component = workInProgress.type; 27201 27202 if (isContextProvider(Component)) { 27203 popContext(workInProgress); 27204 } 27205 27206 var effectTag = workInProgress.effectTag; 27207 27208 if (effectTag & ShouldCapture) { 27209 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture; 27210 return workInProgress; 27211 } 27212 27213 return null; 27214 } 27215 27216 case HostRoot: 27217 { 27218 popHostContainer(workInProgress); 27219 popTopLevelContextObject(workInProgress); 27220 var _effectTag = workInProgress.effectTag; 27221 27222 if (!((_effectTag & DidCapture) === NoEffect)) { 27223 { 27224 throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); 27225 } 27226 } 27227 27228 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture; 27229 return workInProgress; 27230 } 27231 27232 case HostComponent: 27233 { 27234 // TODO: popHydrationState 27235 popHostContext(workInProgress); 27236 return null; 27237 } 27238 27239 case SuspenseComponent: 27240 { 27241 popSuspenseContext(workInProgress); 27242 27243 var _effectTag2 = workInProgress.effectTag; 27244 27245 if (_effectTag2 & ShouldCapture) { 27246 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary. 27247 27248 return workInProgress; 27249 } 27250 27251 return null; 27252 } 27253 27254 case SuspenseListComponent: 27255 { 27256 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been 27257 // caught by a nested boundary. If not, it should bubble through. 27258 27259 return null; 27260 } 27261 27262 case HostPortal: 27263 popHostContainer(workInProgress); 27264 return null; 27265 27266 case ContextProvider: 27267 popProvider(workInProgress); 27268 return null; 27269 27270 default: 27271 return null; 27272 } 27273} 27274 27275function unwindInterruptedWork(interruptedWork) { 27276 switch (interruptedWork.tag) { 27277 case ClassComponent: 27278 { 27279 var childContextTypes = interruptedWork.type.childContextTypes; 27280 27281 if (childContextTypes !== null && childContextTypes !== undefined) { 27282 popContext(interruptedWork); 27283 } 27284 27285 break; 27286 } 27287 27288 case HostRoot: 27289 { 27290 popHostContainer(interruptedWork); 27291 popTopLevelContextObject(interruptedWork); 27292 break; 27293 } 27294 27295 case HostComponent: 27296 { 27297 popHostContext(interruptedWork); 27298 break; 27299 } 27300 27301 case HostPortal: 27302 popHostContainer(interruptedWork); 27303 break; 27304 27305 case SuspenseComponent: 27306 popSuspenseContext(interruptedWork); 27307 break; 27308 27309 case SuspenseListComponent: 27310 popSuspenseContext(interruptedWork); 27311 break; 27312 27313 case ContextProvider: 27314 popProvider(interruptedWork); 27315 break; 27316 } 27317} 27318 27319function createCapturedValue(value, source) { 27320 // If the value is an error, call this function immediately after it is thrown 27321 // so the stack is accurate. 27322 return { 27323 value: value, 27324 source: source, 27325 stack: getStackByFiberInDevAndProd(source) 27326 }; 27327} 27328 27329function logCapturedError(capturedError) { 27330 27331 var error = capturedError.error; 27332 27333 { 27334 var componentName = capturedError.componentName, 27335 componentStack = capturedError.componentStack, 27336 errorBoundaryName = capturedError.errorBoundaryName, 27337 errorBoundaryFound = capturedError.errorBoundaryFound, 27338 willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling 27339 // `preventDefault()` in window `error` handler. 27340 // We record this information as an expando on the error. 27341 27342 if (error != null && error._suppressLogging) { 27343 if (errorBoundaryFound && willRetry) { 27344 // The error is recoverable and was silenced. 27345 // Ignore it and don't print the stack addendum. 27346 // This is handy for testing error boundaries without noise. 27347 return; 27348 } // The error is fatal. Since the silencing might have 27349 // been accidental, we'll surface it anyway. 27350 // However, the browser would have silenced the original error 27351 // so we'll print it first, and then print the stack addendum. 27352 27353 27354 console['error'](error); // Don't transform to our wrapper 27355 // For a more detailed description of this block, see: 27356 // https://github.com/facebook/react/pull/13384 27357 } 27358 27359 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:'; 27360 var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. 27361 27362 if (errorBoundaryFound && errorBoundaryName) { 27363 if (willRetry) { 27364 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); 27365 } else { 27366 errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree."; 27367 } 27368 } else { 27369 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.'; 27370 } 27371 27372 var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. 27373 // We don't include the original error message and JS stack because the browser 27374 // has already printed it. Even if the application swallows the error, it is still 27375 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 27376 27377 console['error'](combinedMessage); // Don't transform to our wrapper 27378 } 27379} 27380 27381var didWarnAboutUndefinedSnapshotBeforeUpdate = null; 27382 27383{ 27384 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); 27385} 27386 27387var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set; 27388function logError(boundary, errorInfo) { 27389 var source = errorInfo.source; 27390 var stack = errorInfo.stack; 27391 27392 if (stack === null && source !== null) { 27393 stack = getStackByFiberInDevAndProd(source); 27394 } 27395 27396 var capturedError = { 27397 componentName: source !== null ? getComponentName(source.type) : null, 27398 componentStack: stack !== null ? stack : '', 27399 error: errorInfo.value, 27400 errorBoundary: null, 27401 errorBoundaryName: null, 27402 errorBoundaryFound: false, 27403 willRetry: false 27404 }; 27405 27406 if (boundary !== null && boundary.tag === ClassComponent) { 27407 capturedError.errorBoundary = boundary.stateNode; 27408 capturedError.errorBoundaryName = getComponentName(boundary.type); 27409 capturedError.errorBoundaryFound = true; 27410 capturedError.willRetry = true; 27411 } 27412 27413 try { 27414 logCapturedError(capturedError); 27415 } catch (e) { 27416 // This method must not throw, or React internal state will get messed up. 27417 // If console.error is overridden, or logCapturedError() shows a dialog that throws, 27418 // we want to report this error outside of the normal stack as a last resort. 27419 // https://github.com/facebook/react/issues/13188 27420 setTimeout(function () { 27421 throw e; 27422 }); 27423 } 27424} 27425 27426var callComponentWillUnmountWithTimer = function (current, instance) { 27427 startPhaseTimer(current, 'componentWillUnmount'); 27428 instance.props = current.memoizedProps; 27429 instance.state = current.memoizedState; 27430 instance.componentWillUnmount(); 27431 stopPhaseTimer(); 27432}; // Capture errors so they don't interrupt unmounting. 27433 27434 27435function safelyCallComponentWillUnmount(current, instance) { 27436 { 27437 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); 27438 27439 if (hasCaughtError()) { 27440 var unmountError = clearCaughtError(); 27441 captureCommitPhaseError(current, unmountError); 27442 } 27443 } 27444} 27445 27446function safelyDetachRef(current) { 27447 var ref = current.ref; 27448 27449 if (ref !== null) { 27450 if (typeof ref === 'function') { 27451 { 27452 invokeGuardedCallback(null, ref, null, null); 27453 27454 if (hasCaughtError()) { 27455 var refError = clearCaughtError(); 27456 captureCommitPhaseError(current, refError); 27457 } 27458 } 27459 } else { 27460 ref.current = null; 27461 } 27462 } 27463} 27464 27465function safelyCallDestroy(current, destroy) { 27466 { 27467 invokeGuardedCallback(null, destroy, null); 27468 27469 if (hasCaughtError()) { 27470 var error = clearCaughtError(); 27471 captureCommitPhaseError(current, error); 27472 } 27473 } 27474} 27475 27476function commitBeforeMutationLifeCycles(current, finishedWork) { 27477 switch (finishedWork.tag) { 27478 case FunctionComponent: 27479 case ForwardRef: 27480 case SimpleMemoComponent: 27481 case Block: 27482 { 27483 return; 27484 } 27485 27486 case ClassComponent: 27487 { 27488 if (finishedWork.effectTag & Snapshot) { 27489 if (current !== null) { 27490 var prevProps = current.memoizedProps; 27491 var prevState = current.memoizedState; 27492 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate'); 27493 var instance = finishedWork.stateNode; // We could update instance props and state here, 27494 // but instead we rely on them being set during last render. 27495 // TODO: revisit this when we implement resuming. 27496 27497 { 27498 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 27499 if (instance.props !== finishedWork.memoizedProps) { 27500 error('Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27501 } 27502 27503 if (instance.state !== finishedWork.memoizedState) { 27504 error('Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27505 } 27506 } 27507 } 27508 27509 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); 27510 27511 { 27512 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; 27513 27514 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { 27515 didWarnSet.add(finishedWork.type); 27516 27517 error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); 27518 } 27519 } 27520 27521 instance.__reactInternalSnapshotBeforeUpdate = snapshot; 27522 stopPhaseTimer(); 27523 } 27524 } 27525 27526 return; 27527 } 27528 27529 case HostRoot: 27530 case HostComponent: 27531 case HostText: 27532 case HostPortal: 27533 case IncompleteClassComponent: 27534 // Nothing to do for these component types 27535 return; 27536 } 27537 27538 { 27539 { 27540 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 27541 } 27542 } 27543} 27544 27545function commitHookEffectListUnmount(tag, finishedWork) { 27546 var updateQueue = finishedWork.updateQueue; 27547 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 27548 27549 if (lastEffect !== null) { 27550 var firstEffect = lastEffect.next; 27551 var effect = firstEffect; 27552 27553 do { 27554 if ((effect.tag & tag) === tag) { 27555 // Unmount 27556 var destroy = effect.destroy; 27557 effect.destroy = undefined; 27558 27559 if (destroy !== undefined) { 27560 destroy(); 27561 } 27562 } 27563 27564 effect = effect.next; 27565 } while (effect !== firstEffect); 27566 } 27567} 27568 27569function commitHookEffectListMount(tag, finishedWork) { 27570 var updateQueue = finishedWork.updateQueue; 27571 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 27572 27573 if (lastEffect !== null) { 27574 var firstEffect = lastEffect.next; 27575 var effect = firstEffect; 27576 27577 do { 27578 if ((effect.tag & tag) === tag) { 27579 // Mount 27580 var create = effect.create; 27581 effect.destroy = create(); 27582 27583 { 27584 var destroy = effect.destroy; 27585 27586 if (destroy !== undefined && typeof destroy !== 'function') { 27587 var addendum = void 0; 27588 27589 if (destroy === null) { 27590 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; 27591 } else if (typeof destroy.then === 'function') { 27592 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching'; 27593 } else { 27594 addendum = ' You returned: ' + destroy; 27595 } 27596 27597 error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork)); 27598 } 27599 } 27600 } 27601 27602 effect = effect.next; 27603 } while (effect !== firstEffect); 27604 } 27605} 27606 27607function commitPassiveHookEffects(finishedWork) { 27608 if ((finishedWork.effectTag & Passive) !== NoEffect) { 27609 switch (finishedWork.tag) { 27610 case FunctionComponent: 27611 case ForwardRef: 27612 case SimpleMemoComponent: 27613 case Block: 27614 { 27615 // TODO (#17945) We should call all passive destroy functions (for all fibers) 27616 // before calling any create functions. The current approach only serializes 27617 // these for a single fiber. 27618 commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); 27619 commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); 27620 break; 27621 } 27622 } 27623 } 27624} 27625 27626function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) { 27627 switch (finishedWork.tag) { 27628 case FunctionComponent: 27629 case ForwardRef: 27630 case SimpleMemoComponent: 27631 case Block: 27632 { 27633 // At this point layout effects have already been destroyed (during mutation phase). 27634 // This is done to prevent sibling component effects from interfering with each other, 27635 // e.g. a destroy function in one component should never override a ref set 27636 // by a create function in another component during the same commit. 27637 commitHookEffectListMount(Layout | HasEffect, finishedWork); 27638 27639 return; 27640 } 27641 27642 case ClassComponent: 27643 { 27644 var instance = finishedWork.stateNode; 27645 27646 if (finishedWork.effectTag & Update) { 27647 if (current === null) { 27648 startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here, 27649 // but instead we rely on them being set during last render. 27650 // TODO: revisit this when we implement resuming. 27651 27652 { 27653 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 27654 if (instance.props !== finishedWork.memoizedProps) { 27655 error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27656 } 27657 27658 if (instance.state !== finishedWork.memoizedState) { 27659 error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27660 } 27661 } 27662 } 27663 27664 instance.componentDidMount(); 27665 stopPhaseTimer(); 27666 } else { 27667 var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); 27668 var prevState = current.memoizedState; 27669 startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here, 27670 // but instead we rely on them being set during last render. 27671 // TODO: revisit this when we implement resuming. 27672 27673 { 27674 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 27675 if (instance.props !== finishedWork.memoizedProps) { 27676 error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27677 } 27678 27679 if (instance.state !== finishedWork.memoizedState) { 27680 error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27681 } 27682 } 27683 } 27684 27685 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); 27686 stopPhaseTimer(); 27687 } 27688 } 27689 27690 var updateQueue = finishedWork.updateQueue; 27691 27692 if (updateQueue !== null) { 27693 { 27694 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 27695 if (instance.props !== finishedWork.memoizedProps) { 27696 error('Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27697 } 27698 27699 if (instance.state !== finishedWork.memoizedState) { 27700 error('Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 27701 } 27702 } 27703 } // We could update instance props and state here, 27704 // but instead we rely on them being set during last render. 27705 // TODO: revisit this when we implement resuming. 27706 27707 27708 commitUpdateQueue(finishedWork, updateQueue, instance); 27709 } 27710 27711 return; 27712 } 27713 27714 case HostRoot: 27715 { 27716 var _updateQueue = finishedWork.updateQueue; 27717 27718 if (_updateQueue !== null) { 27719 var _instance = null; 27720 27721 if (finishedWork.child !== null) { 27722 switch (finishedWork.child.tag) { 27723 case HostComponent: 27724 _instance = getPublicInstance(finishedWork.child.stateNode); 27725 break; 27726 27727 case ClassComponent: 27728 _instance = finishedWork.child.stateNode; 27729 break; 27730 } 27731 } 27732 27733 commitUpdateQueue(finishedWork, _updateQueue, _instance); 27734 } 27735 27736 return; 27737 } 27738 27739 case HostComponent: 27740 { 27741 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted 27742 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 27743 // These effects should only be committed when components are first mounted, 27744 // aka when there is no current/alternate. 27745 27746 if (current === null && finishedWork.effectTag & Update) { 27747 var type = finishedWork.type; 27748 var props = finishedWork.memoizedProps; 27749 commitMount(_instance2, type, props); 27750 } 27751 27752 return; 27753 } 27754 27755 case HostText: 27756 { 27757 // We have no life-cycles associated with text. 27758 return; 27759 } 27760 27761 case HostPortal: 27762 { 27763 // We have no life-cycles associated with portals. 27764 return; 27765 } 27766 27767 case Profiler: 27768 { 27769 { 27770 var onRender = finishedWork.memoizedProps.onRender; 27771 27772 if (typeof onRender === 'function') { 27773 { 27774 onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions); 27775 } 27776 } 27777 } 27778 27779 return; 27780 } 27781 27782 case SuspenseComponent: 27783 { 27784 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); 27785 return; 27786 } 27787 27788 case SuspenseListComponent: 27789 case IncompleteClassComponent: 27790 case FundamentalComponent: 27791 case ScopeComponent: 27792 return; 27793 } 27794 27795 { 27796 { 27797 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 27798 } 27799 } 27800} 27801 27802function hideOrUnhideAllChildren(finishedWork, isHidden) { 27803 { 27804 // We only have the top Fiber that was inserted but we need to recurse down its 27805 // children to find all the terminal nodes. 27806 var node = finishedWork; 27807 27808 while (true) { 27809 if (node.tag === HostComponent) { 27810 var instance = node.stateNode; 27811 27812 if (isHidden) { 27813 hideInstance(instance); 27814 } else { 27815 unhideInstance(node.stateNode, node.memoizedProps); 27816 } 27817 } else if (node.tag === HostText) { 27818 var _instance3 = node.stateNode; 27819 27820 if (isHidden) { 27821 hideTextInstance(_instance3); 27822 } else { 27823 unhideTextInstance(_instance3, node.memoizedProps); 27824 } 27825 } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) { 27826 // Found a nested Suspense component that timed out. Skip over the 27827 // primary child fragment, which should remain hidden. 27828 var fallbackChildFragment = node.child.sibling; 27829 fallbackChildFragment.return = node; 27830 node = fallbackChildFragment; 27831 continue; 27832 } else if (node.child !== null) { 27833 node.child.return = node; 27834 node = node.child; 27835 continue; 27836 } 27837 27838 if (node === finishedWork) { 27839 return; 27840 } 27841 27842 while (node.sibling === null) { 27843 if (node.return === null || node.return === finishedWork) { 27844 return; 27845 } 27846 27847 node = node.return; 27848 } 27849 27850 node.sibling.return = node.return; 27851 node = node.sibling; 27852 } 27853 } 27854} 27855 27856function commitAttachRef(finishedWork) { 27857 var ref = finishedWork.ref; 27858 27859 if (ref !== null) { 27860 var instance = finishedWork.stateNode; 27861 var instanceToUse; 27862 27863 switch (finishedWork.tag) { 27864 case HostComponent: 27865 instanceToUse = getPublicInstance(instance); 27866 break; 27867 27868 default: 27869 instanceToUse = instance; 27870 } // Moved outside to ensure DCE works with this flag 27871 27872 if (typeof ref === 'function') { 27873 ref(instanceToUse); 27874 } else { 27875 { 27876 if (!ref.hasOwnProperty('current')) { 27877 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork)); 27878 } 27879 } 27880 27881 ref.current = instanceToUse; 27882 } 27883 } 27884} 27885 27886function commitDetachRef(current) { 27887 var currentRef = current.ref; 27888 27889 if (currentRef !== null) { 27890 if (typeof currentRef === 'function') { 27891 currentRef(null); 27892 } else { 27893 currentRef.current = null; 27894 } 27895 } 27896} // User-originating errors (lifecycles and refs) should not interrupt 27897// deletion, so don't let them throw. Host-originating errors should 27898// interrupt deletion, so it's okay 27899 27900 27901function commitUnmount(finishedRoot, current, renderPriorityLevel) { 27902 onCommitUnmount(current); 27903 27904 switch (current.tag) { 27905 case FunctionComponent: 27906 case ForwardRef: 27907 case MemoComponent: 27908 case SimpleMemoComponent: 27909 case Block: 27910 { 27911 var updateQueue = current.updateQueue; 27912 27913 if (updateQueue !== null) { 27914 var lastEffect = updateQueue.lastEffect; 27915 27916 if (lastEffect !== null) { 27917 var firstEffect = lastEffect.next; 27918 27919 { 27920 // When the owner fiber is deleted, the destroy function of a passive 27921 // effect hook is called during the synchronous commit phase. This is 27922 // a concession to implementation complexity. Calling it in the 27923 // passive effect phase (like they usually are, when dependencies 27924 // change during an update) would require either traversing the 27925 // children of the deleted fiber again, or including unmount effects 27926 // as part of the fiber effect list. 27927 // 27928 // Because this is during the sync commit phase, we need to change 27929 // the priority. 27930 // 27931 // TODO: Reconsider this implementation trade off. 27932 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel; 27933 runWithPriority$1(priorityLevel, function () { 27934 var effect = firstEffect; 27935 27936 do { 27937 var _destroy = effect.destroy; 27938 27939 if (_destroy !== undefined) { 27940 safelyCallDestroy(current, _destroy); 27941 } 27942 27943 effect = effect.next; 27944 } while (effect !== firstEffect); 27945 }); 27946 } 27947 } 27948 } 27949 27950 return; 27951 } 27952 27953 case ClassComponent: 27954 { 27955 safelyDetachRef(current); 27956 var instance = current.stateNode; 27957 27958 if (typeof instance.componentWillUnmount === 'function') { 27959 safelyCallComponentWillUnmount(current, instance); 27960 } 27961 27962 return; 27963 } 27964 27965 case HostComponent: 27966 { 27967 27968 safelyDetachRef(current); 27969 return; 27970 } 27971 27972 case HostPortal: 27973 { 27974 // TODO: this is recursive. 27975 // We are also not using this parent because 27976 // the portal will get pushed immediately. 27977 { 27978 unmountHostComponents(finishedRoot, current, renderPriorityLevel); 27979 } 27980 27981 return; 27982 } 27983 27984 case FundamentalComponent: 27985 { 27986 27987 return; 27988 } 27989 27990 case DehydratedFragment: 27991 { 27992 27993 return; 27994 } 27995 27996 case ScopeComponent: 27997 { 27998 27999 return; 28000 } 28001 } 28002} 28003 28004function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { 28005 // While we're inside a removed host node we don't want to call 28006 // removeChild on the inner nodes because they're removed by the top 28007 // call anyway. We also want to call componentWillUnmount on all 28008 // composites before this host node is removed from the tree. Therefore 28009 // we do an inner loop while we're still inside the host node. 28010 var node = root; 28011 28012 while (true) { 28013 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. 28014 // Skip portals because commitUnmount() currently visits them recursively. 28015 28016 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above. 28017 // If we don't use mutation we drill down into portals here instead. 28018 node.tag !== HostPortal)) { 28019 node.child.return = node; 28020 node = node.child; 28021 continue; 28022 } 28023 28024 if (node === root) { 28025 return; 28026 } 28027 28028 while (node.sibling === null) { 28029 if (node.return === null || node.return === root) { 28030 return; 28031 } 28032 28033 node = node.return; 28034 } 28035 28036 node.sibling.return = node.return; 28037 node = node.sibling; 28038 } 28039} 28040 28041function detachFiber(current) { 28042 var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we 28043 // should clear the child pointer of the parent alternate to let this 28044 // get GC:ed but we don't know which for sure which parent is the current 28045 // one so we'll settle for GC:ing the subtree of this child. This child 28046 // itself will be GC:ed when the parent updates the next time. 28047 28048 current.return = null; 28049 current.child = null; 28050 current.memoizedState = null; 28051 current.updateQueue = null; 28052 current.dependencies = null; 28053 current.alternate = null; 28054 current.firstEffect = null; 28055 current.lastEffect = null; 28056 current.pendingProps = null; 28057 current.memoizedProps = null; 28058 current.stateNode = null; 28059 28060 if (alternate !== null) { 28061 detachFiber(alternate); 28062 } 28063} 28064 28065function getHostParentFiber(fiber) { 28066 var parent = fiber.return; 28067 28068 while (parent !== null) { 28069 if (isHostParent(parent)) { 28070 return parent; 28071 } 28072 28073 parent = parent.return; 28074 } 28075 28076 { 28077 { 28078 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 28079 } 28080 } 28081} 28082 28083function isHostParent(fiber) { 28084 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 28085} 28086 28087function getHostSibling(fiber) { 28088 // We're going to search forward into the tree until we find a sibling host 28089 // node. Unfortunately, if multiple insertions are done in a row we have to 28090 // search past them. This leads to exponential search for the next sibling. 28091 // TODO: Find a more efficient way to do this. 28092 var node = fiber; 28093 28094 siblings: while (true) { 28095 // If we didn't find anything, let's try the next sibling. 28096 while (node.sibling === null) { 28097 if (node.return === null || isHostParent(node.return)) { 28098 // If we pop out of the root or hit the parent the fiber we are the 28099 // last sibling. 28100 return null; 28101 } 28102 28103 node = node.return; 28104 } 28105 28106 node.sibling.return = node.return; 28107 node = node.sibling; 28108 28109 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) { 28110 // If it is not host node and, we might have a host node inside it. 28111 // Try to search down until we find one. 28112 if (node.effectTag & Placement) { 28113 // If we don't have a child, try the siblings instead. 28114 continue siblings; 28115 } // If we don't have a child, try the siblings instead. 28116 // We also skip portals because they are not part of this host tree. 28117 28118 28119 if (node.child === null || node.tag === HostPortal) { 28120 continue siblings; 28121 } else { 28122 node.child.return = node; 28123 node = node.child; 28124 } 28125 } // Check if this host node is stable or about to be placed. 28126 28127 28128 if (!(node.effectTag & Placement)) { 28129 // Found it! 28130 return node.stateNode; 28131 } 28132 } 28133} 28134 28135function commitPlacement(finishedWork) { 28136 28137 28138 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together. 28139 28140 var parent; 28141 var isContainer; 28142 var parentStateNode = parentFiber.stateNode; 28143 28144 switch (parentFiber.tag) { 28145 case HostComponent: 28146 parent = parentStateNode; 28147 isContainer = false; 28148 break; 28149 28150 case HostRoot: 28151 parent = parentStateNode.containerInfo; 28152 isContainer = true; 28153 break; 28154 28155 case HostPortal: 28156 parent = parentStateNode.containerInfo; 28157 isContainer = true; 28158 break; 28159 28160 case FundamentalComponent: 28161 28162 // eslint-disable-next-line-no-fallthrough 28163 28164 default: 28165 { 28166 { 28167 throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); 28168 } 28169 } 28170 28171 } 28172 28173 if (parentFiber.effectTag & ContentReset) { 28174 // Reset the text content of the parent before doing any insertions 28175 resetTextContent(parent); // Clear ContentReset from the effect tag 28176 28177 parentFiber.effectTag &= ~ContentReset; 28178 } 28179 28180 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its 28181 // children to find all the terminal nodes. 28182 28183 if (isContainer) { 28184 insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent); 28185 } else { 28186 insertOrAppendPlacementNode(finishedWork, before, parent); 28187 } 28188} 28189 28190function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { 28191 var tag = node.tag; 28192 var isHost = tag === HostComponent || tag === HostText; 28193 28194 if (isHost || enableFundamentalAPI ) { 28195 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 28196 28197 if (before) { 28198 insertInContainerBefore(parent, stateNode, before); 28199 } else { 28200 appendChildToContainer(parent, stateNode); 28201 } 28202 } else if (tag === HostPortal) ; else { 28203 var child = node.child; 28204 28205 if (child !== null) { 28206 insertOrAppendPlacementNodeIntoContainer(child, before, parent); 28207 var sibling = child.sibling; 28208 28209 while (sibling !== null) { 28210 insertOrAppendPlacementNodeIntoContainer(sibling, before, parent); 28211 sibling = sibling.sibling; 28212 } 28213 } 28214 } 28215} 28216 28217function insertOrAppendPlacementNode(node, before, parent) { 28218 var tag = node.tag; 28219 var isHost = tag === HostComponent || tag === HostText; 28220 28221 if (isHost || enableFundamentalAPI ) { 28222 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 28223 28224 if (before) { 28225 insertBefore(parent, stateNode, before); 28226 } else { 28227 appendChild(parent, stateNode); 28228 } 28229 } else if (tag === HostPortal) ; else { 28230 var child = node.child; 28231 28232 if (child !== null) { 28233 insertOrAppendPlacementNode(child, before, parent); 28234 var sibling = child.sibling; 28235 28236 while (sibling !== null) { 28237 insertOrAppendPlacementNode(sibling, before, parent); 28238 sibling = sibling.sibling; 28239 } 28240 } 28241 } 28242} 28243 28244function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { 28245 // We only have the top Fiber that was deleted but we need to recurse down its 28246 // children to find all the terminal nodes. 28247 var node = current; // Each iteration, currentParent is populated with node's host parent if not 28248 // currentParentIsValid. 28249 28250 var currentParentIsValid = false; // Note: these two variables *must* always be updated together. 28251 28252 var currentParent; 28253 var currentParentIsContainer; 28254 28255 while (true) { 28256 if (!currentParentIsValid) { 28257 var parent = node.return; 28258 28259 findParent: while (true) { 28260 if (!(parent !== null)) { 28261 { 28262 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 28263 } 28264 } 28265 28266 var parentStateNode = parent.stateNode; 28267 28268 switch (parent.tag) { 28269 case HostComponent: 28270 currentParent = parentStateNode; 28271 currentParentIsContainer = false; 28272 break findParent; 28273 28274 case HostRoot: 28275 currentParent = parentStateNode.containerInfo; 28276 currentParentIsContainer = true; 28277 break findParent; 28278 28279 case HostPortal: 28280 currentParent = parentStateNode.containerInfo; 28281 currentParentIsContainer = true; 28282 break findParent; 28283 28284 } 28285 28286 parent = parent.return; 28287 } 28288 28289 currentParentIsValid = true; 28290 } 28291 28292 if (node.tag === HostComponent || node.tag === HostText) { 28293 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the 28294 // node from the tree. 28295 28296 if (currentParentIsContainer) { 28297 removeChildFromContainer(currentParent, node.stateNode); 28298 } else { 28299 removeChild(currentParent, node.stateNode); 28300 } // Don't visit children because we already visited them. 28301 28302 } else if (node.tag === HostPortal) { 28303 if (node.child !== null) { 28304 // When we go into a portal, it becomes the parent to remove from. 28305 // We will reassign it back when we pop the portal on the way up. 28306 currentParent = node.stateNode.containerInfo; 28307 currentParentIsContainer = true; // Visit children because portals might contain host components. 28308 28309 node.child.return = node; 28310 node = node.child; 28311 continue; 28312 } 28313 } else { 28314 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below. 28315 28316 if (node.child !== null) { 28317 node.child.return = node; 28318 node = node.child; 28319 continue; 28320 } 28321 } 28322 28323 if (node === current) { 28324 return; 28325 } 28326 28327 while (node.sibling === null) { 28328 if (node.return === null || node.return === current) { 28329 return; 28330 } 28331 28332 node = node.return; 28333 28334 if (node.tag === HostPortal) { 28335 // When we go out of the portal, we need to restore the parent. 28336 // Since we don't keep a stack of them, we will search for it. 28337 currentParentIsValid = false; 28338 } 28339 } 28340 28341 node.sibling.return = node.return; 28342 node = node.sibling; 28343 } 28344} 28345 28346function commitDeletion(finishedRoot, current, renderPriorityLevel) { 28347 { 28348 // Recursively delete all host nodes from the parent. 28349 // Detach refs and call componentWillUnmount() on the whole subtree. 28350 unmountHostComponents(finishedRoot, current, renderPriorityLevel); 28351 } 28352 28353 detachFiber(current); 28354} 28355 28356function commitWork(current, finishedWork) { 28357 28358 switch (finishedWork.tag) { 28359 case FunctionComponent: 28360 case ForwardRef: 28361 case MemoComponent: 28362 case SimpleMemoComponent: 28363 case Block: 28364 { 28365 // Layout effects are destroyed during the mutation phase so that all 28366 // destroy functions for all fibers are called before any create functions. 28367 // This prevents sibling component effects from interfering with each other, 28368 // e.g. a destroy function in one component should never override a ref set 28369 // by a create function in another component during the same commit. 28370 commitHookEffectListUnmount(Layout | HasEffect, finishedWork); 28371 return; 28372 } 28373 28374 case ClassComponent: 28375 { 28376 return; 28377 } 28378 28379 case HostComponent: 28380 { 28381 var instance = finishedWork.stateNode; 28382 28383 if (instance != null) { 28384 // Commit the work prepared earlier. 28385 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 28386 // as the newProps. The updatePayload will contain the real change in 28387 // this case. 28388 28389 var oldProps = current !== null ? current.memoizedProps : newProps; 28390 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. 28391 28392 var updatePayload = finishedWork.updateQueue; 28393 finishedWork.updateQueue = null; 28394 28395 if (updatePayload !== null) { 28396 commitUpdate(instance, updatePayload, type, oldProps, newProps); 28397 } 28398 } 28399 28400 return; 28401 } 28402 28403 case HostText: 28404 { 28405 if (!(finishedWork.stateNode !== null)) { 28406 { 28407 throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." ); 28408 } 28409 } 28410 28411 var textInstance = finishedWork.stateNode; 28412 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 28413 // as the newProps. The updatePayload will contain the real change in 28414 // this case. 28415 28416 var oldText = current !== null ? current.memoizedProps : newText; 28417 commitTextUpdate(textInstance, oldText, newText); 28418 return; 28419 } 28420 28421 case HostRoot: 28422 { 28423 { 28424 var _root = finishedWork.stateNode; 28425 28426 if (_root.hydrate) { 28427 // We've just hydrated. No need to hydrate again. 28428 _root.hydrate = false; 28429 commitHydratedContainer(_root.containerInfo); 28430 } 28431 } 28432 28433 return; 28434 } 28435 28436 case Profiler: 28437 { 28438 return; 28439 } 28440 28441 case SuspenseComponent: 28442 { 28443 commitSuspenseComponent(finishedWork); 28444 attachSuspenseRetryListeners(finishedWork); 28445 return; 28446 } 28447 28448 case SuspenseListComponent: 28449 { 28450 attachSuspenseRetryListeners(finishedWork); 28451 return; 28452 } 28453 28454 case IncompleteClassComponent: 28455 { 28456 return; 28457 } 28458 } 28459 28460 { 28461 { 28462 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 28463 } 28464 } 28465} 28466 28467function commitSuspenseComponent(finishedWork) { 28468 var newState = finishedWork.memoizedState; 28469 var newDidTimeout; 28470 var primaryChildParent = finishedWork; 28471 28472 if (newState === null) { 28473 newDidTimeout = false; 28474 } else { 28475 newDidTimeout = true; 28476 primaryChildParent = finishedWork.child; 28477 markCommitTimeOfFallback(); 28478 } 28479 28480 if ( primaryChildParent !== null) { 28481 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); 28482 } 28483} 28484 28485function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) { 28486 28487 var newState = finishedWork.memoizedState; 28488 28489 if (newState === null) { 28490 var current = finishedWork.alternate; 28491 28492 if (current !== null) { 28493 var prevState = current.memoizedState; 28494 28495 if (prevState !== null) { 28496 var suspenseInstance = prevState.dehydrated; 28497 28498 if (suspenseInstance !== null) { 28499 commitHydratedSuspenseInstance(suspenseInstance); 28500 } 28501 } 28502 } 28503 } 28504} 28505 28506function attachSuspenseRetryListeners(finishedWork) { 28507 // If this boundary just timed out, then it will have a set of thenables. 28508 // For each thenable, attach a listener so that when it resolves, React 28509 // attempts to re-render the boundary in the primary (pre-timeout) state. 28510 var thenables = finishedWork.updateQueue; 28511 28512 if (thenables !== null) { 28513 finishedWork.updateQueue = null; 28514 var retryCache = finishedWork.stateNode; 28515 28516 if (retryCache === null) { 28517 retryCache = finishedWork.stateNode = new PossiblyWeakSet(); 28518 } 28519 28520 thenables.forEach(function (thenable) { 28521 // Memoize using the boundary fiber to prevent redundant listeners. 28522 var retry = resolveRetryThenable.bind(null, finishedWork, thenable); 28523 28524 if (!retryCache.has(thenable)) { 28525 { 28526 if (thenable.__reactDoNotTraceInteractions !== true) { 28527 retry = tracing.unstable_wrap(retry); 28528 } 28529 } 28530 28531 retryCache.add(thenable); 28532 thenable.then(retry, retry); 28533 } 28534 }); 28535 } 28536} 28537 28538function commitResetTextContent(current) { 28539 28540 resetTextContent(current.stateNode); 28541} 28542 28543var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; 28544 28545function createRootErrorUpdate(fiber, errorInfo, expirationTime) { 28546 var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. 28547 28548 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property 28549 // being called "element". 28550 28551 update.payload = { 28552 element: null 28553 }; 28554 var error = errorInfo.value; 28555 28556 update.callback = function () { 28557 onUncaughtError(error); 28558 logError(fiber, errorInfo); 28559 }; 28560 28561 return update; 28562} 28563 28564function createClassErrorUpdate(fiber, errorInfo, expirationTime) { 28565 var update = createUpdate(expirationTime, null); 28566 update.tag = CaptureUpdate; 28567 var getDerivedStateFromError = fiber.type.getDerivedStateFromError; 28568 28569 if (typeof getDerivedStateFromError === 'function') { 28570 var error$1 = errorInfo.value; 28571 28572 update.payload = function () { 28573 logError(fiber, errorInfo); 28574 return getDerivedStateFromError(error$1); 28575 }; 28576 } 28577 28578 var inst = fiber.stateNode; 28579 28580 if (inst !== null && typeof inst.componentDidCatch === 'function') { 28581 update.callback = function callback() { 28582 { 28583 markFailedErrorBoundaryForHotReloading(fiber); 28584 } 28585 28586 if (typeof getDerivedStateFromError !== 'function') { 28587 // To preserve the preexisting retry behavior of error boundaries, 28588 // we keep track of which ones already failed during this batch. 28589 // This gets reset before we yield back to the browser. 28590 // TODO: Warn in strict mode if getDerivedStateFromError is 28591 // not defined. 28592 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined 28593 28594 logError(fiber, errorInfo); 28595 } 28596 28597 var error$1 = errorInfo.value; 28598 var stack = errorInfo.stack; 28599 this.componentDidCatch(error$1, { 28600 componentStack: stack !== null ? stack : '' 28601 }); 28602 28603 { 28604 if (typeof getDerivedStateFromError !== 'function') { 28605 // If componentDidCatch is the only error boundary method defined, 28606 // then it needs to call setState to recover from errors. 28607 // If no state update is scheduled then the boundary will swallow the error. 28608 if (fiber.expirationTime !== Sync) { 28609 error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown'); 28610 } 28611 } 28612 } 28613 }; 28614 } else { 28615 update.callback = function () { 28616 markFailedErrorBoundaryForHotReloading(fiber); 28617 }; 28618 } 28619 28620 return update; 28621} 28622 28623function attachPingListener(root, renderExpirationTime, thenable) { 28624 // Attach a listener to the promise to "ping" the root and retry. But 28625 // only if one does not already exist for the current render expiration 28626 // time (which acts like a "thread ID" here). 28627 var pingCache = root.pingCache; 28628 var threadIDs; 28629 28630 if (pingCache === null) { 28631 pingCache = root.pingCache = new PossiblyWeakMap$1(); 28632 threadIDs = new Set(); 28633 pingCache.set(thenable, threadIDs); 28634 } else { 28635 threadIDs = pingCache.get(thenable); 28636 28637 if (threadIDs === undefined) { 28638 threadIDs = new Set(); 28639 pingCache.set(thenable, threadIDs); 28640 } 28641 } 28642 28643 if (!threadIDs.has(renderExpirationTime)) { 28644 // Memoize using the thread ID to prevent redundant listeners. 28645 threadIDs.add(renderExpirationTime); 28646 var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime); 28647 thenable.then(ping, ping); 28648 } 28649} 28650 28651function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) { 28652 // The source fiber did not complete. 28653 sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. 28654 28655 sourceFiber.firstEffect = sourceFiber.lastEffect = null; 28656 28657 if (value !== null && typeof value === 'object' && typeof value.then === 'function') { 28658 // This is a thenable. 28659 var thenable = value; 28660 28661 if ((sourceFiber.mode & BlockingMode) === NoMode) { 28662 // Reset the memoizedState to what it was before we attempted 28663 // to render it. 28664 var currentSource = sourceFiber.alternate; 28665 28666 if (currentSource) { 28667 sourceFiber.updateQueue = currentSource.updateQueue; 28668 sourceFiber.memoizedState = currentSource.memoizedState; 28669 sourceFiber.expirationTime = currentSource.expirationTime; 28670 } else { 28671 sourceFiber.updateQueue = null; 28672 sourceFiber.memoizedState = null; 28673 } 28674 } 28675 28676 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view. 28677 28678 var _workInProgress = returnFiber; 28679 28680 do { 28681 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) { 28682 // Found the nearest boundary. 28683 // Stash the promise on the boundary fiber. If the boundary times out, we'll 28684 // attach another listener to flip the boundary back to its normal state. 28685 var thenables = _workInProgress.updateQueue; 28686 28687 if (thenables === null) { 28688 var updateQueue = new Set(); 28689 updateQueue.add(thenable); 28690 _workInProgress.updateQueue = updateQueue; 28691 } else { 28692 thenables.add(thenable); 28693 } // If the boundary is outside of blocking mode, we should *not* 28694 // suspend the commit. Pretend as if the suspended component rendered 28695 // null and keep rendering. In the commit phase, we'll schedule a 28696 // subsequent synchronous update to re-render the Suspense. 28697 // 28698 // Note: It doesn't matter whether the component that suspended was 28699 // inside a blocking mode tree. If the Suspense is outside of it, we 28700 // should *not* suspend the commit. 28701 28702 28703 if ((_workInProgress.mode & BlockingMode) === NoMode) { 28704 _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. 28705 // But we shouldn't call any lifecycle methods or callbacks. Remove 28706 // all lifecycle effect tags. 28707 28708 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); 28709 28710 if (sourceFiber.tag === ClassComponent) { 28711 var currentSourceFiber = sourceFiber.alternate; 28712 28713 if (currentSourceFiber === null) { 28714 // This is a new mount. Change the tag so it's not mistaken for a 28715 // completed class component. For example, we should not call 28716 // componentWillUnmount if it is deleted. 28717 sourceFiber.tag = IncompleteClassComponent; 28718 } else { 28719 // When we try rendering again, we should not reuse the current fiber, 28720 // since it's known to be in an inconsistent state. Use a force update to 28721 // prevent a bail out. 28722 var update = createUpdate(Sync, null); 28723 update.tag = ForceUpdate; 28724 enqueueUpdate(sourceFiber, update); 28725 } 28726 } // The source fiber did not complete. Mark it with Sync priority to 28727 // indicate that it still has pending work. 28728 28729 28730 sourceFiber.expirationTime = Sync; // Exit without suspending. 28731 28732 return; 28733 } // Confirmed that the boundary is in a concurrent mode tree. Continue 28734 // with the normal suspend path. 28735 // 28736 // After this we'll use a set of heuristics to determine whether this 28737 // render pass will run to completion or restart or "suspend" the commit. 28738 // The actual logic for this is spread out in different places. 28739 // 28740 // This first principle is that if we're going to suspend when we complete 28741 // a root, then we should also restart if we get an update or ping that 28742 // might unsuspend it, and vice versa. The only reason to suspend is 28743 // because you think you might want to restart before committing. However, 28744 // it doesn't make sense to restart only while in the period we're suspended. 28745 // 28746 // Restarting too aggressively is also not good because it starves out any 28747 // intermediate loading state. So we use heuristics to determine when. 28748 // Suspense Heuristics 28749 // 28750 // If nothing threw a Promise or all the same fallbacks are already showing, 28751 // then don't suspend/restart. 28752 // 28753 // If this is an initial render of a new tree of Suspense boundaries and 28754 // those trigger a fallback, then don't suspend/restart. We want to ensure 28755 // that we can show the initial loading state as quickly as possible. 28756 // 28757 // If we hit a "Delayed" case, such as when we'd switch from content back into 28758 // a fallback, then we should always suspend/restart. SuspenseConfig applies to 28759 // this case. If none is defined, JND is used instead. 28760 // 28761 // If we're already showing a fallback and it gets "retried", allowing us to show 28762 // another level, but there's still an inner boundary that would show a fallback, 28763 // then we suspend/restart for 500ms since the last time we showed a fallback 28764 // anywhere in the tree. This effectively throttles progressive loading into a 28765 // consistent train of commits. This also gives us an opportunity to restart to 28766 // get to the completed state slightly earlier. 28767 // 28768 // If there's ambiguity due to batching it's resolved in preference of: 28769 // 1) "delayed", 2) "initial render", 3) "retry". 28770 // 28771 // We want to ensure that a "busy" state doesn't get force committed. We want to 28772 // ensure that new initial loading states can commit as soon as possible. 28773 28774 28775 attachPingListener(root, renderExpirationTime, thenable); 28776 _workInProgress.effectTag |= ShouldCapture; 28777 _workInProgress.expirationTime = renderExpirationTime; 28778 return; 28779 } // This boundary already captured during this render. Continue to the next 28780 // boundary. 28781 28782 28783 _workInProgress = _workInProgress.return; 28784 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. 28785 // TODO: Use invariant so the message is stripped in prod? 28786 28787 28788 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber)); 28789 } // We didn't find a boundary that could handle this type of exception. Start 28790 // over and traverse parent path again, this time treating the exception 28791 // as an error. 28792 28793 28794 renderDidError(); 28795 value = createCapturedValue(value, sourceFiber); 28796 var workInProgress = returnFiber; 28797 28798 do { 28799 switch (workInProgress.tag) { 28800 case HostRoot: 28801 { 28802 var _errorInfo = value; 28803 workInProgress.effectTag |= ShouldCapture; 28804 workInProgress.expirationTime = renderExpirationTime; 28805 28806 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime); 28807 28808 enqueueCapturedUpdate(workInProgress, _update); 28809 return; 28810 } 28811 28812 case ClassComponent: 28813 // Capture and retry 28814 var errorInfo = value; 28815 var ctor = workInProgress.type; 28816 var instance = workInProgress.stateNode; 28817 28818 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { 28819 workInProgress.effectTag |= ShouldCapture; 28820 workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state 28821 28822 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime); 28823 28824 enqueueCapturedUpdate(workInProgress, _update2); 28825 return; 28826 } 28827 28828 break; 28829 } 28830 28831 workInProgress = workInProgress.return; 28832 } while (workInProgress !== null); 28833} 28834 28835var ceil = Math.ceil; 28836var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, 28837 ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, 28838 IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; 28839var NoContext = 28840/* */ 288410; 28842var BatchedContext = 28843/* */ 288441; 28845var EventContext = 28846/* */ 288472; 28848var DiscreteEventContext = 28849/* */ 288504; 28851var LegacyUnbatchedContext = 28852/* */ 288538; 28854var RenderContext = 28855/* */ 2885616; 28857var CommitContext = 28858/* */ 2885932; 28860var RootIncomplete = 0; 28861var RootFatalErrored = 1; 28862var RootErrored = 2; 28863var RootSuspended = 3; 28864var RootSuspendedWithDelay = 4; 28865var RootCompleted = 5; 28866// Describes where we are in the React execution stack 28867var executionContext = NoContext; // The root we're working on 28868 28869var workInProgressRoot = null; // The fiber we're working on 28870 28871var workInProgress = null; // The expiration time we're rendering 28872 28873var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. 28874 28875var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown 28876 28877var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. 28878// This is conceptually a time stamp but expressed in terms of an ExpirationTime 28879// because we deal mostly with expiration times in the hot path, so this avoids 28880// the conversion happening in the hot path. 28881 28882var workInProgressRootLatestProcessedExpirationTime = Sync; 28883var workInProgressRootLatestSuspenseTimeout = Sync; 28884var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only 28885// includes unprocessed updates, not work in bailed out children. 28886 28887var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. 28888// This flag determines if it might be worthwhile to restart if an opportunity 28889// happens latere. 28890 28891var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train 28892// model where we don't commit new loading states in too quick succession. 28893 28894var globalMostRecentFallbackTime = 0; 28895var FALLBACK_THROTTLE_MS = 500; 28896var nextEffect = null; 28897var hasUncaughtError = false; 28898var firstUncaughtError = null; 28899var legacyErrorBoundariesThatAlreadyFailed = null; 28900var rootDoesHavePassiveEffects = false; 28901var rootWithPendingPassiveEffects = null; 28902var pendingPassiveEffectsRenderPriority = NoPriority; 28903var pendingPassiveEffectsExpirationTime = NoWork; 28904var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates 28905 28906var NESTED_UPDATE_LIMIT = 50; 28907var nestedUpdateCount = 0; 28908var rootWithNestedUpdates = null; 28909var NESTED_PASSIVE_UPDATE_LIMIT = 50; 28910var nestedPassiveUpdateCount = 0; 28911var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times 28912// during the commit phase. This enables them to be traced across components 28913// that spawn new work during render. E.g. hidden boundaries, suspended SSR 28914// hydration or SuspenseList. 28915 28916var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start 28917// time). However, if two updates are scheduled within the same event, we 28918// should treat their start times as simultaneous, even if the actual clock 28919// time has advanced between the first and second call. 28920// In other words, because expiration times determine how updates are batched, 28921// we want all updates of like priority that occur within the same event to 28922// receive the same expiration time. Otherwise we get tearing. 28923 28924var currentEventTime = NoWork; 28925function requestCurrentTimeForUpdate() { 28926 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 28927 // We're inside React, so it's fine to read the actual time. 28928 return msToExpirationTime(now()); 28929 } // We're not inside React, so we may be in the middle of a browser event. 28930 28931 28932 if (currentEventTime !== NoWork) { 28933 // Use the same start time for all updates until we enter React again. 28934 return currentEventTime; 28935 } // This is the first update since React yielded. Compute a new start time. 28936 28937 28938 currentEventTime = msToExpirationTime(now()); 28939 return currentEventTime; 28940} 28941function getCurrentTime() { 28942 return msToExpirationTime(now()); 28943} 28944function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { 28945 var mode = fiber.mode; 28946 28947 if ((mode & BlockingMode) === NoMode) { 28948 return Sync; 28949 } 28950 28951 var priorityLevel = getCurrentPriorityLevel(); 28952 28953 if ((mode & ConcurrentMode) === NoMode) { 28954 return priorityLevel === ImmediatePriority ? Sync : Batched; 28955 } 28956 28957 if ((executionContext & RenderContext) !== NoContext) { 28958 // Use whatever time we're already rendering 28959 // TODO: Should there be a way to opt out, like with `runWithPriority`? 28960 return renderExpirationTime$1; 28961 } 28962 28963 var expirationTime; 28964 28965 if (suspenseConfig !== null) { 28966 // Compute an expiration time based on the Suspense timeout. 28967 expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION); 28968 } else { 28969 // Compute an expiration time based on the Scheduler priority. 28970 switch (priorityLevel) { 28971 case ImmediatePriority: 28972 expirationTime = Sync; 28973 break; 28974 28975 case UserBlockingPriority$1: 28976 // TODO: Rename this to computeUserBlockingExpiration 28977 expirationTime = computeInteractiveExpiration(currentTime); 28978 break; 28979 28980 case NormalPriority: 28981 case LowPriority: 28982 // TODO: Handle LowPriority 28983 // TODO: Rename this to... something better. 28984 expirationTime = computeAsyncExpiration(currentTime); 28985 break; 28986 28987 case IdlePriority: 28988 expirationTime = Idle; 28989 break; 28990 28991 default: 28992 { 28993 { 28994 throw Error( "Expected a valid priority level" ); 28995 } 28996 } 28997 28998 } 28999 } // If we're in the middle of rendering a tree, do not update at the same 29000 // expiration time that is already rendering. 29001 // TODO: We shouldn't have to do this if the update is on a different root. 29002 // Refactor computeExpirationForFiber + scheduleUpdate so we have access to 29003 // the root when we check for this condition. 29004 29005 29006 if (workInProgressRoot !== null && expirationTime === renderExpirationTime$1) { 29007 // This is a trick to move this update into a separate batch 29008 expirationTime -= 1; 29009 } 29010 29011 return expirationTime; 29012} 29013function scheduleUpdateOnFiber(fiber, expirationTime) { 29014 checkForNestedUpdates(); 29015 warnAboutRenderPhaseUpdatesInDEV(fiber); 29016 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); 29017 29018 if (root === null) { 29019 warnAboutUpdateOnUnmountedFiberInDEV(fiber); 29020 return; 29021 } 29022 29023 checkForInterruption(fiber, expirationTime); 29024 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the 29025 // priority as an argument to that function and this one. 29026 29027 var priorityLevel = getCurrentPriorityLevel(); 29028 29029 if (expirationTime === Sync) { 29030 if ( // Check if we're inside unbatchedUpdates 29031 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering 29032 (executionContext & (RenderContext | CommitContext)) === NoContext) { 29033 // Register pending interactions on the root to avoid losing traced interaction data. 29034 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed 29035 // root inside of batchedUpdates should be synchronous, but layout updates 29036 // should be deferred until the end of the batch. 29037 29038 performSyncWorkOnRoot(root); 29039 } else { 29040 ensureRootIsScheduled(root); 29041 schedulePendingInteractions(root, expirationTime); 29042 29043 if (executionContext === NoContext) { 29044 // Flush the synchronous work now, unless we're already working or inside 29045 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of 29046 // scheduleCallbackForFiber to preserve the ability to schedule a callback 29047 // without immediately flushing it. We only do this for user-initiated 29048 // updates, to preserve historical behavior of legacy mode. 29049 flushSyncCallbackQueue(); 29050 } 29051 } 29052 } else { 29053 ensureRootIsScheduled(root); 29054 schedulePendingInteractions(root, expirationTime); 29055 } 29056 29057 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered 29058 // discrete, even inside a discrete event. 29059 priorityLevel === UserBlockingPriority$1 || priorityLevel === ImmediatePriority)) { 29060 // This is the result of a discrete event. Track the lowest priority 29061 // discrete update per root so we can flush them early, if needed. 29062 if (rootsWithPendingDiscreteUpdates === null) { 29063 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); 29064 } else { 29065 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); 29066 29067 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { 29068 rootsWithPendingDiscreteUpdates.set(root, expirationTime); 29069 } 29070 } 29071 } 29072} 29073var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending 29074// work without treating it as a typical update that originates from an event; 29075// e.g. retrying a Suspense boundary isn't an update, but it does schedule work 29076// on a fiber. 29077 29078function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { 29079 // Update the source fiber's expiration time 29080 if (fiber.expirationTime < expirationTime) { 29081 fiber.expirationTime = expirationTime; 29082 } 29083 29084 var alternate = fiber.alternate; 29085 29086 if (alternate !== null && alternate.expirationTime < expirationTime) { 29087 alternate.expirationTime = expirationTime; 29088 } // Walk the parent path to the root and update the child expiration time. 29089 29090 29091 var node = fiber.return; 29092 var root = null; 29093 29094 if (node === null && fiber.tag === HostRoot) { 29095 root = fiber.stateNode; 29096 } else { 29097 while (node !== null) { 29098 alternate = node.alternate; 29099 29100 if (node.childExpirationTime < expirationTime) { 29101 node.childExpirationTime = expirationTime; 29102 29103 if (alternate !== null && alternate.childExpirationTime < expirationTime) { 29104 alternate.childExpirationTime = expirationTime; 29105 } 29106 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) { 29107 alternate.childExpirationTime = expirationTime; 29108 } 29109 29110 if (node.return === null && node.tag === HostRoot) { 29111 root = node.stateNode; 29112 break; 29113 } 29114 29115 node = node.return; 29116 } 29117 } 29118 29119 if (root !== null) { 29120 if (workInProgressRoot === root) { 29121 // Received an update to a tree that's in the middle of rendering. Mark 29122 // that's unprocessed work on this root. 29123 markUnprocessedUpdateTime(expirationTime); 29124 29125 if (workInProgressRootExitStatus === RootSuspendedWithDelay) { 29126 // The root already suspended with a delay, which means this render 29127 // definitely won't finish. Since we have a new update, let's mark it as 29128 // suspended now, right before marking the incoming update. This has the 29129 // effect of interrupting the current render and switching to the update. 29130 // TODO: This happens to work when receiving an update during the render 29131 // phase, because of the trick inside computeExpirationForFiber to 29132 // subtract 1 from `renderExpirationTime` to move it into a 29133 // separate bucket. But we should probably model it with an exception, 29134 // using the same mechanism we use to force hydration of a subtree. 29135 // TODO: This does not account for low pri updates that were already 29136 // scheduled before the root started rendering. Need to track the next 29137 // pending expiration time (perhaps by backtracking the return path) and 29138 // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. 29139 markRootSuspendedAtTime(root, renderExpirationTime$1); 29140 } 29141 } // Mark that the root has a pending update. 29142 29143 29144 markRootUpdatedAtTime(root, expirationTime); 29145 } 29146 29147 return root; 29148} 29149 29150function getNextRootExpirationTimeToWorkOn(root) { 29151 // Determines the next expiration time that the root should render, taking 29152 // into account levels that may be suspended, or levels that may have 29153 // received a ping. 29154 var lastExpiredTime = root.lastExpiredTime; 29155 29156 if (lastExpiredTime !== NoWork) { 29157 return lastExpiredTime; 29158 } // "Pending" refers to any update that hasn't committed yet, including if it 29159 // suspended. The "suspended" range is therefore a subset. 29160 29161 29162 var firstPendingTime = root.firstPendingTime; 29163 29164 if (!isRootSuspendedAtTime(root, firstPendingTime)) { 29165 // The highest priority pending time is not suspended. Let's work on that. 29166 return firstPendingTime; 29167 } // If the first pending time is suspended, check if there's a lower priority 29168 // pending level that we know about. Or check if we received a ping. Work 29169 // on whichever is higher priority. 29170 29171 29172 var lastPingedTime = root.lastPingedTime; 29173 var nextKnownPendingLevel = root.nextKnownPendingLevel; 29174 var nextLevel = lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel; 29175 29176 if ( nextLevel <= Idle && firstPendingTime !== nextLevel) { 29177 // Don't work on Idle/Never priority unless everything else is committed. 29178 return NoWork; 29179 } 29180 29181 return nextLevel; 29182} // Use this function to schedule a task for a root. There's only one task per 29183// root; if a task was already scheduled, we'll check to make sure the 29184// expiration time of the existing task is the same as the expiration time of 29185// the next level that the root has work on. This function is called on every 29186// update, and right before exiting a task. 29187 29188 29189function ensureRootIsScheduled(root) { 29190 var lastExpiredTime = root.lastExpiredTime; 29191 29192 if (lastExpiredTime !== NoWork) { 29193 // Special case: Expired work should flush synchronously. 29194 root.callbackExpirationTime = Sync; 29195 root.callbackPriority = ImmediatePriority; 29196 root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 29197 return; 29198 } 29199 29200 var expirationTime = getNextRootExpirationTimeToWorkOn(root); 29201 var existingCallbackNode = root.callbackNode; 29202 29203 if (expirationTime === NoWork) { 29204 // There's nothing to work on. 29205 if (existingCallbackNode !== null) { 29206 root.callbackNode = null; 29207 root.callbackExpirationTime = NoWork; 29208 root.callbackPriority = NoPriority; 29209 } 29210 29211 return; 29212 } // TODO: If this is an update, we already read the current time. Pass the 29213 // time as an argument. 29214 29215 29216 var currentTime = requestCurrentTimeForUpdate(); 29217 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and 29218 // expiration time. Otherwise, we'll cancel it and schedule a new one. 29219 29220 if (existingCallbackNode !== null) { 29221 var existingCallbackPriority = root.callbackPriority; 29222 var existingCallbackExpirationTime = root.callbackExpirationTime; 29223 29224 if ( // Callback must have the exact same expiration time. 29225 existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. 29226 existingCallbackPriority >= priorityLevel) { 29227 // Existing callback is sufficient. 29228 return; 29229 } // Need to schedule a new task. 29230 // TODO: Instead of scheduling a new task, we should be able to change the 29231 // priority of the existing one. 29232 29233 29234 cancelCallback(existingCallbackNode); 29235 } 29236 29237 root.callbackExpirationTime = expirationTime; 29238 root.callbackPriority = priorityLevel; 29239 var callbackNode; 29240 29241 if (expirationTime === Sync) { 29242 // Sync React callbacks are scheduled on a special internal queue 29243 callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 29244 } else { 29245 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects 29246 // ordering because tasks are processed in timeout order. 29247 { 29248 timeout: expirationTimeToMs(expirationTime) - now() 29249 }); 29250 } 29251 29252 root.callbackNode = callbackNode; 29253} // This is the entry point for every concurrent task, i.e. anything that 29254// goes through Scheduler. 29255 29256 29257function performConcurrentWorkOnRoot(root, didTimeout) { 29258 // Since we know we're in a React event, we can clear the current 29259 // event time. The next update will compute a new event time. 29260 currentEventTime = NoWork; 29261 29262 if (didTimeout) { 29263 // The render task took too long to complete. Mark the current time as 29264 // expired to synchronously render all expired work in a single batch. 29265 var currentTime = requestCurrentTimeForUpdate(); 29266 markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. 29267 29268 ensureRootIsScheduled(root); 29269 return null; 29270 } // Determine the next expiration time to work on, using the fields stored 29271 // on the root. 29272 29273 29274 var expirationTime = getNextRootExpirationTimeToWorkOn(root); 29275 29276 if (expirationTime !== NoWork) { 29277 var originalCallbackNode = root.callbackNode; 29278 29279 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 29280 { 29281 throw Error( "Should not already be working." ); 29282 } 29283 } 29284 29285 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack 29286 // and prepare a fresh one. Otherwise we'll continue where we left off. 29287 29288 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) { 29289 prepareFreshStack(root, expirationTime); 29290 startWorkOnPendingInteractions(root, expirationTime); 29291 } // If we have a work-in-progress fiber, it means there's still work to do 29292 // in this root. 29293 29294 29295 if (workInProgress !== null) { 29296 var prevExecutionContext = executionContext; 29297 executionContext |= RenderContext; 29298 var prevDispatcher = pushDispatcher(); 29299 var prevInteractions = pushInteractions(root); 29300 startWorkLoopTimer(workInProgress); 29301 29302 do { 29303 try { 29304 workLoopConcurrent(); 29305 break; 29306 } catch (thrownValue) { 29307 handleError(root, thrownValue); 29308 } 29309 } while (true); 29310 29311 resetContextDependencies(); 29312 executionContext = prevExecutionContext; 29313 popDispatcher(prevDispatcher); 29314 29315 { 29316 popInteractions(prevInteractions); 29317 } 29318 29319 if (workInProgressRootExitStatus === RootFatalErrored) { 29320 var fatalError = workInProgressRootFatalError; 29321 stopInterruptedWorkLoopTimer(); 29322 prepareFreshStack(root, expirationTime); 29323 markRootSuspendedAtTime(root, expirationTime); 29324 ensureRootIsScheduled(root); 29325 throw fatalError; 29326 } 29327 29328 if (workInProgress !== null) { 29329 // There's still work left over. Exit without committing. 29330 stopInterruptedWorkLoopTimer(); 29331 } else { 29332 // We now have a consistent tree. The next step is either to commit it, 29333 // or, if something suspended, wait to commit it after a timeout. 29334 stopFinishedWorkLoopTimer(); 29335 var finishedWork = root.finishedWork = root.current.alternate; 29336 root.finishedExpirationTime = expirationTime; 29337 finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime); 29338 } 29339 29340 ensureRootIsScheduled(root); 29341 29342 if (root.callbackNode === originalCallbackNode) { 29343 // The task node scheduled for this root is the same one that's 29344 // currently executed. Need to return a continuation. 29345 return performConcurrentWorkOnRoot.bind(null, root); 29346 } 29347 } 29348 } 29349 29350 return null; 29351} 29352 29353function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) { 29354 // Set this to null to indicate there's no in-progress render. 29355 workInProgressRoot = null; 29356 29357 switch (exitStatus) { 29358 case RootIncomplete: 29359 case RootFatalErrored: 29360 { 29361 { 29362 { 29363 throw Error( "Root did not complete. This is a bug in React." ); 29364 } 29365 } 29366 } 29367 // Flow knows about invariant, so it complains if I add a break 29368 // statement, but eslint doesn't know about invariant, so it complains 29369 // if I do. eslint-disable-next-line no-fallthrough 29370 29371 case RootErrored: 29372 { 29373 // If this was an async render, the error may have happened due to 29374 // a mutation in a concurrent event. Try rendering one more time, 29375 // synchronously, to see if the error goes away. If there are 29376 // lower priority updates, let's include those, too, in case they 29377 // fix the inconsistency. Render at Idle to include all updates. 29378 // If it was Idle or Never or some not-yet-invented time, render 29379 // at that time. 29380 markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime); // We assume that this second render pass will be synchronous 29381 // and therefore not hit this path again. 29382 29383 break; 29384 } 29385 29386 case RootSuspended: 29387 { 29388 markRootSuspendedAtTime(root, expirationTime); 29389 var lastSuspendedTime = root.lastSuspendedTime; 29390 29391 if (expirationTime === lastSuspendedTime) { 29392 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); 29393 } // We have an acceptable loading state. We need to figure out if we 29394 // should immediately commit it or wait a bit. 29395 // If we have processed new updates during this render, we may now 29396 // have a new loading state ready. We want to ensure that we commit 29397 // that as soon as possible. 29398 29399 29400 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync; 29401 29402 if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope 29403 !( IsThisRendererActing.current)) { 29404 // If we have not processed any new updates during this pass, then 29405 // this is either a retry of an existing fallback state or a 29406 // hidden tree. Hidden trees shouldn't be batched with other work 29407 // and after that's fixed it can only be a retry. We're going to 29408 // throttle committing retries so that we don't show too many 29409 // loading states too quickly. 29410 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. 29411 29412 if (msUntilTimeout > 10) { 29413 if (workInProgressRootHasPendingPing) { 29414 var lastPingedTime = root.lastPingedTime; 29415 29416 if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { 29417 // This render was pinged but we didn't get to restart 29418 // earlier so try restarting now instead. 29419 root.lastPingedTime = expirationTime; 29420 prepareFreshStack(root, expirationTime); 29421 break; 29422 } 29423 } 29424 29425 var nextTime = getNextRootExpirationTimeToWorkOn(root); 29426 29427 if (nextTime !== NoWork && nextTime !== expirationTime) { 29428 // There's additional work on this root. 29429 break; 29430 } 29431 29432 if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) { 29433 // We should prefer to render the fallback of at the last 29434 // suspended level. Ping the last suspended level to try 29435 // rendering it again. 29436 root.lastPingedTime = lastSuspendedTime; 29437 break; 29438 } // The render is suspended, it hasn't timed out, and there's no 29439 // lower priority work to do. Instead of committing the fallback 29440 // immediately, wait for more data to arrive. 29441 29442 29443 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout); 29444 break; 29445 } 29446 } // The work expired. Commit immediately. 29447 29448 29449 commitRoot(root); 29450 break; 29451 } 29452 29453 case RootSuspendedWithDelay: 29454 { 29455 markRootSuspendedAtTime(root, expirationTime); 29456 var _lastSuspendedTime = root.lastSuspendedTime; 29457 29458 if (expirationTime === _lastSuspendedTime) { 29459 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); 29460 } 29461 29462 if ( // do not delay if we're inside an act() scope 29463 !( IsThisRendererActing.current)) { 29464 // We're suspended in a state that should be avoided. We'll try to 29465 // avoid committing it for as long as the timeouts let us. 29466 if (workInProgressRootHasPendingPing) { 29467 var _lastPingedTime = root.lastPingedTime; 29468 29469 if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { 29470 // This render was pinged but we didn't get to restart earlier 29471 // so try restarting now instead. 29472 root.lastPingedTime = expirationTime; 29473 prepareFreshStack(root, expirationTime); 29474 break; 29475 } 29476 } 29477 29478 var _nextTime = getNextRootExpirationTimeToWorkOn(root); 29479 29480 if (_nextTime !== NoWork && _nextTime !== expirationTime) { 29481 // There's additional work on this root. 29482 break; 29483 } 29484 29485 if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) { 29486 // We should prefer to render the fallback of at the last 29487 // suspended level. Ping the last suspended level to try 29488 // rendering it again. 29489 root.lastPingedTime = _lastSuspendedTime; 29490 break; 29491 } 29492 29493 var _msUntilTimeout; 29494 29495 if (workInProgressRootLatestSuspenseTimeout !== Sync) { 29496 // We have processed a suspense config whose expiration time we 29497 // can use as the timeout. 29498 _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); 29499 } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { 29500 // This should never normally happen because only new updates 29501 // cause delayed states, so we should have processed something. 29502 // However, this could also happen in an offscreen tree. 29503 _msUntilTimeout = 0; 29504 } else { 29505 // If we don't have a suspense config, we're going to use a 29506 // heuristic to determine how long we can suspend. 29507 var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime); 29508 var currentTimeMs = now(); 29509 var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs; 29510 var timeElapsed = currentTimeMs - eventTimeMs; 29511 29512 if (timeElapsed < 0) { 29513 // We get this wrong some time since we estimate the time. 29514 timeElapsed = 0; 29515 } 29516 29517 _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the 29518 // event time is exact instead of inferred from expiration time 29519 // we don't need this. 29520 29521 if (timeUntilExpirationMs < _msUntilTimeout) { 29522 _msUntilTimeout = timeUntilExpirationMs; 29523 } 29524 } // Don't bother with a very short suspense time. 29525 29526 29527 if (_msUntilTimeout > 10) { 29528 // The render is suspended, it hasn't timed out, and there's no 29529 // lower priority work to do. Instead of committing the fallback 29530 // immediately, wait for more data to arrive. 29531 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout); 29532 break; 29533 } 29534 } // The work expired. Commit immediately. 29535 29536 29537 commitRoot(root); 29538 break; 29539 } 29540 29541 case RootCompleted: 29542 { 29543 // The work completed. Ready to commit. 29544 if ( // do not delay if we're inside an act() scope 29545 !( IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) { 29546 // If we have exceeded the minimum loading delay, which probably 29547 // means we have shown a spinner already, we might have to suspend 29548 // a bit longer to ensure that the spinner is shown for 29549 // enough time. 29550 var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig); 29551 29552 if (_msUntilTimeout2 > 10) { 29553 markRootSuspendedAtTime(root, expirationTime); 29554 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2); 29555 break; 29556 } 29557 } 29558 29559 commitRoot(root); 29560 break; 29561 } 29562 29563 default: 29564 { 29565 { 29566 { 29567 throw Error( "Unknown root exit status." ); 29568 } 29569 } 29570 } 29571 } 29572} // This is the entry point for synchronous tasks that don't go 29573// through Scheduler 29574 29575 29576function performSyncWorkOnRoot(root) { 29577 // Check if there's expired work on this root. Otherwise, render at Sync. 29578 var lastExpiredTime = root.lastExpiredTime; 29579 var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; 29580 29581 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 29582 { 29583 throw Error( "Should not already be working." ); 29584 } 29585 } 29586 29587 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack 29588 // and prepare a fresh one. Otherwise we'll continue where we left off. 29589 29590 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) { 29591 prepareFreshStack(root, expirationTime); 29592 startWorkOnPendingInteractions(root, expirationTime); 29593 } // If we have a work-in-progress fiber, it means there's still work to do 29594 // in this root. 29595 29596 29597 if (workInProgress !== null) { 29598 var prevExecutionContext = executionContext; 29599 executionContext |= RenderContext; 29600 var prevDispatcher = pushDispatcher(); 29601 var prevInteractions = pushInteractions(root); 29602 startWorkLoopTimer(workInProgress); 29603 29604 do { 29605 try { 29606 workLoopSync(); 29607 break; 29608 } catch (thrownValue) { 29609 handleError(root, thrownValue); 29610 } 29611 } while (true); 29612 29613 resetContextDependencies(); 29614 executionContext = prevExecutionContext; 29615 popDispatcher(prevDispatcher); 29616 29617 { 29618 popInteractions(prevInteractions); 29619 } 29620 29621 if (workInProgressRootExitStatus === RootFatalErrored) { 29622 var fatalError = workInProgressRootFatalError; 29623 stopInterruptedWorkLoopTimer(); 29624 prepareFreshStack(root, expirationTime); 29625 markRootSuspendedAtTime(root, expirationTime); 29626 ensureRootIsScheduled(root); 29627 throw fatalError; 29628 } 29629 29630 if (workInProgress !== null) { 29631 // This is a sync render, so we should have finished the whole tree. 29632 { 29633 { 29634 throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); 29635 } 29636 } 29637 } else { 29638 // We now have a consistent tree. Because this is a sync render, we 29639 // will commit it even if something suspended. 29640 stopFinishedWorkLoopTimer(); 29641 root.finishedWork = root.current.alternate; 29642 root.finishedExpirationTime = expirationTime; 29643 finishSyncRender(root); 29644 } // Before exiting, make sure there's a callback scheduled for the next 29645 // pending level. 29646 29647 29648 ensureRootIsScheduled(root); 29649 } 29650 29651 return null; 29652} 29653 29654function finishSyncRender(root) { 29655 // Set this to null to indicate there's no in-progress render. 29656 workInProgressRoot = null; 29657 commitRoot(root); 29658} 29659function flushDiscreteUpdates() { 29660 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`. 29661 // However, `act` uses `batchedUpdates`, so there's no way to distinguish 29662 // those two cases. Need to fix this before exposing flushDiscreteUpdates 29663 // as a public API. 29664 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) { 29665 { 29666 if ((executionContext & RenderContext) !== NoContext) { 29667 error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.'); 29668 } 29669 } // We're already rendering, so we can't synchronously flush pending work. 29670 // This is probably a nested event dispatch triggered by a lifecycle/effect, 29671 // like `el.focus()`. Exit. 29672 29673 29674 return; 29675 } 29676 29677 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that 29678 // they fire before the next serial event. 29679 29680 flushPassiveEffects(); 29681} 29682function syncUpdates(fn, a, b, c) { 29683 return runWithPriority$1(ImmediatePriority, fn.bind(null, a, b, c)); 29684} 29685 29686function flushPendingDiscreteUpdates() { 29687 if (rootsWithPendingDiscreteUpdates !== null) { 29688 // For each root with pending discrete updates, schedule a callback to 29689 // immediately flush them. 29690 var roots = rootsWithPendingDiscreteUpdates; 29691 rootsWithPendingDiscreteUpdates = null; 29692 roots.forEach(function (expirationTime, root) { 29693 markRootExpiredAtTime(root, expirationTime); 29694 ensureRootIsScheduled(root); 29695 }); // Now flush the immediate queue. 29696 29697 flushSyncCallbackQueue(); 29698 } 29699} 29700 29701function batchedUpdates$1(fn, a) { 29702 var prevExecutionContext = executionContext; 29703 executionContext |= BatchedContext; 29704 29705 try { 29706 return fn(a); 29707 } finally { 29708 executionContext = prevExecutionContext; 29709 29710 if (executionContext === NoContext) { 29711 // Flush the immediate callbacks that were scheduled during this batch 29712 flushSyncCallbackQueue(); 29713 } 29714 } 29715} 29716function batchedEventUpdates$1(fn, a) { 29717 var prevExecutionContext = executionContext; 29718 executionContext |= EventContext; 29719 29720 try { 29721 return fn(a); 29722 } finally { 29723 executionContext = prevExecutionContext; 29724 29725 if (executionContext === NoContext) { 29726 // Flush the immediate callbacks that were scheduled during this batch 29727 flushSyncCallbackQueue(); 29728 } 29729 } 29730} 29731function discreteUpdates$1(fn, a, b, c, d) { 29732 var prevExecutionContext = executionContext; 29733 executionContext |= DiscreteEventContext; 29734 29735 try { 29736 // Should this 29737 return runWithPriority$1(UserBlockingPriority$1, fn.bind(null, a, b, c, d)); 29738 } finally { 29739 executionContext = prevExecutionContext; 29740 29741 if (executionContext === NoContext) { 29742 // Flush the immediate callbacks that were scheduled during this batch 29743 flushSyncCallbackQueue(); 29744 } 29745 } 29746} 29747function unbatchedUpdates(fn, a) { 29748 var prevExecutionContext = executionContext; 29749 executionContext &= ~BatchedContext; 29750 executionContext |= LegacyUnbatchedContext; 29751 29752 try { 29753 return fn(a); 29754 } finally { 29755 executionContext = prevExecutionContext; 29756 29757 if (executionContext === NoContext) { 29758 // Flush the immediate callbacks that were scheduled during this batch 29759 flushSyncCallbackQueue(); 29760 } 29761 } 29762} 29763function flushSync(fn, a) { 29764 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 29765 { 29766 { 29767 throw Error( "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." ); 29768 } 29769 } 29770 } 29771 29772 var prevExecutionContext = executionContext; 29773 executionContext |= BatchedContext; 29774 29775 try { 29776 return runWithPriority$1(ImmediatePriority, fn.bind(null, a)); 29777 } finally { 29778 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. 29779 // Note that this will happen even if batchedUpdates is higher up 29780 // the stack. 29781 29782 flushSyncCallbackQueue(); 29783 } 29784} 29785 29786function prepareFreshStack(root, expirationTime) { 29787 root.finishedWork = null; 29788 root.finishedExpirationTime = NoWork; 29789 var timeoutHandle = root.timeoutHandle; 29790 29791 if (timeoutHandle !== noTimeout) { 29792 // The root previous suspended and scheduled a timeout to commit a fallback 29793 // state. Now that we have additional work, cancel the timeout. 29794 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above 29795 29796 cancelTimeout(timeoutHandle); 29797 } 29798 29799 if (workInProgress !== null) { 29800 var interruptedWork = workInProgress.return; 29801 29802 while (interruptedWork !== null) { 29803 unwindInterruptedWork(interruptedWork); 29804 interruptedWork = interruptedWork.return; 29805 } 29806 } 29807 29808 workInProgressRoot = root; 29809 workInProgress = createWorkInProgress(root.current, null); 29810 renderExpirationTime$1 = expirationTime; 29811 workInProgressRootExitStatus = RootIncomplete; 29812 workInProgressRootFatalError = null; 29813 workInProgressRootLatestProcessedExpirationTime = Sync; 29814 workInProgressRootLatestSuspenseTimeout = Sync; 29815 workInProgressRootCanSuspendUsingConfig = null; 29816 workInProgressRootNextUnprocessedUpdateTime = NoWork; 29817 workInProgressRootHasPendingPing = false; 29818 29819 { 29820 spawnedWorkDuringRender = null; 29821 } 29822 29823 { 29824 ReactStrictModeWarnings.discardPendingWarnings(); 29825 } 29826} 29827 29828function handleError(root, thrownValue) { 29829 do { 29830 try { 29831 // Reset module-level state that was set during the render phase. 29832 resetContextDependencies(); 29833 resetHooksAfterThrow(); 29834 resetCurrentFiber(); 29835 29836 if (workInProgress === null || workInProgress.return === null) { 29837 // Expected to be working on a non-root fiber. This is a fatal error 29838 // because there's no ancestor that can handle it; the root is 29839 // supposed to capture all errors that weren't caught by an error 29840 // boundary. 29841 workInProgressRootExitStatus = RootFatalErrored; 29842 workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next 29843 // sibling, or the parent if there are no siblings. But since the root 29844 // has no siblings nor a parent, we set it to null. Usually this is 29845 // handled by `completeUnitOfWork` or `unwindWork`, but since we're 29846 // interntionally not calling those, we need set it here. 29847 // TODO: Consider calling `unwindWork` to pop the contexts. 29848 29849 workInProgress = null; 29850 return null; 29851 } 29852 29853 if (enableProfilerTimer && workInProgress.mode & ProfileMode) { 29854 // Record the time spent rendering before an error was thrown. This 29855 // avoids inaccurate Profiler durations in the case of a 29856 // suspended render. 29857 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); 29858 } 29859 29860 throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime$1); 29861 workInProgress = completeUnitOfWork(workInProgress); 29862 } catch (yetAnotherThrownValue) { 29863 // Something in the return path also threw. 29864 thrownValue = yetAnotherThrownValue; 29865 continue; 29866 } // Return to the normal work loop. 29867 29868 29869 return; 29870 } while (true); 29871} 29872 29873function pushDispatcher(root) { 29874 var prevDispatcher = ReactCurrentDispatcher$1.current; 29875 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 29876 29877 if (prevDispatcher === null) { 29878 // The React isomorphic package does not include a default dispatcher. 29879 // Instead the first renderer will lazily attach one, in order to give 29880 // nicer error messages. 29881 return ContextOnlyDispatcher; 29882 } else { 29883 return prevDispatcher; 29884 } 29885} 29886 29887function popDispatcher(prevDispatcher) { 29888 ReactCurrentDispatcher$1.current = prevDispatcher; 29889} 29890 29891function pushInteractions(root) { 29892 { 29893 var prevInteractions = tracing.__interactionsRef.current; 29894 tracing.__interactionsRef.current = root.memoizedInteractions; 29895 return prevInteractions; 29896 } 29897} 29898 29899function popInteractions(prevInteractions) { 29900 { 29901 tracing.__interactionsRef.current = prevInteractions; 29902 } 29903} 29904 29905function markCommitTimeOfFallback() { 29906 globalMostRecentFallbackTime = now(); 29907} 29908function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { 29909 if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) { 29910 workInProgressRootLatestProcessedExpirationTime = expirationTime; 29911 } 29912 29913 if (suspenseConfig !== null) { 29914 if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) { 29915 workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. 29916 29917 workInProgressRootCanSuspendUsingConfig = suspenseConfig; 29918 } 29919 } 29920} 29921function markUnprocessedUpdateTime(expirationTime) { 29922 if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { 29923 workInProgressRootNextUnprocessedUpdateTime = expirationTime; 29924 } 29925} 29926function renderDidSuspend() { 29927 if (workInProgressRootExitStatus === RootIncomplete) { 29928 workInProgressRootExitStatus = RootSuspended; 29929 } 29930} 29931function renderDidSuspendDelayIfPossible() { 29932 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) { 29933 workInProgressRootExitStatus = RootSuspendedWithDelay; 29934 } // Check if there's a lower priority update somewhere else in the tree. 29935 29936 29937 if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) { 29938 // Mark the current render as suspended, and then mark that there's a 29939 // pending update. 29940 // TODO: This should immediately interrupt the current render, instead 29941 // of waiting until the next time we yield. 29942 markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); 29943 markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime); 29944 } 29945} 29946function renderDidError() { 29947 if (workInProgressRootExitStatus !== RootCompleted) { 29948 workInProgressRootExitStatus = RootErrored; 29949 } 29950} // Called during render to determine if anything has suspended. 29951// Returns false if we're not sure. 29952 29953function renderHasNotSuspendedYet() { 29954 // If something errored or completed, we can't really be sure, 29955 // so those are false. 29956 return workInProgressRootExitStatus === RootIncomplete; 29957} 29958 29959function inferTimeFromExpirationTime(expirationTime) { 29960 // We don't know exactly when the update was scheduled, but we can infer an 29961 // approximate start time from the expiration time. 29962 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); 29963 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; 29964} 29965 29966function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) { 29967 // We don't know exactly when the update was scheduled, but we can infer an 29968 // approximate start time from the expiration time by subtracting the timeout 29969 // that was added to the event time. 29970 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); 29971 return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION); 29972} // The work loop is an extremely hot path. Tell Closure not to inline it. 29973 29974/** @noinline */ 29975 29976 29977function workLoopSync() { 29978 // Already timed out, so perform work without checking if we need to yield. 29979 while (workInProgress !== null) { 29980 workInProgress = performUnitOfWork(workInProgress); 29981 } 29982} 29983/** @noinline */ 29984 29985 29986function workLoopConcurrent() { 29987 // Perform work until Scheduler asks us to yield 29988 while (workInProgress !== null && !shouldYield()) { 29989 workInProgress = performUnitOfWork(workInProgress); 29990 } 29991} 29992 29993function performUnitOfWork(unitOfWork) { 29994 // The current, flushed, state of this fiber is the alternate. Ideally 29995 // nothing should rely on this, but relying on it here means that we don't 29996 // need an additional field on the work in progress. 29997 var current = unitOfWork.alternate; 29998 startWorkTimer(unitOfWork); 29999 setCurrentFiber(unitOfWork); 30000 var next; 30001 30002 if ( (unitOfWork.mode & ProfileMode) !== NoMode) { 30003 startProfilerTimer(unitOfWork); 30004 next = beginWork$1(current, unitOfWork, renderExpirationTime$1); 30005 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); 30006 } else { 30007 next = beginWork$1(current, unitOfWork, renderExpirationTime$1); 30008 } 30009 30010 resetCurrentFiber(); 30011 unitOfWork.memoizedProps = unitOfWork.pendingProps; 30012 30013 if (next === null) { 30014 // If this doesn't spawn new work, complete the current work. 30015 next = completeUnitOfWork(unitOfWork); 30016 } 30017 30018 ReactCurrentOwner$2.current = null; 30019 return next; 30020} 30021 30022function completeUnitOfWork(unitOfWork) { 30023 // Attempt to complete the current unit of work, then move to the next 30024 // sibling. If there are no more siblings, return to the parent fiber. 30025 workInProgress = unitOfWork; 30026 30027 do { 30028 // The current, flushed, state of this fiber is the alternate. Ideally 30029 // nothing should rely on this, but relying on it here means that we don't 30030 // need an additional field on the work in progress. 30031 var current = workInProgress.alternate; 30032 var returnFiber = workInProgress.return; // Check if the work completed or if something threw. 30033 30034 if ((workInProgress.effectTag & Incomplete) === NoEffect) { 30035 setCurrentFiber(workInProgress); 30036 var next = void 0; 30037 30038 if ( (workInProgress.mode & ProfileMode) === NoMode) { 30039 next = completeWork(current, workInProgress, renderExpirationTime$1); 30040 } else { 30041 startProfilerTimer(workInProgress); 30042 next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. 30043 30044 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); 30045 } 30046 30047 stopWorkTimer(workInProgress); 30048 resetCurrentFiber(); 30049 resetChildExpirationTime(workInProgress); 30050 30051 if (next !== null) { 30052 // Completing this fiber spawned new work. Work on that next. 30053 return next; 30054 } 30055 30056 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete 30057 (returnFiber.effectTag & Incomplete) === NoEffect) { 30058 // Append all the effects of the subtree and this fiber onto the effect 30059 // list of the parent. The completion order of the children affects the 30060 // side-effect order. 30061 if (returnFiber.firstEffect === null) { 30062 returnFiber.firstEffect = workInProgress.firstEffect; 30063 } 30064 30065 if (workInProgress.lastEffect !== null) { 30066 if (returnFiber.lastEffect !== null) { 30067 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; 30068 } 30069 30070 returnFiber.lastEffect = workInProgress.lastEffect; 30071 } // If this fiber had side-effects, we append it AFTER the children's 30072 // side-effects. We can perform certain side-effects earlier if needed, 30073 // by doing multiple passes over the effect list. We don't want to 30074 // schedule our own side-effect on our own list because if end up 30075 // reusing children we'll schedule this effect onto itself since we're 30076 // at the end. 30077 30078 30079 var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect 30080 // list. PerformedWork effect is read by React DevTools but shouldn't be 30081 // committed. 30082 30083 if (effectTag > PerformedWork) { 30084 if (returnFiber.lastEffect !== null) { 30085 returnFiber.lastEffect.nextEffect = workInProgress; 30086 } else { 30087 returnFiber.firstEffect = workInProgress; 30088 } 30089 30090 returnFiber.lastEffect = workInProgress; 30091 } 30092 } 30093 } else { 30094 // This fiber did not complete because something threw. Pop values off 30095 // the stack without entering the complete phase. If this is a boundary, 30096 // capture values if possible. 30097 var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. 30098 30099 30100 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 30101 // Record the render duration for the fiber that errored. 30102 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. 30103 30104 var actualDuration = workInProgress.actualDuration; 30105 var child = workInProgress.child; 30106 30107 while (child !== null) { 30108 actualDuration += child.actualDuration; 30109 child = child.sibling; 30110 } 30111 30112 workInProgress.actualDuration = actualDuration; 30113 } 30114 30115 if (_next !== null) { 30116 // If completing this work spawned new work, do that next. We'll come 30117 // back here again. 30118 // Since we're restarting, remove anything that is not a host effect 30119 // from the effect tag. 30120 // TODO: The name stopFailedWorkTimer is misleading because Suspense 30121 // also captures and restarts. 30122 stopFailedWorkTimer(workInProgress); 30123 _next.effectTag &= HostEffectMask; 30124 return _next; 30125 } 30126 30127 stopWorkTimer(workInProgress); 30128 30129 if (returnFiber !== null) { 30130 // Mark the parent fiber as incomplete and clear its effect list. 30131 returnFiber.firstEffect = returnFiber.lastEffect = null; 30132 returnFiber.effectTag |= Incomplete; 30133 } 30134 } 30135 30136 var siblingFiber = workInProgress.sibling; 30137 30138 if (siblingFiber !== null) { 30139 // If there is more work to do in this returnFiber, do that next. 30140 return siblingFiber; 30141 } // Otherwise, return to the parent 30142 30143 30144 workInProgress = returnFiber; 30145 } while (workInProgress !== null); // We've reached the root. 30146 30147 30148 if (workInProgressRootExitStatus === RootIncomplete) { 30149 workInProgressRootExitStatus = RootCompleted; 30150 } 30151 30152 return null; 30153} 30154 30155function getRemainingExpirationTime(fiber) { 30156 var updateExpirationTime = fiber.expirationTime; 30157 var childExpirationTime = fiber.childExpirationTime; 30158 return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime; 30159} 30160 30161function resetChildExpirationTime(completedWork) { 30162 if (renderExpirationTime$1 !== Never && completedWork.childExpirationTime === Never) { 30163 // The children of this component are hidden. Don't bubble their 30164 // expiration times. 30165 return; 30166 } 30167 30168 var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. 30169 30170 if ( (completedWork.mode & ProfileMode) !== NoMode) { 30171 // In profiling mode, resetChildExpirationTime is also used to reset 30172 // profiler durations. 30173 var actualDuration = completedWork.actualDuration; 30174 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will 30175 // only be updated if work is done on the fiber (i.e. it doesn't bailout). 30176 // When work is done, it should bubble to the parent's actualDuration. If 30177 // the fiber has not been cloned though, (meaning no work was done), then 30178 // this value will reflect the amount of time spent working on a previous 30179 // render. In that case it should not bubble. We determine whether it was 30180 // cloned by comparing the child pointer. 30181 30182 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child; 30183 var child = completedWork.child; 30184 30185 while (child !== null) { 30186 var childUpdateExpirationTime = child.expirationTime; 30187 var childChildExpirationTime = child.childExpirationTime; 30188 30189 if (childUpdateExpirationTime > newChildExpirationTime) { 30190 newChildExpirationTime = childUpdateExpirationTime; 30191 } 30192 30193 if (childChildExpirationTime > newChildExpirationTime) { 30194 newChildExpirationTime = childChildExpirationTime; 30195 } 30196 30197 if (shouldBubbleActualDurations) { 30198 actualDuration += child.actualDuration; 30199 } 30200 30201 treeBaseDuration += child.treeBaseDuration; 30202 child = child.sibling; 30203 } 30204 30205 completedWork.actualDuration = actualDuration; 30206 completedWork.treeBaseDuration = treeBaseDuration; 30207 } else { 30208 var _child = completedWork.child; 30209 30210 while (_child !== null) { 30211 var _childUpdateExpirationTime = _child.expirationTime; 30212 var _childChildExpirationTime = _child.childExpirationTime; 30213 30214 if (_childUpdateExpirationTime > newChildExpirationTime) { 30215 newChildExpirationTime = _childUpdateExpirationTime; 30216 } 30217 30218 if (_childChildExpirationTime > newChildExpirationTime) { 30219 newChildExpirationTime = _childChildExpirationTime; 30220 } 30221 30222 _child = _child.sibling; 30223 } 30224 } 30225 30226 completedWork.childExpirationTime = newChildExpirationTime; 30227} 30228 30229function commitRoot(root) { 30230 var renderPriorityLevel = getCurrentPriorityLevel(); 30231 runWithPriority$1(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel)); 30232 return null; 30233} 30234 30235function commitRootImpl(root, renderPriorityLevel) { 30236 do { 30237 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which 30238 // means `flushPassiveEffects` will sometimes result in additional 30239 // passive effects. So we need to keep flushing in a loop until there are 30240 // no more pending effects. 30241 // TODO: Might be better if `flushPassiveEffects` did not automatically 30242 // flush synchronous work at the end, to avoid factoring hazards like this. 30243 flushPassiveEffects(); 30244 } while (rootWithPendingPassiveEffects !== null); 30245 30246 flushRenderPhaseStrictModeWarningsInDEV(); 30247 30248 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 30249 { 30250 throw Error( "Should not already be working." ); 30251 } 30252 } 30253 30254 var finishedWork = root.finishedWork; 30255 var expirationTime = root.finishedExpirationTime; 30256 30257 if (finishedWork === null) { 30258 return null; 30259 } 30260 30261 root.finishedWork = null; 30262 root.finishedExpirationTime = NoWork; 30263 30264 if (!(finishedWork !== root.current)) { 30265 { 30266 throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); 30267 } 30268 } // commitRoot never returns a continuation; it always finishes synchronously. 30269 // So we can clear these now to allow a new callback to be scheduled. 30270 30271 30272 root.callbackNode = null; 30273 root.callbackExpirationTime = NoWork; 30274 root.callbackPriority = NoPriority; 30275 root.nextKnownPendingLevel = NoWork; 30276 startCommitTimer(); // Update the first and last pending times on this root. The new first 30277 // pending time is whatever is left on the root fiber. 30278 30279 var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork); 30280 markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit); 30281 30282 if (root === workInProgressRoot) { 30283 // We can reset these now that they are finished. 30284 workInProgressRoot = null; 30285 workInProgress = null; 30286 renderExpirationTime$1 = NoWork; 30287 } // This indicates that the last root we worked on is not the same one that 30288 // we're committing now. This most commonly happens when a suspended root 30289 // times out. 30290 // Get the list of effects. 30291 30292 30293 var firstEffect; 30294 30295 if (finishedWork.effectTag > PerformedWork) { 30296 // A fiber's effect list consists only of its children, not itself. So if 30297 // the root has an effect, we need to add it to the end of the list. The 30298 // resulting list is the set that would belong to the root's parent, if it 30299 // had one; that is, all the effects in the tree including the root. 30300 if (finishedWork.lastEffect !== null) { 30301 finishedWork.lastEffect.nextEffect = finishedWork; 30302 firstEffect = finishedWork.firstEffect; 30303 } else { 30304 firstEffect = finishedWork; 30305 } 30306 } else { 30307 // There is no effect on the root. 30308 firstEffect = finishedWork.firstEffect; 30309 } 30310 30311 if (firstEffect !== null) { 30312 var prevExecutionContext = executionContext; 30313 executionContext |= CommitContext; 30314 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles 30315 30316 ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass 30317 // of the effect list for each phase: all mutation effects come before all 30318 // layout effects, and so on. 30319 // The first phase a "before mutation" phase. We use this phase to read the 30320 // state of the host tree right before we mutate it. This is where 30321 // getSnapshotBeforeUpdate is called. 30322 30323 startCommitSnapshotEffectsTimer(); 30324 prepareForCommit(root.containerInfo); 30325 nextEffect = firstEffect; 30326 30327 do { 30328 { 30329 invokeGuardedCallback(null, commitBeforeMutationEffects, null); 30330 30331 if (hasCaughtError()) { 30332 if (!(nextEffect !== null)) { 30333 { 30334 throw Error( "Should be working on an effect." ); 30335 } 30336 } 30337 30338 var error = clearCaughtError(); 30339 captureCommitPhaseError(nextEffect, error); 30340 nextEffect = nextEffect.nextEffect; 30341 } 30342 } 30343 } while (nextEffect !== null); 30344 30345 stopCommitSnapshotEffectsTimer(); 30346 30347 { 30348 // Mark the current commit time to be shared by all Profilers in this 30349 // batch. This enables them to be grouped later. 30350 recordCommitTime(); 30351 } // The next phase is the mutation phase, where we mutate the host tree. 30352 30353 30354 startCommitHostEffectsTimer(); 30355 nextEffect = firstEffect; 30356 30357 do { 30358 { 30359 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel); 30360 30361 if (hasCaughtError()) { 30362 if (!(nextEffect !== null)) { 30363 { 30364 throw Error( "Should be working on an effect." ); 30365 } 30366 } 30367 30368 var _error = clearCaughtError(); 30369 30370 captureCommitPhaseError(nextEffect, _error); 30371 nextEffect = nextEffect.nextEffect; 30372 } 30373 } 30374 } while (nextEffect !== null); 30375 30376 stopCommitHostEffectsTimer(); 30377 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after 30378 // the mutation phase, so that the previous tree is still current during 30379 // componentWillUnmount, but before the layout phase, so that the finished 30380 // work is current during componentDidMount/Update. 30381 30382 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read 30383 // the host tree after it's been mutated. The idiomatic use case for this is 30384 // layout, but class component lifecycles also fire here for legacy reasons. 30385 30386 startCommitLifeCyclesTimer(); 30387 nextEffect = firstEffect; 30388 30389 do { 30390 { 30391 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime); 30392 30393 if (hasCaughtError()) { 30394 if (!(nextEffect !== null)) { 30395 { 30396 throw Error( "Should be working on an effect." ); 30397 } 30398 } 30399 30400 var _error2 = clearCaughtError(); 30401 30402 captureCommitPhaseError(nextEffect, _error2); 30403 nextEffect = nextEffect.nextEffect; 30404 } 30405 } 30406 } while (nextEffect !== null); 30407 30408 stopCommitLifeCyclesTimer(); 30409 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an 30410 // opportunity to paint. 30411 30412 requestPaint(); 30413 30414 { 30415 popInteractions(prevInteractions); 30416 } 30417 30418 executionContext = prevExecutionContext; 30419 } else { 30420 // No effects. 30421 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were 30422 // no effects. 30423 // TODO: Maybe there's a better way to report this. 30424 30425 startCommitSnapshotEffectsTimer(); 30426 stopCommitSnapshotEffectsTimer(); 30427 30428 { 30429 recordCommitTime(); 30430 } 30431 30432 startCommitHostEffectsTimer(); 30433 stopCommitHostEffectsTimer(); 30434 startCommitLifeCyclesTimer(); 30435 stopCommitLifeCyclesTimer(); 30436 } 30437 30438 stopCommitTimer(); 30439 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; 30440 30441 if (rootDoesHavePassiveEffects) { 30442 // This commit has passive effects. Stash a reference to them. But don't 30443 // schedule a callback until after flushing layout work. 30444 rootDoesHavePassiveEffects = false; 30445 rootWithPendingPassiveEffects = root; 30446 pendingPassiveEffectsExpirationTime = expirationTime; 30447 pendingPassiveEffectsRenderPriority = renderPriorityLevel; 30448 } else { 30449 // We are done with the effect chain at this point so let's clear the 30450 // nextEffect pointers to assist with GC. If we have passive effects, we'll 30451 // clear this in flushPassiveEffects. 30452 nextEffect = firstEffect; 30453 30454 while (nextEffect !== null) { 30455 var nextNextEffect = nextEffect.nextEffect; 30456 nextEffect.nextEffect = null; 30457 nextEffect = nextNextEffect; 30458 } 30459 } // Check if there's remaining work on this root 30460 30461 30462 var remainingExpirationTime = root.firstPendingTime; 30463 30464 if (remainingExpirationTime !== NoWork) { 30465 { 30466 if (spawnedWorkDuringRender !== null) { 30467 var expirationTimes = spawnedWorkDuringRender; 30468 spawnedWorkDuringRender = null; 30469 30470 for (var i = 0; i < expirationTimes.length; i++) { 30471 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions); 30472 } 30473 } 30474 30475 schedulePendingInteractions(root, remainingExpirationTime); 30476 } 30477 } else { 30478 // If there's no remaining work, we can clear the set of already failed 30479 // error boundaries. 30480 legacyErrorBoundariesThatAlreadyFailed = null; 30481 } 30482 30483 { 30484 if (!rootDidHavePassiveEffects) { 30485 // If there are no passive effects, then we can complete the pending interactions. 30486 // Otherwise, we'll wait until after the passive effects are flushed. 30487 // Wait to do this until after remaining work has been scheduled, 30488 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. 30489 finishPendingInteractions(root, expirationTime); 30490 } 30491 } 30492 30493 if (remainingExpirationTime === Sync) { 30494 // Count the number of times the root synchronously re-renders without 30495 // finishing. If there are too many, it indicates an infinite update loop. 30496 if (root === rootWithNestedUpdates) { 30497 nestedUpdateCount++; 30498 } else { 30499 nestedUpdateCount = 0; 30500 rootWithNestedUpdates = root; 30501 } 30502 } else { 30503 nestedUpdateCount = 0; 30504 } 30505 30506 onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any 30507 // additional work on this root is scheduled. 30508 30509 ensureRootIsScheduled(root); 30510 30511 if (hasUncaughtError) { 30512 hasUncaughtError = false; 30513 var _error3 = firstUncaughtError; 30514 firstUncaughtError = null; 30515 throw _error3; 30516 } 30517 30518 if ((executionContext & LegacyUnbatchedContext) !== NoContext) { 30519 // This is a legacy edge case. We just committed the initial mount of 30520 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired 30521 // synchronously, but layout updates should be deferred until the end 30522 // of the batch. 30523 return null; 30524 } // If layout work was scheduled, flush it now. 30525 30526 30527 flushSyncCallbackQueue(); 30528 return null; 30529} 30530 30531function commitBeforeMutationEffects() { 30532 while (nextEffect !== null) { 30533 var effectTag = nextEffect.effectTag; 30534 30535 if ((effectTag & Snapshot) !== NoEffect) { 30536 setCurrentFiber(nextEffect); 30537 recordEffect(); 30538 var current = nextEffect.alternate; 30539 commitBeforeMutationLifeCycles(current, nextEffect); 30540 resetCurrentFiber(); 30541 } 30542 30543 if ((effectTag & Passive) !== NoEffect) { 30544 // If there are passive effects, schedule a callback to flush at 30545 // the earliest opportunity. 30546 if (!rootDoesHavePassiveEffects) { 30547 rootDoesHavePassiveEffects = true; 30548 scheduleCallback(NormalPriority, function () { 30549 flushPassiveEffects(); 30550 return null; 30551 }); 30552 } 30553 } 30554 30555 nextEffect = nextEffect.nextEffect; 30556 } 30557} 30558 30559function commitMutationEffects(root, renderPriorityLevel) { 30560 // TODO: Should probably move the bulk of this function to commitWork. 30561 while (nextEffect !== null) { 30562 setCurrentFiber(nextEffect); 30563 var effectTag = nextEffect.effectTag; 30564 30565 if (effectTag & ContentReset) { 30566 commitResetTextContent(nextEffect); 30567 } 30568 30569 if (effectTag & Ref) { 30570 var current = nextEffect.alternate; 30571 30572 if (current !== null) { 30573 commitDetachRef(current); 30574 } 30575 } // The following switch statement is only concerned about placement, 30576 // updates, and deletions. To avoid needing to add a case for every possible 30577 // bitmap value, we remove the secondary effects from the effect tag and 30578 // switch on that value. 30579 30580 30581 var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating); 30582 30583 switch (primaryEffectTag) { 30584 case Placement: 30585 { 30586 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 30587 // inserted, before any life-cycles like componentDidMount gets called. 30588 // TODO: findDOMNode doesn't rely on this any more but isMounted does 30589 // and isMounted is deprecated anyway so we should be able to kill this. 30590 30591 nextEffect.effectTag &= ~Placement; 30592 break; 30593 } 30594 30595 case PlacementAndUpdate: 30596 { 30597 // Placement 30598 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 30599 // inserted, before any life-cycles like componentDidMount gets called. 30600 30601 nextEffect.effectTag &= ~Placement; // Update 30602 30603 var _current = nextEffect.alternate; 30604 commitWork(_current, nextEffect); 30605 break; 30606 } 30607 30608 case Hydrating: 30609 { 30610 nextEffect.effectTag &= ~Hydrating; 30611 break; 30612 } 30613 30614 case HydratingAndUpdate: 30615 { 30616 nextEffect.effectTag &= ~Hydrating; // Update 30617 30618 var _current2 = nextEffect.alternate; 30619 commitWork(_current2, nextEffect); 30620 break; 30621 } 30622 30623 case Update: 30624 { 30625 var _current3 = nextEffect.alternate; 30626 commitWork(_current3, nextEffect); 30627 break; 30628 } 30629 30630 case Deletion: 30631 { 30632 commitDeletion(root, nextEffect, renderPriorityLevel); 30633 break; 30634 } 30635 } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. 30636 30637 30638 recordEffect(); 30639 resetCurrentFiber(); 30640 nextEffect = nextEffect.nextEffect; 30641 } 30642} 30643 30644function commitLayoutEffects(root, committedExpirationTime) { 30645 // TODO: Should probably move the bulk of this function to commitWork. 30646 while (nextEffect !== null) { 30647 setCurrentFiber(nextEffect); 30648 var effectTag = nextEffect.effectTag; 30649 30650 if (effectTag & (Update | Callback)) { 30651 recordEffect(); 30652 var current = nextEffect.alternate; 30653 commitLifeCycles(root, current, nextEffect); 30654 } 30655 30656 if (effectTag & Ref) { 30657 recordEffect(); 30658 commitAttachRef(nextEffect); 30659 } 30660 30661 resetCurrentFiber(); 30662 nextEffect = nextEffect.nextEffect; 30663 } 30664} 30665 30666function flushPassiveEffects() { 30667 if (pendingPassiveEffectsRenderPriority !== NoPriority) { 30668 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority; 30669 pendingPassiveEffectsRenderPriority = NoPriority; 30670 return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); 30671 } 30672} 30673 30674function flushPassiveEffectsImpl() { 30675 if (rootWithPendingPassiveEffects === null) { 30676 return false; 30677 } 30678 30679 var root = rootWithPendingPassiveEffects; 30680 var expirationTime = pendingPassiveEffectsExpirationTime; 30681 rootWithPendingPassiveEffects = null; 30682 pendingPassiveEffectsExpirationTime = NoWork; 30683 30684 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 30685 { 30686 throw Error( "Cannot flush passive effects while already rendering." ); 30687 } 30688 } 30689 30690 var prevExecutionContext = executionContext; 30691 executionContext |= CommitContext; 30692 var prevInteractions = pushInteractions(root); 30693 30694 { 30695 // Note: This currently assumes there are no passive effects on the root fiber 30696 // because the root is not part of its own effect list. 30697 // This could change in the future. 30698 var _effect2 = root.current.firstEffect; 30699 30700 while (_effect2 !== null) { 30701 { 30702 setCurrentFiber(_effect2); 30703 invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); 30704 30705 if (hasCaughtError()) { 30706 if (!(_effect2 !== null)) { 30707 { 30708 throw Error( "Should be working on an effect." ); 30709 } 30710 } 30711 30712 var _error5 = clearCaughtError(); 30713 30714 captureCommitPhaseError(_effect2, _error5); 30715 } 30716 30717 resetCurrentFiber(); 30718 } 30719 30720 var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC 30721 30722 _effect2.nextEffect = null; 30723 _effect2 = nextNextEffect; 30724 } 30725 } 30726 30727 { 30728 popInteractions(prevInteractions); 30729 finishPendingInteractions(root, expirationTime); 30730 } 30731 30732 executionContext = prevExecutionContext; 30733 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this 30734 // exceeds the limit, we'll fire a warning. 30735 30736 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; 30737 return true; 30738} 30739 30740function isAlreadyFailedLegacyErrorBoundary(instance) { 30741 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); 30742} 30743function markLegacyErrorBoundaryAsFailed(instance) { 30744 if (legacyErrorBoundariesThatAlreadyFailed === null) { 30745 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); 30746 } else { 30747 legacyErrorBoundariesThatAlreadyFailed.add(instance); 30748 } 30749} 30750 30751function prepareToThrowUncaughtError(error) { 30752 if (!hasUncaughtError) { 30753 hasUncaughtError = true; 30754 firstUncaughtError = error; 30755 } 30756} 30757 30758var onUncaughtError = prepareToThrowUncaughtError; 30759 30760function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { 30761 var errorInfo = createCapturedValue(error, sourceFiber); 30762 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); 30763 enqueueUpdate(rootFiber, update); 30764 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); 30765 30766 if (root !== null) { 30767 ensureRootIsScheduled(root); 30768 schedulePendingInteractions(root, Sync); 30769 } 30770} 30771 30772function captureCommitPhaseError(sourceFiber, error) { 30773 if (sourceFiber.tag === HostRoot) { 30774 // Error was thrown at the root. There is no parent, so the root 30775 // itself should capture it. 30776 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); 30777 return; 30778 } 30779 30780 var fiber = sourceFiber.return; 30781 30782 while (fiber !== null) { 30783 if (fiber.tag === HostRoot) { 30784 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); 30785 return; 30786 } else if (fiber.tag === ClassComponent) { 30787 var ctor = fiber.type; 30788 var instance = fiber.stateNode; 30789 30790 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 30791 var errorInfo = createCapturedValue(error, sourceFiber); 30792 var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync 30793 Sync); 30794 enqueueUpdate(fiber, update); 30795 var root = markUpdateTimeFromFiberToRoot(fiber, Sync); 30796 30797 if (root !== null) { 30798 ensureRootIsScheduled(root); 30799 schedulePendingInteractions(root, Sync); 30800 } 30801 30802 return; 30803 } 30804 } 30805 30806 fiber = fiber.return; 30807 } 30808} 30809function pingSuspendedRoot(root, thenable, suspendedTime) { 30810 var pingCache = root.pingCache; 30811 30812 if (pingCache !== null) { 30813 // The thenable resolved, so we no longer need to memoize, because it will 30814 // never be thrown again. 30815 pingCache.delete(thenable); 30816 } 30817 30818 if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { 30819 // Received a ping at the same priority level at which we're currently 30820 // rendering. We might want to restart this render. This should mirror 30821 // the logic of whether or not a root suspends once it completes. 30822 // TODO: If we're rendering sync either due to Sync, Batched or expired, 30823 // we should probably never restart. 30824 // If we're suspended with delay, we'll always suspend so we can always 30825 // restart. If we're suspended without any updates, it might be a retry. 30826 // If it's early in the retry we can restart. We can't know for sure 30827 // whether we'll eventually process an update during this render pass, 30828 // but it's somewhat unlikely that we get to a ping before that, since 30829 // getting to the root most update is usually very fast. 30830 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) { 30831 // Restart from the root. Don't need to schedule a ping because 30832 // we're already working on this tree. 30833 prepareFreshStack(root, renderExpirationTime$1); 30834 } else { 30835 // Even though we can't restart right now, we might get an 30836 // opportunity later. So we mark this render as having a ping. 30837 workInProgressRootHasPendingPing = true; 30838 } 30839 30840 return; 30841 } 30842 30843 if (!isRootSuspendedAtTime(root, suspendedTime)) { 30844 // The root is no longer suspended at this time. 30845 return; 30846 } 30847 30848 var lastPingedTime = root.lastPingedTime; 30849 30850 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { 30851 // There's already a lower priority ping scheduled. 30852 return; 30853 } // Mark the time at which this ping was scheduled. 30854 30855 30856 root.lastPingedTime = suspendedTime; 30857 30858 ensureRootIsScheduled(root); 30859 schedulePendingInteractions(root, suspendedTime); 30860} 30861 30862function retryTimedOutBoundary(boundaryFiber, retryTime) { 30863 // The boundary fiber (a Suspense component or SuspenseList component) 30864 // previously was rendered in its fallback state. One of the promises that 30865 // suspended it has resolved, which means at least part of the tree was 30866 // likely unblocked. Try rendering again, at a new expiration time. 30867 if (retryTime === NoWork) { 30868 var suspenseConfig = null; // Retries don't carry over the already committed update. 30869 30870 var currentTime = requestCurrentTimeForUpdate(); 30871 retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig); 30872 } // TODO: Special case idle priority? 30873 30874 30875 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); 30876 30877 if (root !== null) { 30878 ensureRootIsScheduled(root); 30879 schedulePendingInteractions(root, retryTime); 30880 } 30881} 30882function resolveRetryThenable(boundaryFiber, thenable) { 30883 var retryTime = NoWork; // Default 30884 30885 var retryCache; 30886 30887 { 30888 retryCache = boundaryFiber.stateNode; 30889 } 30890 30891 if (retryCache !== null) { 30892 // The thenable resolved, so we no longer need to memoize, because it will 30893 // never be thrown again. 30894 retryCache.delete(thenable); 30895 } 30896 30897 retryTimedOutBoundary(boundaryFiber, retryTime); 30898} // Computes the next Just Noticeable Difference (JND) boundary. 30899// The theory is that a person can't tell the difference between small differences in time. 30900// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable 30901// difference in the experience. However, waiting for longer might mean that we can avoid 30902// showing an intermediate loading state. The longer we have already waited, the harder it 30903// is to tell small differences in time. Therefore, the longer we've already waited, 30904// the longer we can wait additionally. At some point we have to give up though. 30905// We pick a train model where the next boundary commits at a consistent schedule. 30906// These particular numbers are vague estimates. We expect to adjust them based on research. 30907 30908function jnd(timeElapsed) { 30909 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; 30910} 30911 30912function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) { 30913 var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; 30914 30915 if (busyMinDurationMs <= 0) { 30916 return 0; 30917 } 30918 30919 var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. 30920 30921 var currentTimeMs = now(); 30922 var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig); 30923 var timeElapsed = currentTimeMs - eventTimeMs; 30924 30925 if (timeElapsed <= busyDelayMs) { 30926 // If we haven't yet waited longer than the initial delay, we don't 30927 // have to wait any additional time. 30928 return 0; 30929 } 30930 30931 var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. 30932 30933 return msUntilTimeout; 30934} 30935 30936function checkForNestedUpdates() { 30937 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 30938 nestedUpdateCount = 0; 30939 rootWithNestedUpdates = null; 30940 30941 { 30942 { 30943 throw Error( "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." ); 30944 } 30945 } 30946 } 30947 30948 { 30949 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { 30950 nestedPassiveUpdateCount = 0; 30951 30952 error('Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.'); 30953 } 30954 } 30955} 30956 30957function flushRenderPhaseStrictModeWarningsInDEV() { 30958 { 30959 ReactStrictModeWarnings.flushLegacyContextWarning(); 30960 30961 { 30962 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); 30963 } 30964 } 30965} 30966 30967function stopFinishedWorkLoopTimer() { 30968 var didCompleteRoot = true; 30969 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 30970 interruptedBy = null; 30971} 30972 30973function stopInterruptedWorkLoopTimer() { 30974 // TODO: Track which fiber caused the interruption. 30975 var didCompleteRoot = false; 30976 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 30977 interruptedBy = null; 30978} 30979 30980function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { 30981 if ( workInProgressRoot !== null && updateExpirationTime > renderExpirationTime$1) { 30982 interruptedBy = fiberThatReceivedUpdate; 30983 } 30984} 30985 30986var didWarnStateUpdateForUnmountedComponent = null; 30987 30988function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { 30989 { 30990 var tag = fiber.tag; 30991 30992 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 30993 // Only warn for user-defined components, not internal ones like Suspense. 30994 return; 30995 } 30996 // the problematic code almost always lies inside that component. 30997 30998 30999 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 31000 31001 if (didWarnStateUpdateForUnmountedComponent !== null) { 31002 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { 31003 return; 31004 } 31005 31006 didWarnStateUpdateForUnmountedComponent.add(componentName); 31007 } else { 31008 didWarnStateUpdateForUnmountedComponent = new Set([componentName]); 31009 } 31010 31011 error("Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber)); 31012 } 31013} 31014 31015var beginWork$1; 31016 31017{ 31018 var dummyFiber = null; 31019 31020 beginWork$1 = function (current, unitOfWork, expirationTime) { 31021 // If a component throws an error, we replay it again in a synchronously 31022 // dispatched event, so that the debugger will treat it as an uncaught 31023 // error See ReactErrorUtils for more information. 31024 // Before entering the begin phase, copy the work-in-progress onto a dummy 31025 // fiber. If beginWork throws, we'll use this to reset the state. 31026 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork); 31027 31028 try { 31029 return beginWork(current, unitOfWork, expirationTime); 31030 } catch (originalError) { 31031 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') { 31032 // Don't replay promises. Treat everything else like an error. 31033 throw originalError; 31034 } // Keep this code in sync with handleError; any changes here must have 31035 // corresponding changes there. 31036 31037 31038 resetContextDependencies(); 31039 resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the 31040 // same fiber again. 31041 // Unwind the failed stack frame 31042 31043 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. 31044 31045 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); 31046 31047 if ( unitOfWork.mode & ProfileMode) { 31048 // Reset the profiler timer. 31049 startProfilerTimer(unitOfWork); 31050 } // Run beginWork again. 31051 31052 31053 invokeGuardedCallback(null, beginWork, null, current, unitOfWork, expirationTime); 31054 31055 if (hasCaughtError()) { 31056 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. 31057 // Rethrow this error instead of the original one. 31058 31059 throw replayError; 31060 } else { 31061 // This branch is reachable if the render phase is impure. 31062 throw originalError; 31063 } 31064 } 31065 }; 31066} 31067 31068var didWarnAboutUpdateInRender = false; 31069var didWarnAboutUpdateInRenderForAnotherComponent; 31070 31071{ 31072 didWarnAboutUpdateInRenderForAnotherComponent = new Set(); 31073} 31074 31075function warnAboutRenderPhaseUpdatesInDEV(fiber) { 31076 { 31077 if (isRendering && (executionContext & RenderContext) !== NoContext) { 31078 switch (fiber.tag) { 31079 case FunctionComponent: 31080 case ForwardRef: 31081 case SimpleMemoComponent: 31082 { 31083 var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed. 31084 31085 var dedupeKey = renderingComponentName; 31086 31087 if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { 31088 didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); 31089 var setStateComponentName = getComponentName(fiber.type) || 'Unknown'; 31090 31091 error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://fb.me/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName); 31092 } 31093 31094 break; 31095 } 31096 31097 case ClassComponent: 31098 { 31099 if (!didWarnAboutUpdateInRender) { 31100 error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.'); 31101 31102 didWarnAboutUpdateInRender = true; 31103 } 31104 31105 break; 31106 } 31107 } 31108 } 31109 } 31110} // a 'shared' variable that changes when act() opens/closes in tests. 31111 31112 31113var IsThisRendererActing = { 31114 current: false 31115}; 31116function warnIfNotScopedWithMatchingAct(fiber) { 31117 { 31118 if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) { 31119 error("It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber)); 31120 } 31121 } 31122} 31123function warnIfNotCurrentlyActingEffectsInDEV(fiber) { 31124 { 31125 if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 31126 error('An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber)); 31127 } 31128 } 31129} 31130 31131function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { 31132 { 31133 if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 31134 error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber)); 31135 } 31136 } 31137} 31138 31139var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. 31140 31141var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked 31142// scheduler is the actual recommendation. The alternative could be a testing build, 31143// a new lib, or whatever; we dunno just yet. This message is for early adopters 31144// to get their tests right. 31145 31146function warnIfUnmockedScheduler(fiber) { 31147 { 31148 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) { 31149 if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { 31150 didWarnAboutUnmockedScheduler = true; 31151 31152 error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler'); 31153 } 31154 } 31155 } 31156} 31157 31158function computeThreadID(root, expirationTime) { 31159 // Interaction threads are unique per root and expiration time. 31160 return expirationTime * 1000 + root.interactionThreadID; 31161} 31162 31163function markSpawnedWork(expirationTime) { 31164 31165 if (spawnedWorkDuringRender === null) { 31166 spawnedWorkDuringRender = [expirationTime]; 31167 } else { 31168 spawnedWorkDuringRender.push(expirationTime); 31169 } 31170} 31171 31172function scheduleInteractions(root, expirationTime, interactions) { 31173 31174 if (interactions.size > 0) { 31175 var pendingInteractionMap = root.pendingInteractionMap; 31176 var pendingInteractions = pendingInteractionMap.get(expirationTime); 31177 31178 if (pendingInteractions != null) { 31179 interactions.forEach(function (interaction) { 31180 if (!pendingInteractions.has(interaction)) { 31181 // Update the pending async work count for previously unscheduled interaction. 31182 interaction.__count++; 31183 } 31184 31185 pendingInteractions.add(interaction); 31186 }); 31187 } else { 31188 pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. 31189 31190 interactions.forEach(function (interaction) { 31191 interaction.__count++; 31192 }); 31193 } 31194 31195 var subscriber = tracing.__subscriberRef.current; 31196 31197 if (subscriber !== null) { 31198 var threadID = computeThreadID(root, expirationTime); 31199 subscriber.onWorkScheduled(interactions, threadID); 31200 } 31201 } 31202} 31203 31204function schedulePendingInteractions(root, expirationTime) { 31205 31206 scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); 31207} 31208 31209function startWorkOnPendingInteractions(root, expirationTime) { 31210 // we can accurately attribute time spent working on it, And so that cascading 31211 // work triggered during the render phase will be associated with it. 31212 31213 31214 var interactions = new Set(); 31215 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) { 31216 if (scheduledExpirationTime >= expirationTime) { 31217 scheduledInteractions.forEach(function (interaction) { 31218 return interactions.add(interaction); 31219 }); 31220 } 31221 }); // Store the current set of interactions on the FiberRoot for a few reasons: 31222 // We can re-use it in hot functions like performConcurrentWorkOnRoot() 31223 // without having to recalculate it. We will also use it in commitWork() to 31224 // pass to any Profiler onRender() hooks. This also provides DevTools with a 31225 // way to access it when the onCommitRoot() hook is called. 31226 31227 root.memoizedInteractions = interactions; 31228 31229 if (interactions.size > 0) { 31230 var subscriber = tracing.__subscriberRef.current; 31231 31232 if (subscriber !== null) { 31233 var threadID = computeThreadID(root, expirationTime); 31234 31235 try { 31236 subscriber.onWorkStarted(interactions, threadID); 31237 } catch (error) { 31238 // If the subscriber throws, rethrow it in a separate task 31239 scheduleCallback(ImmediatePriority, function () { 31240 throw error; 31241 }); 31242 } 31243 } 31244 } 31245} 31246 31247function finishPendingInteractions(root, committedExpirationTime) { 31248 31249 var earliestRemainingTimeAfterCommit = root.firstPendingTime; 31250 var subscriber; 31251 31252 try { 31253 subscriber = tracing.__subscriberRef.current; 31254 31255 if (subscriber !== null && root.memoizedInteractions.size > 0) { 31256 var threadID = computeThreadID(root, committedExpirationTime); 31257 subscriber.onWorkStopped(root.memoizedInteractions, threadID); 31258 } 31259 } catch (error) { 31260 // If the subscriber throws, rethrow it in a separate task 31261 scheduleCallback(ImmediatePriority, function () { 31262 throw error; 31263 }); 31264 } finally { 31265 // Clear completed interactions from the pending Map. 31266 // Unless the render was suspended or cascading work was scheduled, 31267 // In which case– leave pending interactions until the subsequent render. 31268 var pendingInteractionMap = root.pendingInteractionMap; 31269 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) { 31270 // Only decrement the pending interaction count if we're done. 31271 // If there's still work at the current priority, 31272 // That indicates that we are waiting for suspense data. 31273 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { 31274 pendingInteractionMap.delete(scheduledExpirationTime); 31275 scheduledInteractions.forEach(function (interaction) { 31276 interaction.__count--; 31277 31278 if (subscriber !== null && interaction.__count === 0) { 31279 try { 31280 subscriber.onInteractionScheduledWorkCompleted(interaction); 31281 } catch (error) { 31282 // If the subscriber throws, rethrow it in a separate task 31283 scheduleCallback(ImmediatePriority, function () { 31284 throw error; 31285 }); 31286 } 31287 } 31288 }); 31289 } 31290 }); 31291 } 31292} 31293 31294var onScheduleFiberRoot = null; 31295var onCommitFiberRoot = null; 31296var onCommitFiberUnmount = null; 31297var hasLoggedError = false; 31298var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; 31299function injectInternals(internals) { 31300 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 31301 // No DevTools 31302 return false; 31303 } 31304 31305 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 31306 31307 if (hook.isDisabled) { 31308 // This isn't a real property on the hook, but it can be set to opt out 31309 // of DevTools integration and associated warnings and logs. 31310 // https://github.com/facebook/react/issues/3877 31311 return true; 31312 } 31313 31314 if (!hook.supportsFiber) { 31315 { 31316 error('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'); 31317 } // DevTools exists, even though it doesn't support Fiber. 31318 31319 31320 return true; 31321 } 31322 31323 try { 31324 var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. 31325 31326 if (true) { 31327 // Only used by Fast Refresh 31328 if (typeof hook.onScheduleFiberRoot === 'function') { 31329 onScheduleFiberRoot = function (root, children) { 31330 try { 31331 hook.onScheduleFiberRoot(rendererID, root, children); 31332 } catch (err) { 31333 if ( true && !hasLoggedError) { 31334 hasLoggedError = true; 31335 31336 error('React instrumentation encountered an error: %s', err); 31337 } 31338 } 31339 }; 31340 } 31341 } 31342 31343 onCommitFiberRoot = function (root, expirationTime) { 31344 try { 31345 var didError = (root.current.effectTag & DidCapture) === DidCapture; 31346 31347 if (enableProfilerTimer) { 31348 var currentTime = getCurrentTime(); 31349 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); 31350 hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); 31351 } else { 31352 hook.onCommitFiberRoot(rendererID, root, undefined, didError); 31353 } 31354 } catch (err) { 31355 if (true) { 31356 if (!hasLoggedError) { 31357 hasLoggedError = true; 31358 31359 error('React instrumentation encountered an error: %s', err); 31360 } 31361 } 31362 } 31363 }; 31364 31365 onCommitFiberUnmount = function (fiber) { 31366 try { 31367 hook.onCommitFiberUnmount(rendererID, fiber); 31368 } catch (err) { 31369 if (true) { 31370 if (!hasLoggedError) { 31371 hasLoggedError = true; 31372 31373 error('React instrumentation encountered an error: %s', err); 31374 } 31375 } 31376 } 31377 }; 31378 } catch (err) { 31379 // Catch all errors because it is unsafe to throw during initialization. 31380 { 31381 error('React instrumentation encountered an error: %s.', err); 31382 } 31383 } // DevTools exists 31384 31385 31386 return true; 31387} 31388function onScheduleRoot(root, children) { 31389 if (typeof onScheduleFiberRoot === 'function') { 31390 onScheduleFiberRoot(root, children); 31391 } 31392} 31393function onCommitRoot(root, expirationTime) { 31394 if (typeof onCommitFiberRoot === 'function') { 31395 onCommitFiberRoot(root, expirationTime); 31396 } 31397} 31398function onCommitUnmount(fiber) { 31399 if (typeof onCommitFiberUnmount === 'function') { 31400 onCommitFiberUnmount(fiber); 31401 } 31402} 31403 31404var hasBadMapPolyfill; 31405 31406{ 31407 hasBadMapPolyfill = false; 31408 31409 try { 31410 var nonExtensibleObject = Object.preventExtensions({}); 31411 var testMap = new Map([[nonExtensibleObject, null]]); 31412 var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. 31413 // https://github.com/rollup/rollup/issues/1771 31414 // TODO: we can remove these if Rollup fixes the bug. 31415 31416 testMap.set(0, 0); 31417 testSet.add(0); 31418 } catch (e) { 31419 // TODO: Consider warning about bad polyfills 31420 hasBadMapPolyfill = true; 31421 } 31422} 31423 31424var debugCounter = 1; 31425 31426function FiberNode(tag, pendingProps, key, mode) { 31427 // Instance 31428 this.tag = tag; 31429 this.key = key; 31430 this.elementType = null; 31431 this.type = null; 31432 this.stateNode = null; // Fiber 31433 31434 this.return = null; 31435 this.child = null; 31436 this.sibling = null; 31437 this.index = 0; 31438 this.ref = null; 31439 this.pendingProps = pendingProps; 31440 this.memoizedProps = null; 31441 this.updateQueue = null; 31442 this.memoizedState = null; 31443 this.dependencies = null; 31444 this.mode = mode; // Effects 31445 31446 this.effectTag = NoEffect; 31447 this.nextEffect = null; 31448 this.firstEffect = null; 31449 this.lastEffect = null; 31450 this.expirationTime = NoWork; 31451 this.childExpirationTime = NoWork; 31452 this.alternate = null; 31453 31454 { 31455 // Note: The following is done to avoid a v8 performance cliff. 31456 // 31457 // Initializing the fields below to smis and later updating them with 31458 // double values will cause Fibers to end up having separate shapes. 31459 // This behavior/bug has something to do with Object.preventExtension(). 31460 // Fortunately this only impacts DEV builds. 31461 // Unfortunately it makes React unusably slow for some applications. 31462 // To work around this, initialize the fields below with doubles. 31463 // 31464 // Learn more about this here: 31465 // https://github.com/facebook/react/issues/14365 31466 // https://bugs.chromium.org/p/v8/issues/detail?id=8538 31467 this.actualDuration = Number.NaN; 31468 this.actualStartTime = Number.NaN; 31469 this.selfBaseDuration = Number.NaN; 31470 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization. 31471 // This won't trigger the performance cliff mentioned above, 31472 // and it simplifies other profiler code (including DevTools). 31473 31474 this.actualDuration = 0; 31475 this.actualStartTime = -1; 31476 this.selfBaseDuration = 0; 31477 this.treeBaseDuration = 0; 31478 } // This is normally DEV-only except www when it adds listeners. 31479 // TODO: remove the User Timing integration in favor of Root Events. 31480 31481 31482 { 31483 this._debugID = debugCounter++; 31484 this._debugIsCurrentlyTiming = false; 31485 } 31486 31487 { 31488 this._debugSource = null; 31489 this._debugOwner = null; 31490 this._debugNeedsRemount = false; 31491 this._debugHookTypes = null; 31492 31493 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 31494 Object.preventExtensions(this); 31495 } 31496 } 31497} // This is a constructor function, rather than a POJO constructor, still 31498// please ensure we do the following: 31499// 1) Nobody should add any instance methods on this. Instance methods can be 31500// more difficult to predict when they get optimized and they are almost 31501// never inlined properly in static compilers. 31502// 2) Nobody should rely on `instanceof Fiber` for type testing. We should 31503// always know when it is a fiber. 31504// 3) We might want to experiment with using numeric keys since they are easier 31505// to optimize in a non-JIT environment. 31506// 4) We can easily go from a constructor to a createFiber object literal if that 31507// is faster. 31508// 5) It should be easy to port this to a C struct and keep a C implementation 31509// compatible. 31510 31511 31512var createFiber = function (tag, pendingProps, key, mode) { 31513 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 31514 return new FiberNode(tag, pendingProps, key, mode); 31515}; 31516 31517function shouldConstruct(Component) { 31518 var prototype = Component.prototype; 31519 return !!(prototype && prototype.isReactComponent); 31520} 31521 31522function isSimpleFunctionComponent(type) { 31523 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined; 31524} 31525function resolveLazyComponentTag(Component) { 31526 if (typeof Component === 'function') { 31527 return shouldConstruct(Component) ? ClassComponent : FunctionComponent; 31528 } else if (Component !== undefined && Component !== null) { 31529 var $$typeof = Component.$$typeof; 31530 31531 if ($$typeof === REACT_FORWARD_REF_TYPE) { 31532 return ForwardRef; 31533 } 31534 31535 if ($$typeof === REACT_MEMO_TYPE) { 31536 return MemoComponent; 31537 } 31538 } 31539 31540 return IndeterminateComponent; 31541} // This is used to create an alternate fiber to do work on. 31542 31543function createWorkInProgress(current, pendingProps) { 31544 var workInProgress = current.alternate; 31545 31546 if (workInProgress === null) { 31547 // We use a double buffering pooling technique because we know that we'll 31548 // only ever need at most two versions of a tree. We pool the "other" unused 31549 // node that we're free to reuse. This is lazily created to avoid allocating 31550 // extra objects for things that are never updated. It also allow us to 31551 // reclaim the extra memory if needed. 31552 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); 31553 workInProgress.elementType = current.elementType; 31554 workInProgress.type = current.type; 31555 workInProgress.stateNode = current.stateNode; 31556 31557 { 31558 // DEV-only fields 31559 { 31560 workInProgress._debugID = current._debugID; 31561 } 31562 31563 workInProgress._debugSource = current._debugSource; 31564 workInProgress._debugOwner = current._debugOwner; 31565 workInProgress._debugHookTypes = current._debugHookTypes; 31566 } 31567 31568 workInProgress.alternate = current; 31569 current.alternate = workInProgress; 31570 } else { 31571 workInProgress.pendingProps = pendingProps; // We already have an alternate. 31572 // Reset the effect tag. 31573 31574 workInProgress.effectTag = NoEffect; // The effect list is no longer valid. 31575 31576 workInProgress.nextEffect = null; 31577 workInProgress.firstEffect = null; 31578 workInProgress.lastEffect = null; 31579 31580 { 31581 // We intentionally reset, rather than copy, actualDuration & actualStartTime. 31582 // This prevents time from endlessly accumulating in new commits. 31583 // This has the downside of resetting values for different priority renders, 31584 // But works for yielding (the common case) and should support resuming. 31585 workInProgress.actualDuration = 0; 31586 workInProgress.actualStartTime = -1; 31587 } 31588 } 31589 31590 workInProgress.childExpirationTime = current.childExpirationTime; 31591 workInProgress.expirationTime = current.expirationTime; 31592 workInProgress.child = current.child; 31593 workInProgress.memoizedProps = current.memoizedProps; 31594 workInProgress.memoizedState = current.memoizedState; 31595 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 31596 // it cannot be shared with the current fiber. 31597 31598 var currentDependencies = current.dependencies; 31599 workInProgress.dependencies = currentDependencies === null ? null : { 31600 expirationTime: currentDependencies.expirationTime, 31601 firstContext: currentDependencies.firstContext, 31602 responders: currentDependencies.responders 31603 }; // These will be overridden during the parent's reconciliation 31604 31605 workInProgress.sibling = current.sibling; 31606 workInProgress.index = current.index; 31607 workInProgress.ref = current.ref; 31608 31609 { 31610 workInProgress.selfBaseDuration = current.selfBaseDuration; 31611 workInProgress.treeBaseDuration = current.treeBaseDuration; 31612 } 31613 31614 { 31615 workInProgress._debugNeedsRemount = current._debugNeedsRemount; 31616 31617 switch (workInProgress.tag) { 31618 case IndeterminateComponent: 31619 case FunctionComponent: 31620 case SimpleMemoComponent: 31621 workInProgress.type = resolveFunctionForHotReloading(current.type); 31622 break; 31623 31624 case ClassComponent: 31625 workInProgress.type = resolveClassForHotReloading(current.type); 31626 break; 31627 31628 case ForwardRef: 31629 workInProgress.type = resolveForwardRefForHotReloading(current.type); 31630 break; 31631 } 31632 } 31633 31634 return workInProgress; 31635} // Used to reuse a Fiber for a second pass. 31636 31637function resetWorkInProgress(workInProgress, renderExpirationTime) { 31638 // This resets the Fiber to what createFiber or createWorkInProgress would 31639 // have set the values to before during the first pass. Ideally this wouldn't 31640 // be necessary but unfortunately many code paths reads from the workInProgress 31641 // when they should be reading from current and writing to workInProgress. 31642 // We assume pendingProps, index, key, ref, return are still untouched to 31643 // avoid doing another reconciliation. 31644 // Reset the effect tag but keep any Placement tags, since that's something 31645 // that child fiber is setting, not the reconciliation. 31646 workInProgress.effectTag &= Placement; // The effect list is no longer valid. 31647 31648 workInProgress.nextEffect = null; 31649 workInProgress.firstEffect = null; 31650 workInProgress.lastEffect = null; 31651 var current = workInProgress.alternate; 31652 31653 if (current === null) { 31654 // Reset to createFiber's initial values. 31655 workInProgress.childExpirationTime = NoWork; 31656 workInProgress.expirationTime = renderExpirationTime; 31657 workInProgress.child = null; 31658 workInProgress.memoizedProps = null; 31659 workInProgress.memoizedState = null; 31660 workInProgress.updateQueue = null; 31661 workInProgress.dependencies = null; 31662 31663 { 31664 // Note: We don't reset the actualTime counts. It's useful to accumulate 31665 // actual time across multiple render passes. 31666 workInProgress.selfBaseDuration = 0; 31667 workInProgress.treeBaseDuration = 0; 31668 } 31669 } else { 31670 // Reset to the cloned values that createWorkInProgress would've. 31671 workInProgress.childExpirationTime = current.childExpirationTime; 31672 workInProgress.expirationTime = current.expirationTime; 31673 workInProgress.child = current.child; 31674 workInProgress.memoizedProps = current.memoizedProps; 31675 workInProgress.memoizedState = current.memoizedState; 31676 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 31677 // it cannot be shared with the current fiber. 31678 31679 var currentDependencies = current.dependencies; 31680 workInProgress.dependencies = currentDependencies === null ? null : { 31681 expirationTime: currentDependencies.expirationTime, 31682 firstContext: currentDependencies.firstContext, 31683 responders: currentDependencies.responders 31684 }; 31685 31686 { 31687 // Note: We don't reset the actualTime counts. It's useful to accumulate 31688 // actual time across multiple render passes. 31689 workInProgress.selfBaseDuration = current.selfBaseDuration; 31690 workInProgress.treeBaseDuration = current.treeBaseDuration; 31691 } 31692 } 31693 31694 return workInProgress; 31695} 31696function createHostRootFiber(tag) { 31697 var mode; 31698 31699 if (tag === ConcurrentRoot) { 31700 mode = ConcurrentMode | BlockingMode | StrictMode; 31701 } else if (tag === BlockingRoot) { 31702 mode = BlockingMode | StrictMode; 31703 } else { 31704 mode = NoMode; 31705 } 31706 31707 if ( isDevToolsPresent) { 31708 // Always collect profile timings when DevTools are present. 31709 // This enables DevTools to start capturing timing at any point– 31710 // Without some nodes in the tree having empty base times. 31711 mode |= ProfileMode; 31712 } 31713 31714 return createFiber(HostRoot, null, null, mode); 31715} 31716function createFiberFromTypeAndProps(type, // React$ElementType 31717key, pendingProps, owner, mode, expirationTime) { 31718 var fiber; 31719 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. 31720 31721 var resolvedType = type; 31722 31723 if (typeof type === 'function') { 31724 if (shouldConstruct(type)) { 31725 fiberTag = ClassComponent; 31726 31727 { 31728 resolvedType = resolveClassForHotReloading(resolvedType); 31729 } 31730 } else { 31731 { 31732 resolvedType = resolveFunctionForHotReloading(resolvedType); 31733 } 31734 } 31735 } else if (typeof type === 'string') { 31736 fiberTag = HostComponent; 31737 } else { 31738 getTag: switch (type) { 31739 case REACT_FRAGMENT_TYPE: 31740 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key); 31741 31742 case REACT_CONCURRENT_MODE_TYPE: 31743 fiberTag = Mode; 31744 mode |= ConcurrentMode | BlockingMode | StrictMode; 31745 break; 31746 31747 case REACT_STRICT_MODE_TYPE: 31748 fiberTag = Mode; 31749 mode |= StrictMode; 31750 break; 31751 31752 case REACT_PROFILER_TYPE: 31753 return createFiberFromProfiler(pendingProps, mode, expirationTime, key); 31754 31755 case REACT_SUSPENSE_TYPE: 31756 return createFiberFromSuspense(pendingProps, mode, expirationTime, key); 31757 31758 case REACT_SUSPENSE_LIST_TYPE: 31759 return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key); 31760 31761 default: 31762 { 31763 if (typeof type === 'object' && type !== null) { 31764 switch (type.$$typeof) { 31765 case REACT_PROVIDER_TYPE: 31766 fiberTag = ContextProvider; 31767 break getTag; 31768 31769 case REACT_CONTEXT_TYPE: 31770 // This is a consumer 31771 fiberTag = ContextConsumer; 31772 break getTag; 31773 31774 case REACT_FORWARD_REF_TYPE: 31775 fiberTag = ForwardRef; 31776 31777 { 31778 resolvedType = resolveForwardRefForHotReloading(resolvedType); 31779 } 31780 31781 break getTag; 31782 31783 case REACT_MEMO_TYPE: 31784 fiberTag = MemoComponent; 31785 break getTag; 31786 31787 case REACT_LAZY_TYPE: 31788 fiberTag = LazyComponent; 31789 resolvedType = null; 31790 break getTag; 31791 31792 case REACT_BLOCK_TYPE: 31793 fiberTag = Block; 31794 break getTag; 31795 31796 } 31797 } 31798 31799 var info = ''; 31800 31801 { 31802 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 31803 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.'; 31804 } 31805 31806 var ownerName = owner ? getComponentName(owner.type) : null; 31807 31808 if (ownerName) { 31809 info += '\n\nCheck the render method of `' + ownerName + '`.'; 31810 } 31811 } 31812 31813 { 31814 { 31815 throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info ); 31816 } 31817 } 31818 } 31819 } 31820 } 31821 31822 fiber = createFiber(fiberTag, pendingProps, key, mode); 31823 fiber.elementType = type; 31824 fiber.type = resolvedType; 31825 fiber.expirationTime = expirationTime; 31826 return fiber; 31827} 31828function createFiberFromElement(element, mode, expirationTime) { 31829 var owner = null; 31830 31831 { 31832 owner = element._owner; 31833 } 31834 31835 var type = element.type; 31836 var key = element.key; 31837 var pendingProps = element.props; 31838 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime); 31839 31840 { 31841 fiber._debugSource = element._source; 31842 fiber._debugOwner = element._owner; 31843 } 31844 31845 return fiber; 31846} 31847function createFiberFromFragment(elements, mode, expirationTime, key) { 31848 var fiber = createFiber(Fragment, elements, key, mode); 31849 fiber.expirationTime = expirationTime; 31850 return fiber; 31851} 31852 31853function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { 31854 { 31855 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') { 31856 error('Profiler must specify an "id" string and "onRender" function as props'); 31857 } 31858 } 31859 31860 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag. 31861 31862 fiber.elementType = REACT_PROFILER_TYPE; 31863 fiber.type = REACT_PROFILER_TYPE; 31864 fiber.expirationTime = expirationTime; 31865 return fiber; 31866} 31867 31868function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { 31869 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. 31870 // This needs to be fixed in getComponentName so that it relies on the tag 31871 // instead. 31872 31873 fiber.type = REACT_SUSPENSE_TYPE; 31874 fiber.elementType = REACT_SUSPENSE_TYPE; 31875 fiber.expirationTime = expirationTime; 31876 return fiber; 31877} 31878function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { 31879 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); 31880 31881 { 31882 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag. 31883 // This needs to be fixed in getComponentName so that it relies on the tag 31884 // instead. 31885 fiber.type = REACT_SUSPENSE_LIST_TYPE; 31886 } 31887 31888 fiber.elementType = REACT_SUSPENSE_LIST_TYPE; 31889 fiber.expirationTime = expirationTime; 31890 return fiber; 31891} 31892function createFiberFromText(content, mode, expirationTime) { 31893 var fiber = createFiber(HostText, content, null, mode); 31894 fiber.expirationTime = expirationTime; 31895 return fiber; 31896} 31897function createFiberFromHostInstanceForDeletion() { 31898 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type. 31899 31900 fiber.elementType = 'DELETED'; 31901 fiber.type = 'DELETED'; 31902 return fiber; 31903} 31904function createFiberFromPortal(portal, mode, expirationTime) { 31905 var pendingProps = portal.children !== null ? portal.children : []; 31906 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); 31907 fiber.expirationTime = expirationTime; 31908 fiber.stateNode = { 31909 containerInfo: portal.containerInfo, 31910 pendingChildren: null, 31911 // Used by persistent updates 31912 implementation: portal.implementation 31913 }; 31914 return fiber; 31915} // Used for stashing WIP properties to replay failed work in DEV. 31916 31917function assignFiberPropertiesInDEV(target, source) { 31918 if (target === null) { 31919 // This Fiber's initial properties will always be overwritten. 31920 // We only use a Fiber to ensure the same hidden class so DEV isn't slow. 31921 target = createFiber(IndeterminateComponent, null, null, NoMode); 31922 } // This is intentionally written as a list of all properties. 31923 // We tried to use Object.assign() instead but this is called in 31924 // the hottest path, and Object.assign() was too slow: 31925 // https://github.com/facebook/react/issues/12502 31926 // This code is DEV-only so size is not a concern. 31927 31928 31929 target.tag = source.tag; 31930 target.key = source.key; 31931 target.elementType = source.elementType; 31932 target.type = source.type; 31933 target.stateNode = source.stateNode; 31934 target.return = source.return; 31935 target.child = source.child; 31936 target.sibling = source.sibling; 31937 target.index = source.index; 31938 target.ref = source.ref; 31939 target.pendingProps = source.pendingProps; 31940 target.memoizedProps = source.memoizedProps; 31941 target.updateQueue = source.updateQueue; 31942 target.memoizedState = source.memoizedState; 31943 target.dependencies = source.dependencies; 31944 target.mode = source.mode; 31945 target.effectTag = source.effectTag; 31946 target.nextEffect = source.nextEffect; 31947 target.firstEffect = source.firstEffect; 31948 target.lastEffect = source.lastEffect; 31949 target.expirationTime = source.expirationTime; 31950 target.childExpirationTime = source.childExpirationTime; 31951 target.alternate = source.alternate; 31952 31953 { 31954 target.actualDuration = source.actualDuration; 31955 target.actualStartTime = source.actualStartTime; 31956 target.selfBaseDuration = source.selfBaseDuration; 31957 target.treeBaseDuration = source.treeBaseDuration; 31958 } 31959 31960 { 31961 target._debugID = source._debugID; 31962 } 31963 31964 target._debugSource = source._debugSource; 31965 target._debugOwner = source._debugOwner; 31966 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; 31967 target._debugNeedsRemount = source._debugNeedsRemount; 31968 target._debugHookTypes = source._debugHookTypes; 31969 return target; 31970} 31971 31972function FiberRootNode(containerInfo, tag, hydrate) { 31973 this.tag = tag; 31974 this.current = null; 31975 this.containerInfo = containerInfo; 31976 this.pendingChildren = null; 31977 this.pingCache = null; 31978 this.finishedExpirationTime = NoWork; 31979 this.finishedWork = null; 31980 this.timeoutHandle = noTimeout; 31981 this.context = null; 31982 this.pendingContext = null; 31983 this.hydrate = hydrate; 31984 this.callbackNode = null; 31985 this.callbackPriority = NoPriority; 31986 this.firstPendingTime = NoWork; 31987 this.firstSuspendedTime = NoWork; 31988 this.lastSuspendedTime = NoWork; 31989 this.nextKnownPendingLevel = NoWork; 31990 this.lastPingedTime = NoWork; 31991 this.lastExpiredTime = NoWork; 31992 31993 { 31994 this.interactionThreadID = tracing.unstable_getThreadID(); 31995 this.memoizedInteractions = new Set(); 31996 this.pendingInteractionMap = new Map(); 31997 } 31998} 31999 32000function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { 32001 var root = new FiberRootNode(containerInfo, tag, hydrate); 32002 // stateNode is any. 32003 32004 32005 var uninitializedFiber = createHostRootFiber(tag); 32006 root.current = uninitializedFiber; 32007 uninitializedFiber.stateNode = root; 32008 initializeUpdateQueue(uninitializedFiber); 32009 return root; 32010} 32011function isRootSuspendedAtTime(root, expirationTime) { 32012 var firstSuspendedTime = root.firstSuspendedTime; 32013 var lastSuspendedTime = root.lastSuspendedTime; 32014 return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime; 32015} 32016function markRootSuspendedAtTime(root, expirationTime) { 32017 var firstSuspendedTime = root.firstSuspendedTime; 32018 var lastSuspendedTime = root.lastSuspendedTime; 32019 32020 if (firstSuspendedTime < expirationTime) { 32021 root.firstSuspendedTime = expirationTime; 32022 } 32023 32024 if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { 32025 root.lastSuspendedTime = expirationTime; 32026 } 32027 32028 if (expirationTime <= root.lastPingedTime) { 32029 root.lastPingedTime = NoWork; 32030 } 32031 32032 if (expirationTime <= root.lastExpiredTime) { 32033 root.lastExpiredTime = NoWork; 32034 } 32035} 32036function markRootUpdatedAtTime(root, expirationTime) { 32037 // Update the range of pending times 32038 var firstPendingTime = root.firstPendingTime; 32039 32040 if (expirationTime > firstPendingTime) { 32041 root.firstPendingTime = expirationTime; 32042 } // Update the range of suspended times. Treat everything lower priority or 32043 // equal to this update as unsuspended. 32044 32045 32046 var firstSuspendedTime = root.firstSuspendedTime; 32047 32048 if (firstSuspendedTime !== NoWork) { 32049 if (expirationTime >= firstSuspendedTime) { 32050 // The entire suspended range is now unsuspended. 32051 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; 32052 } else if (expirationTime >= root.lastSuspendedTime) { 32053 root.lastSuspendedTime = expirationTime + 1; 32054 } // This is a pending level. Check if it's higher priority than the next 32055 // known pending level. 32056 32057 32058 if (expirationTime > root.nextKnownPendingLevel) { 32059 root.nextKnownPendingLevel = expirationTime; 32060 } 32061 } 32062} 32063function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) { 32064 // Update the range of pending times 32065 root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or 32066 // equal to this update as unsuspended. 32067 32068 if (finishedExpirationTime <= root.lastSuspendedTime) { 32069 // The entire suspended range is now unsuspended. 32070 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; 32071 } else if (finishedExpirationTime <= root.firstSuspendedTime) { 32072 // Part of the suspended range is now unsuspended. Narrow the range to 32073 // include everything between the unsuspended time (non-inclusive) and the 32074 // last suspended time. 32075 root.firstSuspendedTime = finishedExpirationTime - 1; 32076 } 32077 32078 if (finishedExpirationTime <= root.lastPingedTime) { 32079 // Clear the pinged time 32080 root.lastPingedTime = NoWork; 32081 } 32082 32083 if (finishedExpirationTime <= root.lastExpiredTime) { 32084 // Clear the expired time 32085 root.lastExpiredTime = NoWork; 32086 } 32087} 32088function markRootExpiredAtTime(root, expirationTime) { 32089 var lastExpiredTime = root.lastExpiredTime; 32090 32091 if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { 32092 root.lastExpiredTime = expirationTime; 32093 } 32094} 32095 32096var didWarnAboutNestedUpdates; 32097var didWarnAboutFindNodeInStrictMode; 32098 32099{ 32100 didWarnAboutNestedUpdates = false; 32101 didWarnAboutFindNodeInStrictMode = {}; 32102} 32103 32104function getContextForSubtree(parentComponent) { 32105 if (!parentComponent) { 32106 return emptyContextObject; 32107 } 32108 32109 var fiber = get(parentComponent); 32110 var parentContext = findCurrentUnmaskedContext(fiber); 32111 32112 if (fiber.tag === ClassComponent) { 32113 var Component = fiber.type; 32114 32115 if (isContextProvider(Component)) { 32116 return processChildContext(fiber, Component, parentContext); 32117 } 32118 } 32119 32120 return parentContext; 32121} 32122 32123function findHostInstanceWithWarning(component, methodName) { 32124 { 32125 var fiber = get(component); 32126 32127 if (fiber === undefined) { 32128 if (typeof component.render === 'function') { 32129 { 32130 { 32131 throw Error( "Unable to find node on an unmounted component." ); 32132 } 32133 } 32134 } else { 32135 { 32136 { 32137 throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) ); 32138 } 32139 } 32140 } 32141 } 32142 32143 var hostFiber = findCurrentHostFiber(fiber); 32144 32145 if (hostFiber === null) { 32146 return null; 32147 } 32148 32149 if (hostFiber.mode & StrictMode) { 32150 var componentName = getComponentName(fiber.type) || 'Component'; 32151 32152 if (!didWarnAboutFindNodeInStrictMode[componentName]) { 32153 didWarnAboutFindNodeInStrictMode[componentName] = true; 32154 32155 if (fiber.mode & StrictMode) { 32156 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber)); 32157 } else { 32158 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber)); 32159 } 32160 } 32161 } 32162 32163 return hostFiber.stateNode; 32164 } 32165} 32166 32167function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { 32168 return createFiberRoot(containerInfo, tag, hydrate); 32169} 32170function updateContainer(element, container, parentComponent, callback) { 32171 { 32172 onScheduleRoot(container, element); 32173 } 32174 32175 var current$1 = container.current; 32176 var currentTime = requestCurrentTimeForUpdate(); 32177 32178 { 32179 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 32180 if ('undefined' !== typeof jest) { 32181 warnIfUnmockedScheduler(current$1); 32182 warnIfNotScopedWithMatchingAct(current$1); 32183 } 32184 } 32185 32186 var suspenseConfig = requestCurrentSuspenseConfig(); 32187 var expirationTime = computeExpirationForFiber(currentTime, current$1, suspenseConfig); 32188 var context = getContextForSubtree(parentComponent); 32189 32190 if (container.context === null) { 32191 container.context = context; 32192 } else { 32193 container.pendingContext = context; 32194 } 32195 32196 { 32197 if (isRendering && current !== null && !didWarnAboutNestedUpdates) { 32198 didWarnAboutNestedUpdates = true; 32199 32200 error('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(current.type) || 'Unknown'); 32201 } 32202 } 32203 32204 var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property 32205 // being called "element". 32206 32207 update.payload = { 32208 element: element 32209 }; 32210 callback = callback === undefined ? null : callback; 32211 32212 if (callback !== null) { 32213 { 32214 if (typeof callback !== 'function') { 32215 error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); 32216 } 32217 } 32218 32219 update.callback = callback; 32220 } 32221 32222 enqueueUpdate(current$1, update); 32223 scheduleWork(current$1, expirationTime); 32224 return expirationTime; 32225} 32226function getPublicRootInstance(container) { 32227 var containerFiber = container.current; 32228 32229 if (!containerFiber.child) { 32230 return null; 32231 } 32232 32233 switch (containerFiber.child.tag) { 32234 case HostComponent: 32235 return getPublicInstance(containerFiber.child.stateNode); 32236 32237 default: 32238 return containerFiber.child.stateNode; 32239 } 32240} 32241 32242function markRetryTimeImpl(fiber, retryTime) { 32243 var suspenseState = fiber.memoizedState; 32244 32245 if (suspenseState !== null && suspenseState.dehydrated !== null) { 32246 if (suspenseState.retryTime < retryTime) { 32247 suspenseState.retryTime = retryTime; 32248 } 32249 } 32250} // Increases the priority of thennables when they resolve within this boundary. 32251 32252 32253function markRetryTimeIfNotHydrated(fiber, retryTime) { 32254 markRetryTimeImpl(fiber, retryTime); 32255 var alternate = fiber.alternate; 32256 32257 if (alternate) { 32258 markRetryTimeImpl(alternate, retryTime); 32259 } 32260} 32261 32262function attemptUserBlockingHydration$1(fiber) { 32263 if (fiber.tag !== SuspenseComponent) { 32264 // We ignore HostRoots here because we can't increase 32265 // their priority and they should not suspend on I/O, 32266 // since you have to wrap anything that might suspend in 32267 // Suspense. 32268 return; 32269 } 32270 32271 var expTime = computeInteractiveExpiration(requestCurrentTimeForUpdate()); 32272 scheduleWork(fiber, expTime); 32273 markRetryTimeIfNotHydrated(fiber, expTime); 32274} 32275function attemptContinuousHydration$1(fiber) { 32276 if (fiber.tag !== SuspenseComponent) { 32277 // We ignore HostRoots here because we can't increase 32278 // their priority and they should not suspend on I/O, 32279 // since you have to wrap anything that might suspend in 32280 // Suspense. 32281 return; 32282 } 32283 32284 scheduleWork(fiber, ContinuousHydration); 32285 markRetryTimeIfNotHydrated(fiber, ContinuousHydration); 32286} 32287function attemptHydrationAtCurrentPriority$1(fiber) { 32288 if (fiber.tag !== SuspenseComponent) { 32289 // We ignore HostRoots here because we can't increase 32290 // their priority other than synchronously flush it. 32291 return; 32292 } 32293 32294 var currentTime = requestCurrentTimeForUpdate(); 32295 var expTime = computeExpirationForFiber(currentTime, fiber, null); 32296 scheduleWork(fiber, expTime); 32297 markRetryTimeIfNotHydrated(fiber, expTime); 32298} 32299function findHostInstanceWithNoPortals(fiber) { 32300 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 32301 32302 if (hostFiber === null) { 32303 return null; 32304 } 32305 32306 if (hostFiber.tag === FundamentalComponent) { 32307 return hostFiber.stateNode.instance; 32308 } 32309 32310 return hostFiber.stateNode; 32311} 32312 32313var shouldSuspendImpl = function (fiber) { 32314 return false; 32315}; 32316 32317function shouldSuspend(fiber) { 32318 return shouldSuspendImpl(fiber); 32319} 32320var overrideHookState = null; 32321var overrideProps = null; 32322var scheduleUpdate = null; 32323var setSuspenseHandler = null; 32324 32325{ 32326 var copyWithSetImpl = function (obj, path, idx, value) { 32327 if (idx >= path.length) { 32328 return value; 32329 } 32330 32331 var key = path[idx]; 32332 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here 32333 32334 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); 32335 return updated; 32336 }; 32337 32338 var copyWithSet = function (obj, path, value) { 32339 return copyWithSetImpl(obj, path, 0, value); 32340 }; // Support DevTools editable values for useState and useReducer. 32341 32342 32343 overrideHookState = function (fiber, id, path, value) { 32344 // For now, the "id" of stateful hooks is just the stateful hook index. 32345 // This may change in the future with e.g. nested hooks. 32346 var currentHook = fiber.memoizedState; 32347 32348 while (currentHook !== null && id > 0) { 32349 currentHook = currentHook.next; 32350 id--; 32351 } 32352 32353 if (currentHook !== null) { 32354 var newState = copyWithSet(currentHook.memoizedState, path, value); 32355 currentHook.memoizedState = newState; 32356 currentHook.baseState = newState; // We aren't actually adding an update to the queue, 32357 // because there is no update we can add for useReducer hooks that won't trigger an error. 32358 // (There's no appropriate action type for DevTools overrides.) 32359 // As a result though, React will see the scheduled update as a noop and bailout. 32360 // Shallow cloning props works as a workaround for now to bypass the bailout check. 32361 32362 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 32363 scheduleWork(fiber, Sync); 32364 } 32365 }; // Support DevTools props for function components, forwardRef, memo, host components, etc. 32366 32367 32368 overrideProps = function (fiber, path, value) { 32369 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); 32370 32371 if (fiber.alternate) { 32372 fiber.alternate.pendingProps = fiber.pendingProps; 32373 } 32374 32375 scheduleWork(fiber, Sync); 32376 }; 32377 32378 scheduleUpdate = function (fiber) { 32379 scheduleWork(fiber, Sync); 32380 }; 32381 32382 setSuspenseHandler = function (newShouldSuspendImpl) { 32383 shouldSuspendImpl = newShouldSuspendImpl; 32384 }; 32385} 32386 32387function injectIntoDevTools(devToolsConfig) { 32388 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 32389 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 32390 return injectInternals(_assign({}, devToolsConfig, { 32391 overrideHookState: overrideHookState, 32392 overrideProps: overrideProps, 32393 setSuspenseHandler: setSuspenseHandler, 32394 scheduleUpdate: scheduleUpdate, 32395 currentDispatcherRef: ReactCurrentDispatcher, 32396 findHostInstanceByFiber: function (fiber) { 32397 var hostFiber = findCurrentHostFiber(fiber); 32398 32399 if (hostFiber === null) { 32400 return null; 32401 } 32402 32403 return hostFiber.stateNode; 32404 }, 32405 findFiberByHostInstance: function (instance) { 32406 if (!findFiberByHostInstance) { 32407 // Might not be implemented by the renderer. 32408 return null; 32409 } 32410 32411 return findFiberByHostInstance(instance); 32412 }, 32413 // React Refresh 32414 findHostInstancesForRefresh: findHostInstancesForRefresh , 32415 scheduleRefresh: scheduleRefresh , 32416 scheduleRoot: scheduleRoot , 32417 setRefreshHandler: setRefreshHandler , 32418 // Enables DevTools to append owner stacks to error messages in DEV mode. 32419 getCurrentFiber: function () { 32420 return current; 32421 } 32422 })); 32423} 32424var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; 32425 32426function ReactDOMRoot(container, options) { 32427 this._internalRoot = createRootImpl(container, ConcurrentRoot, options); 32428} 32429 32430function ReactDOMBlockingRoot(container, tag, options) { 32431 this._internalRoot = createRootImpl(container, tag, options); 32432} 32433 32434ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) { 32435 var root = this._internalRoot; 32436 32437 { 32438 if (typeof arguments[1] === 'function') { 32439 error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 32440 } 32441 32442 var container = root.containerInfo; 32443 32444 if (container.nodeType !== COMMENT_NODE) { 32445 var hostInstance = findHostInstanceWithNoPortals(root.current); 32446 32447 if (hostInstance) { 32448 if (hostInstance.parentNode !== container) { 32449 error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container."); 32450 } 32451 } 32452 } 32453 } 32454 32455 updateContainer(children, root, null, null); 32456}; 32457 32458ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () { 32459 { 32460 if (typeof arguments[0] === 'function') { 32461 error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 32462 } 32463 } 32464 32465 var root = this._internalRoot; 32466 var container = root.containerInfo; 32467 updateContainer(null, root, null, function () { 32468 unmarkContainerAsRoot(container); 32469 }); 32470}; 32471 32472function createRootImpl(container, tag, options) { 32473 // Tag is either LegacyRoot or Concurrent Root 32474 var hydrate = options != null && options.hydrate === true; 32475 var hydrationCallbacks = options != null && options.hydrationOptions || null; 32476 var root = createContainer(container, tag, hydrate); 32477 markContainerAsRoot(root.current, container); 32478 32479 if (hydrate && tag !== LegacyRoot) { 32480 var doc = container.nodeType === DOCUMENT_NODE ? container : container.ownerDocument; 32481 eagerlyTrapReplayableEvents(container, doc); 32482 } 32483 32484 return root; 32485} 32486function createLegacyRoot(container, options) { 32487 return new ReactDOMBlockingRoot(container, LegacyRoot, options); 32488} 32489function isValidContainer(node) { 32490 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 ')); 32491} 32492 32493var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; 32494var topLevelUpdateWarnings; 32495var warnedAboutHydrateAPI = false; 32496 32497{ 32498 topLevelUpdateWarnings = function (container) { 32499 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 32500 var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); 32501 32502 if (hostInstance) { 32503 if (hostInstance.parentNode !== container) { 32504 error('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.'); 32505 } 32506 } 32507 } 32508 32509 var isRootRenderedBySomeReact = !!container._reactRootContainer; 32510 var rootEl = getReactRootElementInContainer(container); 32511 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl)); 32512 32513 if (hasNonRootReactChild && !isRootRenderedBySomeReact) { 32514 error('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.'); 32515 } 32516 32517 if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') { 32518 error('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.'); 32519 } 32520 }; 32521} 32522 32523function getReactRootElementInContainer(container) { 32524 if (!container) { 32525 return null; 32526 } 32527 32528 if (container.nodeType === DOCUMENT_NODE) { 32529 return container.documentElement; 32530 } else { 32531 return container.firstChild; 32532 } 32533} 32534 32535function shouldHydrateDueToLegacyHeuristic(container) { 32536 var rootElement = getReactRootElementInContainer(container); 32537 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 32538} 32539 32540function legacyCreateRootFromDOMContainer(container, forceHydrate) { 32541 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content. 32542 32543 if (!shouldHydrate) { 32544 var warned = false; 32545 var rootSibling; 32546 32547 while (rootSibling = container.lastChild) { 32548 { 32549 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 32550 warned = true; 32551 32552 error('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.'); 32553 } 32554 } 32555 32556 container.removeChild(rootSibling); 32557 } 32558 } 32559 32560 { 32561 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 32562 warnedAboutHydrateAPI = true; 32563 32564 warn('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.'); 32565 } 32566 } 32567 32568 return createLegacyRoot(container, shouldHydrate ? { 32569 hydrate: true 32570 } : undefined); 32571} 32572 32573function warnOnInvalidCallback$1(callback, callerName) { 32574 { 32575 if (callback !== null && typeof callback !== 'function') { 32576 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 32577 } 32578 } 32579} 32580 32581function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 32582 { 32583 topLevelUpdateWarnings(container); 32584 warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render'); 32585 } // TODO: Without `any` type, Flow says "Property cannot be accessed on any 32586 // member of intersection type." Whyyyyyy. 32587 32588 32589 var root = container._reactRootContainer; 32590 var fiberRoot; 32591 32592 if (!root) { 32593 // Initial mount 32594 root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); 32595 fiberRoot = root._internalRoot; 32596 32597 if (typeof callback === 'function') { 32598 var originalCallback = callback; 32599 32600 callback = function () { 32601 var instance = getPublicRootInstance(fiberRoot); 32602 originalCallback.call(instance); 32603 }; 32604 } // Initial mount should not be batched. 32605 32606 32607 unbatchedUpdates(function () { 32608 updateContainer(children, fiberRoot, parentComponent, callback); 32609 }); 32610 } else { 32611 fiberRoot = root._internalRoot; 32612 32613 if (typeof callback === 'function') { 32614 var _originalCallback = callback; 32615 32616 callback = function () { 32617 var instance = getPublicRootInstance(fiberRoot); 32618 32619 _originalCallback.call(instance); 32620 }; 32621 } // Update 32622 32623 32624 updateContainer(children, fiberRoot, parentComponent, callback); 32625 } 32626 32627 return getPublicRootInstance(fiberRoot); 32628} 32629 32630function findDOMNode(componentOrElement) { 32631 { 32632 var owner = ReactCurrentOwner$3.current; 32633 32634 if (owner !== null && owner.stateNode !== null) { 32635 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 32636 32637 if (!warnedAboutRefsInRender) { 32638 error('%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.type) || 'A component'); 32639 } 32640 32641 owner.stateNode._warnedAboutRefsInRender = true; 32642 } 32643 } 32644 32645 if (componentOrElement == null) { 32646 return null; 32647 } 32648 32649 if (componentOrElement.nodeType === ELEMENT_NODE) { 32650 return componentOrElement; 32651 } 32652 32653 { 32654 return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); 32655 } 32656} 32657function hydrate(element, container, callback) { 32658 if (!isValidContainer(container)) { 32659 { 32660 throw Error( "Target container is not a DOM element." ); 32661 } 32662 } 32663 32664 { 32665 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 32666 32667 if (isModernRoot) { 32668 error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?'); 32669 } 32670 } // TODO: throw or warn if we couldn't hydrate? 32671 32672 32673 return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); 32674} 32675function render(element, container, callback) { 32676 if (!isValidContainer(container)) { 32677 { 32678 throw Error( "Target container is not a DOM element." ); 32679 } 32680 } 32681 32682 { 32683 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 32684 32685 if (isModernRoot) { 32686 error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?'); 32687 } 32688 } 32689 32690 return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); 32691} 32692function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 32693 if (!isValidContainer(containerNode)) { 32694 { 32695 throw Error( "Target container is not a DOM element." ); 32696 } 32697 } 32698 32699 if (!(parentComponent != null && has(parentComponent))) { 32700 { 32701 throw Error( "parentComponent must be a valid React Component" ); 32702 } 32703 } 32704 32705 return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 32706} 32707function unmountComponentAtNode(container) { 32708 if (!isValidContainer(container)) { 32709 { 32710 throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." ); 32711 } 32712 } 32713 32714 { 32715 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 32716 32717 if (isModernRoot) { 32718 error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?'); 32719 } 32720 } 32721 32722 if (container._reactRootContainer) { 32723 { 32724 var rootEl = getReactRootElementInContainer(container); 32725 var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl); 32726 32727 if (renderedByDifferentReact) { 32728 error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); 32729 } 32730 } // Unmount should not be batched. 32731 32732 32733 unbatchedUpdates(function () { 32734 legacyRenderSubtreeIntoContainer(null, null, container, false, function () { 32735 // $FlowFixMe This should probably use `delete container._reactRootContainer` 32736 container._reactRootContainer = null; 32737 unmarkContainerAsRoot(container); 32738 }); 32739 }); // If you call unmountComponentAtNode twice in quick succession, you'll 32740 // get `true` twice. That's probably fine? 32741 32742 return true; 32743 } else { 32744 { 32745 var _rootEl = getReactRootElementInContainer(container); 32746 32747 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); // Check if the container itself is a React root node. 32748 32749 var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 32750 32751 if (hasNonRootReactChild) { 32752 error("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.'); 32753 } 32754 } 32755 32756 return false; 32757 } 32758} 32759 32760function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. 32761implementation) { 32762 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 32763 return { 32764 // This tag allow us to uniquely identify this as a React Portal 32765 $$typeof: REACT_PORTAL_TYPE, 32766 key: key == null ? null : '' + key, 32767 children: children, 32768 containerInfo: containerInfo, 32769 implementation: implementation 32770 }; 32771} 32772 32773var ReactVersion = '16.13.1'; 32774 32775setAttemptUserBlockingHydration(attemptUserBlockingHydration$1); 32776setAttemptContinuousHydration(attemptContinuousHydration$1); 32777setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1); 32778var didWarnAboutUnstableCreatePortal = false; 32779 32780{ 32781 if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype 32782 Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype 32783 Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 32784 error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 32785 } 32786} 32787 32788setRestoreImplementation(restoreControlledState$3); 32789setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1); 32790 32791function createPortal$1(children, container) { 32792 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 32793 32794 if (!isValidContainer(container)) { 32795 { 32796 throw Error( "Target container is not a DOM element." ); 32797 } 32798 } // TODO: pass ReactDOM portal implementation as third argument 32799 // $FlowFixMe The Flow type is opaque but there's no way to actually create it. 32800 32801 32802 return createPortal(children, container, null, key); 32803} 32804 32805function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 32806 32807 return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback); 32808} 32809 32810function unstable_createPortal(children, container) { 32811 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 32812 32813 { 32814 if (!didWarnAboutUnstableCreatePortal) { 32815 didWarnAboutUnstableCreatePortal = true; 32816 32817 warn('The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.'); 32818 } 32819 } 32820 32821 return createPortal$1(children, container, key); 32822} 32823 32824var Internals = { 32825 // Keep in sync with ReactDOMUnstableNativeDependencies.js 32826 // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification. 32827 Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing] 32828}; 32829var foundDevTools = injectIntoDevTools({ 32830 findFiberByHostInstance: getClosestInstanceFromNode, 32831 bundleType: 1 , 32832 version: ReactVersion, 32833 rendererPackageName: 'react-dom' 32834}); 32835 32836{ 32837 if (!foundDevTools && canUseDOM && window.top === window.self) { 32838 // If we're in Chrome or Firefox, provide a download link if not installed. 32839 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 32840 var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://. 32841 32842 if (/^(https?|file):$/.test(protocol)) { 32843 // eslint-disable-next-line react-internal/no-production-logging 32844 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'); 32845 } 32846 } 32847 } 32848} 32849 32850exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; 32851exports.createPortal = createPortal$1; 32852exports.findDOMNode = findDOMNode; 32853exports.flushSync = flushSync; 32854exports.hydrate = hydrate; 32855exports.render = render; 32856exports.unmountComponentAtNode = unmountComponentAtNode; 32857exports.unstable_batchedUpdates = batchedUpdates$1; 32858exports.unstable_createPortal = unstable_createPortal; 32859exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer; 32860exports.version = ReactVersion; 32861 })(); 32862} 32863 32864 32865/***/ }), 32866
vendor: 1,716 bytes, lines 32867-32911
32867/***/ "../../node_modules/react-dom/index.js": 32868/*!********************************************************************************************************************************!*\ 32869 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/react-dom/index.js ***! 32870 \********************************************************************************************************************************/ 32871/*! no static exports found */ 32872/***/ (function(module, exports, __webpack_require__) { 32873 32874"use strict"; 32875 32876 32877function checkDCE() { 32878 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 32879 if ( 32880 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 32881 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 32882 ) { 32883 return; 32884 } 32885 if (true) { 32886 // This branch is unreachable because this function is only called 32887 // in production, but the condition is true only in development. 32888 // Therefore if the branch is still here, dead code elimination wasn't 32889 // properly applied. 32890 // Don't change the message. React DevTools relies on it. Also make sure 32891 // this message doesn't occur elsewhere in this function, or it will cause 32892 // a false positive. 32893 throw new Error('^_^'); 32894 } 32895 try { 32896 // Verify that the code above has been dead code eliminated (DCE'd). 32897 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 32898 } catch (err) { 32899 // DevTools shouldn't crash React, no matter what. 32900 // We should still report in case we break this code. 32901 console.error(err); 32902 } 32903} 32904 32905if (false) {} else { 32906 module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "../../node_modules/react-dom/cjs/react-dom.development.js"); 32907} 32908 32909 32910/***/ }), 32911
vendor: 61,338 bytes, lines 32912-34835
32912/***/ "../../node_modules/react/cjs/react.development.js": 32913/*!********************************************************************************************************************************************!*\ 32914 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/react/cjs/react.development.js ***! 32915 \********************************************************************************************************************************************/ 32916/*! no static exports found */ 32917/***/ (function(module, exports, __webpack_require__) { 32918 32919"use strict"; 32920/** @license React v16.13.1 32921 * react.development.js 32922 * 32923 * Copyright (c) Facebook, Inc. and its affiliates. 32924 * 32925 * This source code is licensed under the MIT license found in the 32926 * LICENSE file in the root directory of this source tree. 32927 */ 32928 32929 32930 32931 32932 32933if (true) { 32934 (function() { 32935'use strict'; 32936 32937var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js"); 32938var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js"); 32939 32940var ReactVersion = '16.13.1'; 32941 32942// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 32943// nor polyfill, then a plain number is used for performance. 32944var hasSymbol = typeof Symbol === 'function' && Symbol.for; 32945var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 32946var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 32947var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 32948var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 32949var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 32950var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 32951var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary 32952var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; 32953var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 32954var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; 32955var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; 32956var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; 32957var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; 32958var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; 32959var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; 32960var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; 32961var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; 32962var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 32963var FAUX_ITERATOR_SYMBOL = '@@iterator'; 32964function getIteratorFn(maybeIterable) { 32965 if (maybeIterable === null || typeof maybeIterable !== 'object') { 32966 return null; 32967 } 32968 32969 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 32970 32971 if (typeof maybeIterator === 'function') { 32972 return maybeIterator; 32973 } 32974 32975 return null; 32976} 32977 32978/** 32979 * Keeps track of the current dispatcher. 32980 */ 32981var ReactCurrentDispatcher = { 32982 /** 32983 * @internal 32984 * @type {ReactComponent} 32985 */ 32986 current: null 32987}; 32988 32989/** 32990 * Keeps track of the current batch's configuration such as how long an update 32991 * should suspend for if it needs to. 32992 */ 32993var ReactCurrentBatchConfig = { 32994 suspense: null 32995}; 32996 32997/** 32998 * Keeps track of the current owner. 32999 * 33000 * The current owner is the component who should own any components that are 33001 * currently being constructed. 33002 */ 33003var ReactCurrentOwner = { 33004 /** 33005 * @internal 33006 * @type {ReactComponent} 33007 */ 33008 current: null 33009}; 33010 33011var BEFORE_SLASH_RE = /^(.*)[\\\/]/; 33012function describeComponentFrame (name, source, ownerName) { 33013 var sourceInfo = ''; 33014 33015 if (source) { 33016 var path = source.fileName; 33017 var fileName = path.replace(BEFORE_SLASH_RE, ''); 33018 33019 { 33020 // In DEV, include code for a common special case: 33021 // prefer "folder/index.js" instead of just "index.js". 33022 if (/^index\./.test(fileName)) { 33023 var match = path.match(BEFORE_SLASH_RE); 33024 33025 if (match) { 33026 var pathBeforeSlash = match[1]; 33027 33028 if (pathBeforeSlash) { 33029 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); 33030 fileName = folderName + '/' + fileName; 33031 } 33032 } 33033 } 33034 } 33035 33036 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; 33037 } else if (ownerName) { 33038 sourceInfo = ' (created by ' + ownerName + ')'; 33039 } 33040 33041 return '\n in ' + (name || 'Unknown') + sourceInfo; 33042} 33043 33044var Resolved = 1; 33045function refineResolvedLazyComponent(lazyComponent) { 33046 return lazyComponent._status === Resolved ? lazyComponent._result : null; 33047} 33048 33049function getWrappedName(outerType, innerType, wrapperName) { 33050 var functionName = innerType.displayName || innerType.name || ''; 33051 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 33052} 33053 33054function getComponentName(type) { 33055 if (type == null) { 33056 // Host root, text node or just invalid type. 33057 return null; 33058 } 33059 33060 { 33061 if (typeof type.tag === 'number') { 33062 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 33063 } 33064 } 33065 33066 if (typeof type === 'function') { 33067 return type.displayName || type.name || null; 33068 } 33069 33070 if (typeof type === 'string') { 33071 return type; 33072 } 33073 33074 switch (type) { 33075 case REACT_FRAGMENT_TYPE: 33076 return 'Fragment'; 33077 33078 case REACT_PORTAL_TYPE: 33079 return 'Portal'; 33080 33081 case REACT_PROFILER_TYPE: 33082 return "Profiler"; 33083 33084 case REACT_STRICT_MODE_TYPE: 33085 return 'StrictMode'; 33086 33087 case REACT_SUSPENSE_TYPE: 33088 return 'Suspense'; 33089 33090 case REACT_SUSPENSE_LIST_TYPE: 33091 return 'SuspenseList'; 33092 } 33093 33094 if (typeof type === 'object') { 33095 switch (type.$$typeof) { 33096 case REACT_CONTEXT_TYPE: 33097 return 'Context.Consumer'; 33098 33099 case REACT_PROVIDER_TYPE: 33100 return 'Context.Provider'; 33101 33102 case REACT_FORWARD_REF_TYPE: 33103 return getWrappedName(type, type.render, 'ForwardRef'); 33104 33105 case REACT_MEMO_TYPE: 33106 return getComponentName(type.type); 33107 33108 case REACT_BLOCK_TYPE: 33109 return getComponentName(type.render); 33110 33111 case REACT_LAZY_TYPE: 33112 { 33113 var thenable = type; 33114 var resolvedThenable = refineResolvedLazyComponent(thenable); 33115 33116 if (resolvedThenable) { 33117 return getComponentName(resolvedThenable); 33118 } 33119 33120 break; 33121 } 33122 } 33123 } 33124 33125 return null; 33126} 33127 33128var ReactDebugCurrentFrame = {}; 33129var currentlyValidatingElement = null; 33130function setCurrentlyValidatingElement(element) { 33131 { 33132 currentlyValidatingElement = element; 33133 } 33134} 33135 33136{ 33137 // Stack implementation injected by the current renderer. 33138 ReactDebugCurrentFrame.getCurrentStack = null; 33139 33140 ReactDebugCurrentFrame.getStackAddendum = function () { 33141 var stack = ''; // Add an extra top frame while an element is being validated 33142 33143 if (currentlyValidatingElement) { 33144 var name = getComponentName(currentlyValidatingElement.type); 33145 var owner = currentlyValidatingElement._owner; 33146 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); 33147 } // Delegate to the injected renderer-specific implementation 33148 33149 33150 var impl = ReactDebugCurrentFrame.getCurrentStack; 33151 33152 if (impl) { 33153 stack += impl() || ''; 33154 } 33155 33156 return stack; 33157 }; 33158} 33159 33160/** 33161 * Used by act() to track whether you're inside an act() scope. 33162 */ 33163var IsSomeRendererActing = { 33164 current: false 33165}; 33166 33167var ReactSharedInternals = { 33168 ReactCurrentDispatcher: ReactCurrentDispatcher, 33169 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 33170 ReactCurrentOwner: ReactCurrentOwner, 33171 IsSomeRendererActing: IsSomeRendererActing, 33172 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 33173 assign: _assign 33174}; 33175 33176{ 33177 _assign(ReactSharedInternals, { 33178 // These should not be included in production. 33179 ReactDebugCurrentFrame: ReactDebugCurrentFrame, 33180 // Shim for React DOM 16.0.0 which still destructured (but not used) this. 33181 // TODO: remove in React 17.0. 33182 ReactComponentTreeHook: {} 33183 }); 33184} 33185 33186// by calls to these methods by a Babel plugin. 33187// 33188// In PROD (or in packages without access to React internals), 33189// they are left as they are instead. 33190 33191function warn(format) { 33192 { 33193 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 33194 args[_key - 1] = arguments[_key]; 33195 } 33196 33197 printWarning('warn', format, args); 33198 } 33199} 33200function error(format) { 33201 { 33202 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 33203 args[_key2 - 1] = arguments[_key2]; 33204 } 33205 33206 printWarning('error', format, args); 33207 } 33208} 33209 33210function printWarning(level, format, args) { 33211 // When changing this logic, you might want to also 33212 // update consoleWithStackDev.www.js as well. 33213 { 33214 var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; 33215 33216 if (!hasExistingStack) { 33217 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 33218 var stack = ReactDebugCurrentFrame.getStackAddendum(); 33219 33220 if (stack !== '') { 33221 format += '%s'; 33222 args = args.concat([stack]); 33223 } 33224 } 33225 33226 var argsWithFormat = args.map(function (item) { 33227 return '' + item; 33228 }); // Careful: RN currently depends on this prefix 33229 33230 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 33231 // breaks IE9: https://github.com/facebook/react/issues/13610 33232 // eslint-disable-next-line react-internal/no-production-logging 33233 33234 Function.prototype.apply.call(console[level], console, argsWithFormat); 33235 33236 try { 33237 // --- Welcome to debugging React --- 33238 // This error was thrown as a convenience so that you can use this stack 33239 // to find the callsite that caused this warning to fire. 33240 var argIndex = 0; 33241 var message = 'Warning: ' + format.replace(/%s/g, function () { 33242 return args[argIndex++]; 33243 }); 33244 throw new Error(message); 33245 } catch (x) {} 33246 } 33247} 33248 33249var didWarnStateUpdateForUnmountedComponent = {}; 33250 33251function warnNoop(publicInstance, callerName) { 33252 { 33253 var _constructor = publicInstance.constructor; 33254 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 33255 var warningKey = componentName + "." + callerName; 33256 33257 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 33258 return; 33259 } 33260 33261 error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); 33262 33263 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 33264 } 33265} 33266/** 33267 * This is the abstract API for an update queue. 33268 */ 33269 33270 33271var ReactNoopUpdateQueue = { 33272 /** 33273 * Checks whether or not this composite component is mounted. 33274 * @param {ReactClass} publicInstance The instance we want to test. 33275 * @return {boolean} True if mounted, false otherwise. 33276 * @protected 33277 * @final 33278 */ 33279 isMounted: function (publicInstance) { 33280 return false; 33281 }, 33282 33283 /** 33284 * Forces an update. This should only be invoked when it is known with 33285 * certainty that we are **not** in a DOM transaction. 33286 * 33287 * You may want to call this when you know that some deeper aspect of the 33288 * component's state has changed but `setState` was not called. 33289 * 33290 * This will not invoke `shouldComponentUpdate`, but it will invoke 33291 * `componentWillUpdate` and `componentDidUpdate`. 33292 * 33293 * @param {ReactClass} publicInstance The instance that should rerender. 33294 * @param {?function} callback Called after component is updated. 33295 * @param {?string} callerName name of the calling function in the public API. 33296 * @internal 33297 */ 33298 enqueueForceUpdate: function (publicInstance, callback, callerName) { 33299 warnNoop(publicInstance, 'forceUpdate'); 33300 }, 33301 33302 /** 33303 * Replaces all of the state. Always use this or `setState` to mutate state. 33304 * You should treat `this.state` as immutable. 33305 * 33306 * There is no guarantee that `this.state` will be immediately updated, so 33307 * accessing `this.state` after calling this method may return the old value. 33308 * 33309 * @param {ReactClass} publicInstance The instance that should rerender. 33310 * @param {object} completeState Next state. 33311 * @param {?function} callback Called after component is updated. 33312 * @param {?string} callerName name of the calling function in the public API. 33313 * @internal 33314 */ 33315 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 33316 warnNoop(publicInstance, 'replaceState'); 33317 }, 33318 33319 /** 33320 * Sets a subset of the state. This only exists because _pendingState is 33321 * internal. This provides a merging strategy that is not available to deep 33322 * properties which is confusing. TODO: Expose pendingState or don't use it 33323 * during the merge. 33324 * 33325 * @param {ReactClass} publicInstance The instance that should rerender. 33326 * @param {object} partialState Next partial state to be merged with state. 33327 * @param {?function} callback Called after component is updated. 33328 * @param {?string} Name of the calling function in the public API. 33329 * @internal 33330 */ 33331 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 33332 warnNoop(publicInstance, 'setState'); 33333 } 33334}; 33335 33336var emptyObject = {}; 33337 33338{ 33339 Object.freeze(emptyObject); 33340} 33341/** 33342 * Base class helpers for the updating state of a component. 33343 */ 33344 33345 33346function Component(props, context, updater) { 33347 this.props = props; 33348 this.context = context; // If a component has string refs, we will assign a different object later. 33349 33350 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the 33351 // renderer. 33352 33353 this.updater = updater || ReactNoopUpdateQueue; 33354} 33355 33356Component.prototype.isReactComponent = {}; 33357/** 33358 * Sets a subset of the state. Always use this to mutate 33359 * state. You should treat `this.state` as immutable. 33360 * 33361 * There is no guarantee that `this.state` will be immediately updated, so 33362 * accessing `this.state` after calling this method may return the old value. 33363 * 33364 * There is no guarantee that calls to `setState` will run synchronously, 33365 * as they may eventually be batched together. You can provide an optional 33366 * callback that will be executed when the call to setState is actually 33367 * completed. 33368 * 33369 * When a function is provided to setState, it will be called at some point in 33370 * the future (not synchronously). It will be called with the up to date 33371 * component arguments (state, props, context). These values can be different 33372 * from this.* because your function may be called after receiveProps but before 33373 * shouldComponentUpdate, and this new state, props, and context will not yet be 33374 * assigned to this. 33375 * 33376 * @param {object|function} partialState Next partial state or function to 33377 * produce next partial state to be merged with current state. 33378 * @param {?function} callback Called after state is updated. 33379 * @final 33380 * @protected 33381 */ 33382 33383Component.prototype.setState = function (partialState, callback) { 33384 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { 33385 { 33386 throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); 33387 } 33388 } 33389 33390 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 33391}; 33392/** 33393 * Forces an update. This should only be invoked when it is known with 33394 * certainty that we are **not** in a DOM transaction. 33395 * 33396 * You may want to call this when you know that some deeper aspect of the 33397 * component's state has changed but `setState` was not called. 33398 * 33399 * This will not invoke `shouldComponentUpdate`, but it will invoke 33400 * `componentWillUpdate` and `componentDidUpdate`. 33401 * 33402 * @param {?function} callback Called after update is complete. 33403 * @final 33404 * @protected 33405 */ 33406 33407 33408Component.prototype.forceUpdate = function (callback) { 33409 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 33410}; 33411/** 33412 * Deprecated APIs. These APIs used to exist on classic React classes but since 33413 * we would like to deprecate them, we're not going to move them over to this 33414 * modern base class. Instead, we define a getter that warns if it's accessed. 33415 */ 33416 33417 33418{ 33419 var deprecatedAPIs = { 33420 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 33421 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 33422 }; 33423 33424 var defineDeprecationWarning = function (methodName, info) { 33425 Object.defineProperty(Component.prototype, methodName, { 33426 get: function () { 33427 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 33428 33429 return undefined; 33430 } 33431 }); 33432 }; 33433 33434 for (var fnName in deprecatedAPIs) { 33435 if (deprecatedAPIs.hasOwnProperty(fnName)) { 33436 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 33437 } 33438 } 33439} 33440 33441function ComponentDummy() {} 33442 33443ComponentDummy.prototype = Component.prototype; 33444/** 33445 * Convenience component with default shallow equality check for sCU. 33446 */ 33447 33448function PureComponent(props, context, updater) { 33449 this.props = props; 33450 this.context = context; // If a component has string refs, we will assign a different object later. 33451 33452 this.refs = emptyObject; 33453 this.updater = updater || ReactNoopUpdateQueue; 33454} 33455 33456var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 33457pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. 33458 33459_assign(pureComponentPrototype, Component.prototype); 33460 33461pureComponentPrototype.isPureReactComponent = true; 33462 33463// an immutable object with a single mutable value 33464function createRef() { 33465 var refObject = { 33466 current: null 33467 }; 33468 33469 { 33470 Object.seal(refObject); 33471 } 33472 33473 return refObject; 33474} 33475 33476var hasOwnProperty = Object.prototype.hasOwnProperty; 33477var RESERVED_PROPS = { 33478 key: true, 33479 ref: true, 33480 __self: true, 33481 __source: true 33482}; 33483var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; 33484 33485{ 33486 didWarnAboutStringRefs = {}; 33487} 33488 33489function hasValidRef(config) { 33490 { 33491 if (hasOwnProperty.call(config, 'ref')) { 33492 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 33493 33494 if (getter && getter.isReactWarning) { 33495 return false; 33496 } 33497 } 33498 } 33499 33500 return config.ref !== undefined; 33501} 33502 33503function hasValidKey(config) { 33504 { 33505 if (hasOwnProperty.call(config, 'key')) { 33506 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 33507 33508 if (getter && getter.isReactWarning) { 33509 return false; 33510 } 33511 } 33512 } 33513 33514 return config.key !== undefined; 33515} 33516 33517function defineKeyPropWarningGetter(props, displayName) { 33518 var warnAboutAccessingKey = function () { 33519 { 33520 if (!specialPropKeyWarningShown) { 33521 specialPropKeyWarningShown = true; 33522 33523 error('%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); 33524 } 33525 } 33526 }; 33527 33528 warnAboutAccessingKey.isReactWarning = true; 33529 Object.defineProperty(props, 'key', { 33530 get: warnAboutAccessingKey, 33531 configurable: true 33532 }); 33533} 33534 33535function defineRefPropWarningGetter(props, displayName) { 33536 var warnAboutAccessingRef = function () { 33537 { 33538 if (!specialPropRefWarningShown) { 33539 specialPropRefWarningShown = true; 33540 33541 error('%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); 33542 } 33543 } 33544 }; 33545 33546 warnAboutAccessingRef.isReactWarning = true; 33547 Object.defineProperty(props, 'ref', { 33548 get: warnAboutAccessingRef, 33549 configurable: true 33550 }); 33551} 33552 33553function warnIfStringRefCannotBeAutoConverted(config) { 33554 { 33555 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { 33556 var componentName = getComponentName(ReactCurrentOwner.current.type); 33557 33558 if (!didWarnAboutStringRefs[componentName]) { 33559 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref); 33560 33561 didWarnAboutStringRefs[componentName] = true; 33562 } 33563 } 33564 } 33565} 33566/** 33567 * Factory method to create a new React element. This no longer adheres to 33568 * the class pattern, so do not use new to call it. Also, instanceof check 33569 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 33570 * if something is a React Element. 33571 * 33572 * @param {*} type 33573 * @param {*} props 33574 * @param {*} key 33575 * @param {string|object} ref 33576 * @param {*} owner 33577 * @param {*} self A *temporary* helper to detect places where `this` is 33578 * different from the `owner` when React.createElement is called, so that we 33579 * can warn. We want to get rid of owner and replace string `ref`s with arrow 33580 * functions, and as long as `this` and owner are the same, there will be no 33581 * change in behavior. 33582 * @param {*} source An annotation object (added by a transpiler or otherwise) 33583 * indicating filename, line number, and/or other information. 33584 * @internal 33585 */ 33586 33587 33588var ReactElement = function (type, key, ref, self, source, owner, props) { 33589 var element = { 33590 // This tag allows us to uniquely identify this as a React Element 33591 $$typeof: REACT_ELEMENT_TYPE, 33592 // Built-in properties that belong on the element 33593 type: type, 33594 key: key, 33595 ref: ref, 33596 props: props, 33597 // Record the component responsible for creating this element. 33598 _owner: owner 33599 }; 33600 33601 { 33602 // The validation flag is currently mutative. We put it on 33603 // an external backing store so that we can freeze the whole object. 33604 // This can be replaced with a WeakMap once they are implemented in 33605 // commonly used development environments. 33606 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 33607 // the validation flag non-enumerable (where possible, which should 33608 // include every environment we run tests in), so the test framework 33609 // ignores it. 33610 33611 Object.defineProperty(element._store, 'validated', { 33612 configurable: false, 33613 enumerable: false, 33614 writable: true, 33615 value: false 33616 }); // self and source are DEV only properties. 33617 33618 Object.defineProperty(element, '_self', { 33619 configurable: false, 33620 enumerable: false, 33621 writable: false, 33622 value: self 33623 }); // Two elements created in two different places should be considered 33624 // equal for testing purposes and therefore we hide it from enumeration. 33625 33626 Object.defineProperty(element, '_source', { 33627 configurable: false, 33628 enumerable: false, 33629 writable: false, 33630 value: source 33631 }); 33632 33633 if (Object.freeze) { 33634 Object.freeze(element.props); 33635 Object.freeze(element); 33636 } 33637 } 33638 33639 return element; 33640}; 33641/** 33642 * Create and return a new ReactElement of the given type. 33643 * See https://reactjs.org/docs/react-api.html#createelement 33644 */ 33645 33646function createElement(type, config, children) { 33647 var propName; // Reserved names are extracted 33648 33649 var props = {}; 33650 var key = null; 33651 var ref = null; 33652 var self = null; 33653 var source = null; 33654 33655 if (config != null) { 33656 if (hasValidRef(config)) { 33657 ref = config.ref; 33658 33659 { 33660 warnIfStringRefCannotBeAutoConverted(config); 33661 } 33662 } 33663 33664 if (hasValidKey(config)) { 33665 key = '' + config.key; 33666 } 33667 33668 self = config.__self === undefined ? null : config.__self; 33669 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object 33670 33671 for (propName in config) { 33672 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 33673 props[propName] = config[propName]; 33674 } 33675 } 33676 } // Children can be more than one argument, and those are transferred onto 33677 // the newly allocated props object. 33678 33679 33680 var childrenLength = arguments.length - 2; 33681 33682 if (childrenLength === 1) { 33683 props.children = children; 33684 } else if (childrenLength > 1) { 33685 var childArray = Array(childrenLength); 33686 33687 for (var i = 0; i < childrenLength; i++) { 33688 childArray[i] = arguments[i + 2]; 33689 } 33690 33691 { 33692 if (Object.freeze) { 33693 Object.freeze(childArray); 33694 } 33695 } 33696 33697 props.children = childArray; 33698 } // Resolve default props 33699 33700 33701 if (type && type.defaultProps) { 33702 var defaultProps = type.defaultProps; 33703 33704 for (propName in defaultProps) { 33705 if (props[propName] === undefined) { 33706 props[propName] = defaultProps[propName]; 33707 } 33708 } 33709 } 33710 33711 { 33712 if (key || ref) { 33713 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 33714 33715 if (key) { 33716 defineKeyPropWarningGetter(props, displayName); 33717 } 33718 33719 if (ref) { 33720 defineRefPropWarningGetter(props, displayName); 33721 } 33722 } 33723 } 33724 33725 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 33726} 33727function cloneAndReplaceKey(oldElement, newKey) { 33728 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 33729 return newElement; 33730} 33731/** 33732 * Clone and return a new ReactElement using element as the starting point. 33733 * See https://reactjs.org/docs/react-api.html#cloneelement 33734 */ 33735 33736function cloneElement(element, config, children) { 33737 if (!!(element === null || element === undefined)) { 33738 { 33739 throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); 33740 } 33741 } 33742 33743 var propName; // Original props are copied 33744 33745 var props = _assign({}, element.props); // Reserved names are extracted 33746 33747 33748 var key = element.key; 33749 var ref = element.ref; // Self is preserved since the owner is preserved. 33750 33751 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a 33752 // transpiler, and the original source is probably a better indicator of the 33753 // true owner. 33754 33755 var source = element._source; // Owner will be preserved, unless ref is overridden 33756 33757 var owner = element._owner; 33758 33759 if (config != null) { 33760 if (hasValidRef(config)) { 33761 // Silently steal the ref from the parent. 33762 ref = config.ref; 33763 owner = ReactCurrentOwner.current; 33764 } 33765 33766 if (hasValidKey(config)) { 33767 key = '' + config.key; 33768 } // Remaining properties override existing props 33769 33770 33771 var defaultProps; 33772 33773 if (element.type && element.type.defaultProps) { 33774 defaultProps = element.type.defaultProps; 33775 } 33776 33777 for (propName in config) { 33778 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 33779 if (config[propName] === undefined && defaultProps !== undefined) { 33780 // Resolve default props 33781 props[propName] = defaultProps[propName]; 33782 } else { 33783 props[propName] = config[propName]; 33784 } 33785 } 33786 } 33787 } // Children can be more than one argument, and those are transferred onto 33788 // the newly allocated props object. 33789 33790 33791 var childrenLength = arguments.length - 2; 33792 33793 if (childrenLength === 1) { 33794 props.children = children; 33795 } else if (childrenLength > 1) { 33796 var childArray = Array(childrenLength); 33797 33798 for (var i = 0; i < childrenLength; i++) { 33799 childArray[i] = arguments[i + 2]; 33800 } 33801 33802 props.children = childArray; 33803 } 33804 33805 return ReactElement(element.type, key, ref, self, source, owner, props); 33806} 33807/** 33808 * Verifies the object is a ReactElement. 33809 * See https://reactjs.org/docs/react-api.html#isvalidelement 33810 * @param {?object} object 33811 * @return {boolean} True if `object` is a ReactElement. 33812 * @final 33813 */ 33814 33815function isValidElement(object) { 33816 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 33817} 33818 33819var SEPARATOR = '.'; 33820var SUBSEPARATOR = ':'; 33821/** 33822 * Escape and wrap key so it is safe to use as a reactid 33823 * 33824 * @param {string} key to be escaped. 33825 * @return {string} the escaped key. 33826 */ 33827 33828function escape(key) { 33829 var escapeRegex = /[=:]/g; 33830 var escaperLookup = { 33831 '=': '=0', 33832 ':': '=2' 33833 }; 33834 var escapedString = ('' + key).replace(escapeRegex, function (match) { 33835 return escaperLookup[match]; 33836 }); 33837 return '$' + escapedString; 33838} 33839/** 33840 * TODO: Test that a single child and an array with one item have the same key 33841 * pattern. 33842 */ 33843 33844 33845var didWarnAboutMaps = false; 33846var userProvidedKeyEscapeRegex = /\/+/g; 33847 33848function escapeUserProvidedKey(text) { 33849 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); 33850} 33851 33852var POOL_SIZE = 10; 33853var traverseContextPool = []; 33854 33855function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { 33856 if (traverseContextPool.length) { 33857 var traverseContext = traverseContextPool.pop(); 33858 traverseContext.result = mapResult; 33859 traverseContext.keyPrefix = keyPrefix; 33860 traverseContext.func = mapFunction; 33861 traverseContext.context = mapContext; 33862 traverseContext.count = 0; 33863 return traverseContext; 33864 } else { 33865 return { 33866 result: mapResult, 33867 keyPrefix: keyPrefix, 33868 func: mapFunction, 33869 context: mapContext, 33870 count: 0 33871 }; 33872 } 33873} 33874 33875function releaseTraverseContext(traverseContext) { 33876 traverseContext.result = null; 33877 traverseContext.keyPrefix = null; 33878 traverseContext.func = null; 33879 traverseContext.context = null; 33880 traverseContext.count = 0; 33881 33882 if (traverseContextPool.length < POOL_SIZE) { 33883 traverseContextPool.push(traverseContext); 33884 } 33885} 33886/** 33887 * @param {?*} children Children tree container. 33888 * @param {!string} nameSoFar Name of the key path so far. 33889 * @param {!function} callback Callback to invoke with each child found. 33890 * @param {?*} traverseContext Used to pass information throughout the traversal 33891 * process. 33892 * @return {!number} The number of children in this subtree. 33893 */ 33894 33895 33896function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { 33897 var type = typeof children; 33898 33899 if (type === 'undefined' || type === 'boolean') { 33900 // All of the above are perceived as null. 33901 children = null; 33902 } 33903 33904 var invokeCallback = false; 33905 33906 if (children === null) { 33907 invokeCallback = true; 33908 } else { 33909 switch (type) { 33910 case 'string': 33911 case 'number': 33912 invokeCallback = true; 33913 break; 33914 33915 case 'object': 33916 switch (children.$$typeof) { 33917 case REACT_ELEMENT_TYPE: 33918 case REACT_PORTAL_TYPE: 33919 invokeCallback = true; 33920 } 33921 33922 } 33923 } 33924 33925 if (invokeCallback) { 33926 callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array 33927 // so that it's consistent if the number of children grows. 33928 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); 33929 return 1; 33930 } 33931 33932 var child; 33933 var nextName; 33934 var subtreeCount = 0; // Count of children found in the current subtree. 33935 33936 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 33937 33938 if (Array.isArray(children)) { 33939 for (var i = 0; i < children.length; i++) { 33940 child = children[i]; 33941 nextName = nextNamePrefix + getComponentKey(child, i); 33942 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 33943 } 33944 } else { 33945 var iteratorFn = getIteratorFn(children); 33946 33947 if (typeof iteratorFn === 'function') { 33948 33949 { 33950 // Warn about using Maps as children 33951 if (iteratorFn === children.entries) { 33952 if (!didWarnAboutMaps) { 33953 warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.'); 33954 } 33955 33956 didWarnAboutMaps = true; 33957 } 33958 } 33959 33960 var iterator = iteratorFn.call(children); 33961 var step; 33962 var ii = 0; 33963 33964 while (!(step = iterator.next()).done) { 33965 child = step.value; 33966 nextName = nextNamePrefix + getComponentKey(child, ii++); 33967 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 33968 } 33969 } else if (type === 'object') { 33970 var addendum = ''; 33971 33972 { 33973 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); 33974 } 33975 33976 var childrenString = '' + children; 33977 33978 { 33979 { 33980 throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum ); 33981 } 33982 } 33983 } 33984 } 33985 33986 return subtreeCount; 33987} 33988/** 33989 * Traverses children that are typically specified as `props.children`, but 33990 * might also be specified through attributes: 33991 * 33992 * - `traverseAllChildren(this.props.children, ...)` 33993 * - `traverseAllChildren(this.props.leftPanelChildren, ...)` 33994 * 33995 * The `traverseContext` is an optional argument that is passed through the 33996 * entire traversal. It can be used to store accumulations or anything else that 33997 * the callback might find relevant. 33998 * 33999 * @param {?*} children Children tree object. 34000 * @param {!function} callback To invoke upon traversing each child. 34001 * @param {?*} traverseContext Context for traversal. 34002 * @return {!number} The number of children in this subtree. 34003 */ 34004 34005 34006function traverseAllChildren(children, callback, traverseContext) { 34007 if (children == null) { 34008 return 0; 34009 } 34010 34011 return traverseAllChildrenImpl(children, '', callback, traverseContext); 34012} 34013/** 34014 * Generate a key string that identifies a component within a set. 34015 * 34016 * @param {*} component A component that could contain a manual key. 34017 * @param {number} index Index that is used if a manual key is not provided. 34018 * @return {string} 34019 */ 34020 34021 34022function getComponentKey(component, index) { 34023 // Do some typechecking here since we call this blindly. We want to ensure 34024 // that we don't block potential future ES APIs. 34025 if (typeof component === 'object' && component !== null && component.key != null) { 34026 // Explicit key 34027 return escape(component.key); 34028 } // Implicit key determined by the index in the set 34029 34030 34031 return index.toString(36); 34032} 34033 34034function forEachSingleChild(bookKeeping, child, name) { 34035 var func = bookKeeping.func, 34036 context = bookKeeping.context; 34037 func.call(context, child, bookKeeping.count++); 34038} 34039/** 34040 * Iterates through children that are typically specified as `props.children`. 34041 * 34042 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 34043 * 34044 * The provided forEachFunc(child, index) will be called for each 34045 * leaf child. 34046 * 34047 * @param {?*} children Children tree container. 34048 * @param {function(*, int)} forEachFunc 34049 * @param {*} forEachContext Context for forEachContext. 34050 */ 34051 34052 34053function forEachChildren(children, forEachFunc, forEachContext) { 34054 if (children == null) { 34055 return children; 34056 } 34057 34058 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); 34059 traverseAllChildren(children, forEachSingleChild, traverseContext); 34060 releaseTraverseContext(traverseContext); 34061} 34062 34063function mapSingleChildIntoContext(bookKeeping, child, childKey) { 34064 var result = bookKeeping.result, 34065 keyPrefix = bookKeeping.keyPrefix, 34066 func = bookKeeping.func, 34067 context = bookKeeping.context; 34068 var mappedChild = func.call(context, child, bookKeeping.count++); 34069 34070 if (Array.isArray(mappedChild)) { 34071 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { 34072 return c; 34073 }); 34074 } else if (mappedChild != null) { 34075 if (isValidElement(mappedChild)) { 34076 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as 34077 // traverseAllChildren used to do for objects as children 34078 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); 34079 } 34080 34081 result.push(mappedChild); 34082 } 34083} 34084 34085function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { 34086 var escapedPrefix = ''; 34087 34088 if (prefix != null) { 34089 escapedPrefix = escapeUserProvidedKey(prefix) + '/'; 34090 } 34091 34092 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); 34093 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); 34094 releaseTraverseContext(traverseContext); 34095} 34096/** 34097 * Maps children that are typically specified as `props.children`. 34098 * 34099 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 34100 * 34101 * The provided mapFunction(child, key, index) will be called for each 34102 * leaf child. 34103 * 34104 * @param {?*} children Children tree container. 34105 * @param {function(*, int)} func The map function. 34106 * @param {*} context Context for mapFunction. 34107 * @return {object} Object containing the ordered map of results. 34108 */ 34109 34110 34111function mapChildren(children, func, context) { 34112 if (children == null) { 34113 return children; 34114 } 34115 34116 var result = []; 34117 mapIntoWithKeyPrefixInternal(children, result, null, func, context); 34118 return result; 34119} 34120/** 34121 * Count the number of children that are typically specified as 34122 * `props.children`. 34123 * 34124 * See https://reactjs.org/docs/react-api.html#reactchildrencount 34125 * 34126 * @param {?*} children Children tree container. 34127 * @return {number} The number of children. 34128 */ 34129 34130 34131function countChildren(children) { 34132 return traverseAllChildren(children, function () { 34133 return null; 34134 }, null); 34135} 34136/** 34137 * Flatten a children object (typically specified as `props.children`) and 34138 * return an array with appropriately re-keyed children. 34139 * 34140 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 34141 */ 34142 34143 34144function toArray(children) { 34145 var result = []; 34146 mapIntoWithKeyPrefixInternal(children, result, null, function (child) { 34147 return child; 34148 }); 34149 return result; 34150} 34151/** 34152 * Returns the first child in a collection of children and verifies that there 34153 * is only one child in the collection. 34154 * 34155 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 34156 * 34157 * The current implementation of this function assumes that a single child gets 34158 * passed without a wrapper, but the purpose of this helper function is to 34159 * abstract away the particular structure of children. 34160 * 34161 * @param {?object} children Child collection structure. 34162 * @return {ReactElement} The first and only `ReactElement` contained in the 34163 * structure. 34164 */ 34165 34166 34167function onlyChild(children) { 34168 if (!isValidElement(children)) { 34169 { 34170 throw Error( "React.Children.only expected to receive a single React element child." ); 34171 } 34172 } 34173 34174 return children; 34175} 34176 34177function createContext(defaultValue, calculateChangedBits) { 34178 if (calculateChangedBits === undefined) { 34179 calculateChangedBits = null; 34180 } else { 34181 { 34182 if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { 34183 error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); 34184 } 34185 } 34186 } 34187 34188 var context = { 34189 $$typeof: REACT_CONTEXT_TYPE, 34190 _calculateChangedBits: calculateChangedBits, 34191 // As a workaround to support multiple concurrent renderers, we categorize 34192 // some renderers as primary and others as secondary. We only expect 34193 // there to be two concurrent renderers at most: React Native (primary) and 34194 // Fabric (secondary); React DOM (primary) and React ART (secondary). 34195 // Secondary renderers store their context values on separate fields. 34196 _currentValue: defaultValue, 34197 _currentValue2: defaultValue, 34198 // Used to track how many concurrent renderers this context currently 34199 // supports within in a single renderer. Such as parallel server rendering. 34200 _threadCount: 0, 34201 // These are circular 34202 Provider: null, 34203 Consumer: null 34204 }; 34205 context.Provider = { 34206 $$typeof: REACT_PROVIDER_TYPE, 34207 _context: context 34208 }; 34209 var hasWarnedAboutUsingNestedContextConsumers = false; 34210 var hasWarnedAboutUsingConsumerProvider = false; 34211 34212 { 34213 // A separate object, but proxies back to the original context object for 34214 // backwards compatibility. It has a different $$typeof, so we can properly 34215 // warn for the incorrect usage of Context as a Consumer. 34216 var Consumer = { 34217 $$typeof: REACT_CONTEXT_TYPE, 34218 _context: context, 34219 _calculateChangedBits: context._calculateChangedBits 34220 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here 34221 34222 Object.defineProperties(Consumer, { 34223 Provider: { 34224 get: function () { 34225 if (!hasWarnedAboutUsingConsumerProvider) { 34226 hasWarnedAboutUsingConsumerProvider = true; 34227 34228 error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); 34229 } 34230 34231 return context.Provider; 34232 }, 34233 set: function (_Provider) { 34234 context.Provider = _Provider; 34235 } 34236 }, 34237 _currentValue: { 34238 get: function () { 34239 return context._currentValue; 34240 }, 34241 set: function (_currentValue) { 34242 context._currentValue = _currentValue; 34243 } 34244 }, 34245 _currentValue2: { 34246 get: function () { 34247 return context._currentValue2; 34248 }, 34249 set: function (_currentValue2) { 34250 context._currentValue2 = _currentValue2; 34251 } 34252 }, 34253 _threadCount: { 34254 get: function () { 34255 return context._threadCount; 34256 }, 34257 set: function (_threadCount) { 34258 context._threadCount = _threadCount; 34259 } 34260 }, 34261 Consumer: { 34262 get: function () { 34263 if (!hasWarnedAboutUsingNestedContextConsumers) { 34264 hasWarnedAboutUsingNestedContextConsumers = true; 34265 34266 error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 34267 } 34268 34269 return context.Consumer; 34270 } 34271 } 34272 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty 34273 34274 context.Consumer = Consumer; 34275 } 34276 34277 { 34278 context._currentRenderer = null; 34279 context._currentRenderer2 = null; 34280 } 34281 34282 return context; 34283} 34284 34285function lazy(ctor) { 34286 var lazyType = { 34287 $$typeof: REACT_LAZY_TYPE, 34288 _ctor: ctor, 34289 // React uses these fields to store the result. 34290 _status: -1, 34291 _result: null 34292 }; 34293 34294 { 34295 // In production, this would just set it on the object. 34296 var defaultProps; 34297 var propTypes; 34298 Object.defineProperties(lazyType, { 34299 defaultProps: { 34300 configurable: true, 34301 get: function () { 34302 return defaultProps; 34303 }, 34304 set: function (newDefaultProps) { 34305 error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 34306 34307 defaultProps = newDefaultProps; // Match production behavior more closely: 34308 34309 Object.defineProperty(lazyType, 'defaultProps', { 34310 enumerable: true 34311 }); 34312 } 34313 }, 34314 propTypes: { 34315 configurable: true, 34316 get: function () { 34317 return propTypes; 34318 }, 34319 set: function (newPropTypes) { 34320 error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 34321 34322 propTypes = newPropTypes; // Match production behavior more closely: 34323 34324 Object.defineProperty(lazyType, 'propTypes', { 34325 enumerable: true 34326 }); 34327 } 34328 } 34329 }); 34330 } 34331 34332 return lazyType; 34333} 34334 34335function forwardRef(render) { 34336 { 34337 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { 34338 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); 34339 } else if (typeof render !== 'function') { 34340 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 34341 } else { 34342 if (render.length !== 0 && render.length !== 2) { 34343 error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.'); 34344 } 34345 } 34346 34347 if (render != null) { 34348 if (render.defaultProps != null || render.propTypes != null) { 34349 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); 34350 } 34351 } 34352 } 34353 34354 return { 34355 $$typeof: REACT_FORWARD_REF_TYPE, 34356 render: render 34357 }; 34358} 34359 34360function isValidElementType(type) { 34361 return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 34362 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); 34363} 34364 34365function memo(type, compare) { 34366 { 34367 if (!isValidElementType(type)) { 34368 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); 34369 } 34370 } 34371 34372 return { 34373 $$typeof: REACT_MEMO_TYPE, 34374 type: type, 34375 compare: compare === undefined ? null : compare 34376 }; 34377} 34378 34379function resolveDispatcher() { 34380 var dispatcher = ReactCurrentDispatcher.current; 34381 34382 if (!(dispatcher !== null)) { 34383 { 34384 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); 34385 } 34386 } 34387 34388 return dispatcher; 34389} 34390 34391function useContext(Context, unstable_observedBits) { 34392 var dispatcher = resolveDispatcher(); 34393 34394 { 34395 if (unstable_observedBits !== undefined) { 34396 error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : ''); 34397 } // TODO: add a more generic warning for invalid values. 34398 34399 34400 if (Context._context !== undefined) { 34401 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs 34402 // and nobody should be using this in existing code. 34403 34404 if (realContext.Consumer === Context) { 34405 error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); 34406 } else if (realContext.Provider === Context) { 34407 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); 34408 } 34409 } 34410 } 34411 34412 return dispatcher.useContext(Context, unstable_observedBits); 34413} 34414function useState(initialState) { 34415 var dispatcher = resolveDispatcher(); 34416 return dispatcher.useState(initialState); 34417} 34418function useReducer(reducer, initialArg, init) { 34419 var dispatcher = resolveDispatcher(); 34420 return dispatcher.useReducer(reducer, initialArg, init); 34421} 34422function useRef(initialValue) { 34423 var dispatcher = resolveDispatcher(); 34424 return dispatcher.useRef(initialValue); 34425} 34426function useEffect(create, deps) { 34427 var dispatcher = resolveDispatcher(); 34428 return dispatcher.useEffect(create, deps); 34429} 34430function useLayoutEffect(create, deps) { 34431 var dispatcher = resolveDispatcher(); 34432 return dispatcher.useLayoutEffect(create, deps); 34433} 34434function useCallback(callback, deps) { 34435 var dispatcher = resolveDispatcher(); 34436 return dispatcher.useCallback(callback, deps); 34437} 34438function useMemo(create, deps) { 34439 var dispatcher = resolveDispatcher(); 34440 return dispatcher.useMemo(create, deps); 34441} 34442function useImperativeHandle(ref, create, deps) { 34443 var dispatcher = resolveDispatcher(); 34444 return dispatcher.useImperativeHandle(ref, create, deps); 34445} 34446function useDebugValue(value, formatterFn) { 34447 { 34448 var dispatcher = resolveDispatcher(); 34449 return dispatcher.useDebugValue(value, formatterFn); 34450 } 34451} 34452 34453var propTypesMisspellWarningShown; 34454 34455{ 34456 propTypesMisspellWarningShown = false; 34457} 34458 34459function getDeclarationErrorAddendum() { 34460 if (ReactCurrentOwner.current) { 34461 var name = getComponentName(ReactCurrentOwner.current.type); 34462 34463 if (name) { 34464 return '\n\nCheck the render method of `' + name + '`.'; 34465 } 34466 } 34467 34468 return ''; 34469} 34470 34471function getSourceInfoErrorAddendum(source) { 34472 if (source !== undefined) { 34473 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 34474 var lineNumber = source.lineNumber; 34475 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 34476 } 34477 34478 return ''; 34479} 34480 34481function getSourceInfoErrorAddendumForProps(elementProps) { 34482 if (elementProps !== null && elementProps !== undefined) { 34483 return getSourceInfoErrorAddendum(elementProps.__source); 34484 } 34485 34486 return ''; 34487} 34488/** 34489 * Warn if there's no key explicitly set on dynamic arrays of children or 34490 * object keys are not valid. This allows us to keep track of children between 34491 * updates. 34492 */ 34493 34494 34495var ownerHasKeyUseWarning = {}; 34496 34497function getCurrentComponentErrorInfo(parentType) { 34498 var info = getDeclarationErrorAddendum(); 34499 34500 if (!info) { 34501 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 34502 34503 if (parentName) { 34504 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 34505 } 34506 } 34507 34508 return info; 34509} 34510/** 34511 * Warn if the element doesn't have an explicit key assigned to it. 34512 * This element is in an array. The array could grow and shrink or be 34513 * reordered. All children that haven't already been validated are required to 34514 * have a "key" property assigned to it. Error statuses are cached so a warning 34515 * will only be shown once. 34516 * 34517 * @internal 34518 * @param {ReactElement} element Element that requires a key. 34519 * @param {*} parentType element's parent's type. 34520 */ 34521 34522 34523function validateExplicitKey(element, parentType) { 34524 if (!element._store || element._store.validated || element.key != null) { 34525 return; 34526 } 34527 34528 element._store.validated = true; 34529 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 34530 34531 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 34532 return; 34533 } 34534 34535 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 34536 // property, it may be the creator of the child that's responsible for 34537 // assigning it a key. 34538 34539 var childOwner = ''; 34540 34541 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 34542 // Give the component that originally created this child. 34543 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 34544 } 34545 34546 setCurrentlyValidatingElement(element); 34547 34548 { 34549 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); 34550 } 34551 34552 setCurrentlyValidatingElement(null); 34553} 34554/** 34555 * Ensure that every element either is passed in a static location, in an 34556 * array with an explicit keys property defined, or in an object literal 34557 * with valid key property. 34558 * 34559 * @internal 34560 * @param {ReactNode} node Statically passed child of any type. 34561 * @param {*} parentType node's parent's type. 34562 */ 34563 34564 34565function validateChildKeys(node, parentType) { 34566 if (typeof node !== 'object') { 34567 return; 34568 } 34569 34570 if (Array.isArray(node)) { 34571 for (var i = 0; i < node.length; i++) { 34572 var child = node[i]; 34573 34574 if (isValidElement(child)) { 34575 validateExplicitKey(child, parentType); 34576 } 34577 } 34578 } else if (isValidElement(node)) { 34579 // This element was passed in a valid location. 34580 if (node._store) { 34581 node._store.validated = true; 34582 } 34583 } else if (node) { 34584 var iteratorFn = getIteratorFn(node); 34585 34586 if (typeof iteratorFn === 'function') { 34587 // Entry iterators used to provide implicit keys, 34588 // but now we print a separate warning for them later. 34589 if (iteratorFn !== node.entries) { 34590 var iterator = iteratorFn.call(node); 34591 var step; 34592 34593 while (!(step = iterator.next()).done) { 34594 if (isValidElement(step.value)) { 34595 validateExplicitKey(step.value, parentType); 34596 } 34597 } 34598 } 34599 } 34600 } 34601} 34602/** 34603 * Given an element, validate that its props follow the propTypes definition, 34604 * provided by the type. 34605 * 34606 * @param {ReactElement} element 34607 */ 34608 34609 34610function validatePropTypes(element) { 34611 { 34612 var type = element.type; 34613 34614 if (type === null || type === undefined || typeof type === 'string') { 34615 return; 34616 } 34617 34618 var name = getComponentName(type); 34619 var propTypes; 34620 34621 if (typeof type === 'function') { 34622 propTypes = type.propTypes; 34623 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 34624 // Inner props are checked in the reconciler. 34625 type.$$typeof === REACT_MEMO_TYPE)) { 34626 propTypes = type.propTypes; 34627 } else { 34628 return; 34629 } 34630 34631 if (propTypes) { 34632 setCurrentlyValidatingElement(element); 34633 checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); 34634 setCurrentlyValidatingElement(null); 34635 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 34636 propTypesMisspellWarningShown = true; 34637 34638 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); 34639 } 34640 34641 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 34642 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 34643 } 34644 } 34645} 34646/** 34647 * Given a fragment, validate that it can only be provided with fragment props 34648 * @param {ReactElement} fragment 34649 */ 34650 34651 34652function validateFragmentProps(fragment) { 34653 { 34654 setCurrentlyValidatingElement(fragment); 34655 var keys = Object.keys(fragment.props); 34656 34657 for (var i = 0; i < keys.length; i++) { 34658 var key = keys[i]; 34659 34660 if (key !== 'children' && key !== 'key') { 34661 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 34662 34663 break; 34664 } 34665 } 34666 34667 if (fragment.ref !== null) { 34668 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 34669 } 34670 34671 setCurrentlyValidatingElement(null); 34672 } 34673} 34674function createElementWithValidation(type, props, children) { 34675 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 34676 // succeed and there will likely be errors in render. 34677 34678 if (!validType) { 34679 var info = ''; 34680 34681 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 34682 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."; 34683 } 34684 34685 var sourceInfo = getSourceInfoErrorAddendumForProps(props); 34686 34687 if (sourceInfo) { 34688 info += sourceInfo; 34689 } else { 34690 info += getDeclarationErrorAddendum(); 34691 } 34692 34693 var typeString; 34694 34695 if (type === null) { 34696 typeString = 'null'; 34697 } else if (Array.isArray(type)) { 34698 typeString = 'array'; 34699 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 34700 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 34701 info = ' Did you accidentally export a JSX literal instead of a component?'; 34702 } else { 34703 typeString = typeof type; 34704 } 34705 34706 { 34707 error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); 34708 } 34709 } 34710 34711 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. 34712 // TODO: Drop this when these are no longer allowed as the type argument. 34713 34714 if (element == null) { 34715 return element; 34716 } // Skip key warning if the type isn't valid since our key validation logic 34717 // doesn't expect a non-string/function type and can throw confusing errors. 34718 // We don't want exception behavior to differ between dev and prod. 34719 // (Rendering will throw with a helpful message and as soon as the type is 34720 // fixed, the key warnings will appear.) 34721 34722 34723 if (validType) { 34724 for (var i = 2; i < arguments.length; i++) { 34725 validateChildKeys(arguments[i], type); 34726 } 34727 } 34728 34729 if (type === REACT_FRAGMENT_TYPE) { 34730 validateFragmentProps(element); 34731 } else { 34732 validatePropTypes(element); 34733 } 34734 34735 return element; 34736} 34737var didWarnAboutDeprecatedCreateFactory = false; 34738function createFactoryWithValidation(type) { 34739 var validatedFactory = createElementWithValidation.bind(null, type); 34740 validatedFactory.type = type; 34741 34742 { 34743 if (!didWarnAboutDeprecatedCreateFactory) { 34744 didWarnAboutDeprecatedCreateFactory = true; 34745 34746 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); 34747 } // Legacy hook: remove it 34748 34749 34750 Object.defineProperty(validatedFactory, 'type', { 34751 enumerable: false, 34752 get: function () { 34753 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 34754 34755 Object.defineProperty(this, 'type', { 34756 value: type 34757 }); 34758 return type; 34759 } 34760 }); 34761 } 34762 34763 return validatedFactory; 34764} 34765function cloneElementWithValidation(element, props, children) { 34766 var newElement = cloneElement.apply(this, arguments); 34767 34768 for (var i = 2; i < arguments.length; i++) { 34769 validateChildKeys(arguments[i], newElement.type); 34770 } 34771 34772 validatePropTypes(newElement); 34773 return newElement; 34774} 34775 34776{ 34777 34778 try { 34779 var frozenObject = Object.freeze({}); 34780 var testMap = new Map([[frozenObject, null]]); 34781 var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused. 34782 // https://github.com/rollup/rollup/issues/1771 34783 // TODO: we can remove these if Rollup fixes the bug. 34784 34785 testMap.set(0, 0); 34786 testSet.add(0); 34787 } catch (e) { 34788 } 34789} 34790 34791var createElement$1 = createElementWithValidation ; 34792var cloneElement$1 = cloneElementWithValidation ; 34793var createFactory = createFactoryWithValidation ; 34794var Children = { 34795 map: mapChildren, 34796 forEach: forEachChildren, 34797 count: countChildren, 34798 toArray: toArray, 34799 only: onlyChild 34800}; 34801 34802exports.Children = Children; 34803exports.Component = Component; 34804exports.Fragment = REACT_FRAGMENT_TYPE; 34805exports.Profiler = REACT_PROFILER_TYPE; 34806exports.PureComponent = PureComponent; 34807exports.StrictMode = REACT_STRICT_MODE_TYPE; 34808exports.Suspense = REACT_SUSPENSE_TYPE; 34809exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; 34810exports.cloneElement = cloneElement$1; 34811exports.createContext = createContext; 34812exports.createElement = createElement$1; 34813exports.createFactory = createFactory; 34814exports.createRef = createRef; 34815exports.forwardRef = forwardRef; 34816exports.isValidElement = isValidElement; 34817exports.lazy = lazy; 34818exports.memo = memo; 34819exports.useCallback = useCallback; 34820exports.useContext = useContext; 34821exports.useDebugValue = useDebugValue; 34822exports.useEffect = useEffect; 34823exports.useImperativeHandle = useImperativeHandle; 34824exports.useLayoutEffect = useLayoutEffect; 34825exports.useMemo = useMemo; 34826exports.useReducer = useReducer; 34827exports.useRef = useRef; 34828exports.useState = useState; 34829exports.version = ReactVersion; 34830 })(); 34831} 34832 34833 34834/***/ }), 34835
vendor: 699 bytes, lines 34836-34852
34836/***/ "../../node_modules/react/index.js": 34837/*!****************************************************************************************************************************!*\ 34838 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/react/index.js ***! 34839 \****************************************************************************************************************************/ 34840/*! no static exports found */ 34841/***/ (function(module, exports, __webpack_require__) { 34842 34843"use strict"; 34844 34845 34846if (false) {} else { 34847 module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "../../node_modules/react/cjs/react.development.js"); 34848} 34849 34850 34851/***/ }), 34852
vendor: 9,632 bytes, lines 34853-35213
34853/***/ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js": 34854/*!************************************************************************************************************************************************************!*\ 34855 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/scheduler/cjs/scheduler-tracing.development.js ***! 34856 \************************************************************************************************************************************************************/ 34857/*! no static exports found */ 34858/***/ (function(module, exports, __webpack_require__) { 34859 34860"use strict"; 34861/** @license React v0.19.1 34862 * scheduler-tracing.development.js 34863 * 34864 * Copyright (c) Facebook, Inc. and its affiliates. 34865 * 34866 * This source code is licensed under the MIT license found in the 34867 * LICENSE file in the root directory of this source tree. 34868 */ 34869 34870 34871 34872 34873 34874if (true) { 34875 (function() { 34876'use strict'; 34877 34878var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. 34879 34880var interactionIDCounter = 0; 34881var threadIDCounter = 0; // Set of currently traced interactions. 34882// Interactions "stack"– 34883// Meaning that newly traced interactions are appended to the previously active set. 34884// When an interaction goes out of scope, the previous set (if any) is restored. 34885 34886exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end. 34887 34888exports.__subscriberRef = null; 34889 34890{ 34891 exports.__interactionsRef = { 34892 current: new Set() 34893 }; 34894 exports.__subscriberRef = { 34895 current: null 34896 }; 34897} 34898function unstable_clear(callback) { 34899 34900 var prevInteractions = exports.__interactionsRef.current; 34901 exports.__interactionsRef.current = new Set(); 34902 34903 try { 34904 return callback(); 34905 } finally { 34906 exports.__interactionsRef.current = prevInteractions; 34907 } 34908} 34909function unstable_getCurrent() { 34910 { 34911 return exports.__interactionsRef.current; 34912 } 34913} 34914function unstable_getThreadID() { 34915 return ++threadIDCounter; 34916} 34917function unstable_trace(name, timestamp, callback) { 34918 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 34919 34920 var interaction = { 34921 __count: 1, 34922 id: interactionIDCounter++, 34923 name: name, 34924 timestamp: timestamp 34925 }; 34926 var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. 34927 // To do that, clone the current interactions. 34928 // The previous set will be restored upon completion. 34929 34930 var interactions = new Set(prevInteractions); 34931 interactions.add(interaction); 34932 exports.__interactionsRef.current = interactions; 34933 var subscriber = exports.__subscriberRef.current; 34934 var returnValue; 34935 34936 try { 34937 if (subscriber !== null) { 34938 subscriber.onInteractionTraced(interaction); 34939 } 34940 } finally { 34941 try { 34942 if (subscriber !== null) { 34943 subscriber.onWorkStarted(interactions, threadID); 34944 } 34945 } finally { 34946 try { 34947 returnValue = callback(); 34948 } finally { 34949 exports.__interactionsRef.current = prevInteractions; 34950 34951 try { 34952 if (subscriber !== null) { 34953 subscriber.onWorkStopped(interactions, threadID); 34954 } 34955 } finally { 34956 interaction.__count--; // If no async work was scheduled for this interaction, 34957 // Notify subscribers that it's completed. 34958 34959 if (subscriber !== null && interaction.__count === 0) { 34960 subscriber.onInteractionScheduledWorkCompleted(interaction); 34961 } 34962 } 34963 } 34964 } 34965 } 34966 34967 return returnValue; 34968} 34969function unstable_wrap(callback) { 34970 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 34971 34972 var wrappedInteractions = exports.__interactionsRef.current; 34973 var subscriber = exports.__subscriberRef.current; 34974 34975 if (subscriber !== null) { 34976 subscriber.onWorkScheduled(wrappedInteractions, threadID); 34977 } // Update the pending async work count for the current interactions. 34978 // Update after calling subscribers in case of error. 34979 34980 34981 wrappedInteractions.forEach(function (interaction) { 34982 interaction.__count++; 34983 }); 34984 var hasRun = false; 34985 34986 function wrapped() { 34987 var prevInteractions = exports.__interactionsRef.current; 34988 exports.__interactionsRef.current = wrappedInteractions; 34989 subscriber = exports.__subscriberRef.current; 34990 34991 try { 34992 var returnValue; 34993 34994 try { 34995 if (subscriber !== null) { 34996 subscriber.onWorkStarted(wrappedInteractions, threadID); 34997 } 34998 } finally { 34999 try { 35000 returnValue = callback.apply(undefined, arguments); 35001 } finally { 35002 exports.__interactionsRef.current = prevInteractions; 35003 35004 if (subscriber !== null) { 35005 subscriber.onWorkStopped(wrappedInteractions, threadID); 35006 } 35007 } 35008 } 35009 35010 return returnValue; 35011 } finally { 35012 if (!hasRun) { 35013 // We only expect a wrapped function to be executed once, 35014 // But in the event that it's executed more than once– 35015 // Only decrement the outstanding interaction counts once. 35016 hasRun = true; // Update pending async counts for all wrapped interactions. 35017 // If this was the last scheduled async work for any of them, 35018 // Mark them as completed. 35019 35020 wrappedInteractions.forEach(function (interaction) { 35021 interaction.__count--; 35022 35023 if (subscriber !== null && interaction.__count === 0) { 35024 subscriber.onInteractionScheduledWorkCompleted(interaction); 35025 } 35026 }); 35027 } 35028 } 35029 } 35030 35031 wrapped.cancel = function cancel() { 35032 subscriber = exports.__subscriberRef.current; 35033 35034 try { 35035 if (subscriber !== null) { 35036 subscriber.onWorkCanceled(wrappedInteractions, threadID); 35037 } 35038 } finally { 35039 // Update pending async counts for all wrapped interactions. 35040 // If this was the last scheduled async work for any of them, 35041 // Mark them as completed. 35042 wrappedInteractions.forEach(function (interaction) { 35043 interaction.__count--; 35044 35045 if (subscriber && interaction.__count === 0) { 35046 subscriber.onInteractionScheduledWorkCompleted(interaction); 35047 } 35048 }); 35049 } 35050 }; 35051 35052 return wrapped; 35053} 35054 35055var subscribers = null; 35056 35057{ 35058 subscribers = new Set(); 35059} 35060 35061function unstable_subscribe(subscriber) { 35062 { 35063 subscribers.add(subscriber); 35064 35065 if (subscribers.size === 1) { 35066 exports.__subscriberRef.current = { 35067 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 35068 onInteractionTraced: onInteractionTraced, 35069 onWorkCanceled: onWorkCanceled, 35070 onWorkScheduled: onWorkScheduled, 35071 onWorkStarted: onWorkStarted, 35072 onWorkStopped: onWorkStopped 35073 }; 35074 } 35075 } 35076} 35077function unstable_unsubscribe(subscriber) { 35078 { 35079 subscribers.delete(subscriber); 35080 35081 if (subscribers.size === 0) { 35082 exports.__subscriberRef.current = null; 35083 } 35084 } 35085} 35086 35087function onInteractionTraced(interaction) { 35088 var didCatchError = false; 35089 var caughtError = null; 35090 subscribers.forEach(function (subscriber) { 35091 try { 35092 subscriber.onInteractionTraced(interaction); 35093 } catch (error) { 35094 if (!didCatchError) { 35095 didCatchError = true; 35096 caughtError = error; 35097 } 35098 } 35099 }); 35100 35101 if (didCatchError) { 35102 throw caughtError; 35103 } 35104} 35105 35106function onInteractionScheduledWorkCompleted(interaction) { 35107 var didCatchError = false; 35108 var caughtError = null; 35109 subscribers.forEach(function (subscriber) { 35110 try { 35111 subscriber.onInteractionScheduledWorkCompleted(interaction); 35112 } catch (error) { 35113 if (!didCatchError) { 35114 didCatchError = true; 35115 caughtError = error; 35116 } 35117 } 35118 }); 35119 35120 if (didCatchError) { 35121 throw caughtError; 35122 } 35123} 35124 35125function onWorkScheduled(interactions, threadID) { 35126 var didCatchError = false; 35127 var caughtError = null; 35128 subscribers.forEach(function (subscriber) { 35129 try { 35130 subscriber.onWorkScheduled(interactions, threadID); 35131 } catch (error) { 35132 if (!didCatchError) { 35133 didCatchError = true; 35134 caughtError = error; 35135 } 35136 } 35137 }); 35138 35139 if (didCatchError) { 35140 throw caughtError; 35141 } 35142} 35143 35144function onWorkStarted(interactions, threadID) { 35145 var didCatchError = false; 35146 var caughtError = null; 35147 subscribers.forEach(function (subscriber) { 35148 try { 35149 subscriber.onWorkStarted(interactions, threadID); 35150 } catch (error) { 35151 if (!didCatchError) { 35152 didCatchError = true; 35153 caughtError = error; 35154 } 35155 } 35156 }); 35157 35158 if (didCatchError) { 35159 throw caughtError; 35160 } 35161} 35162 35163function onWorkStopped(interactions, threadID) { 35164 var didCatchError = false; 35165 var caughtError = null; 35166 subscribers.forEach(function (subscriber) { 35167 try { 35168 subscriber.onWorkStopped(interactions, threadID); 35169 } catch (error) { 35170 if (!didCatchError) { 35171 didCatchError = true; 35172 caughtError = error; 35173 } 35174 } 35175 }); 35176 35177 if (didCatchError) { 35178 throw caughtError; 35179 } 35180} 35181 35182function onWorkCanceled(interactions, threadID) { 35183 var didCatchError = false; 35184 var caughtError = null; 35185 subscribers.forEach(function (subscriber) { 35186 try { 35187 subscriber.onWorkCanceled(interactions, threadID); 35188 } catch (error) { 35189 if (!didCatchError) { 35190 didCatchError = true; 35191 caughtError = error; 35192 } 35193 } 35194 }); 35195 35196 if (didCatchError) { 35197 throw caughtError; 35198 } 35199} 35200 35201exports.unstable_clear = unstable_clear; 35202exports.unstable_getCurrent = unstable_getCurrent; 35203exports.unstable_getThreadID = unstable_getThreadID; 35204exports.unstable_subscribe = unstable_subscribe; 35205exports.unstable_trace = unstable_trace; 35206exports.unstable_unsubscribe = unstable_unsubscribe; 35207exports.unstable_wrap = unstable_wrap; 35208 })(); 35209} 35210 35211 35212/***/ }), 35213
vendor: 24,359 bytes, lines 35214-36083
35214/***/ "../../node_modules/scheduler/cjs/scheduler.development.js": 35215/*!****************************************************************************************************************************************************!*\ 35216 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/scheduler/cjs/scheduler.development.js ***! 35217 \****************************************************************************************************************************************************/ 35218/*! no static exports found */ 35219/***/ (function(module, exports, __webpack_require__) { 35220 35221"use strict"; 35222/** @license React v0.19.1 35223 * scheduler.development.js 35224 * 35225 * Copyright (c) Facebook, Inc. and its affiliates. 35226 * 35227 * This source code is licensed under the MIT license found in the 35228 * LICENSE file in the root directory of this source tree. 35229 */ 35230 35231 35232 35233 35234 35235if (true) { 35236 (function() { 35237'use strict'; 35238 35239var enableSchedulerDebugging = false; 35240var enableProfiling = true; 35241 35242var requestHostCallback; 35243var requestHostTimeout; 35244var cancelHostTimeout; 35245var shouldYieldToHost; 35246var requestPaint; 35247 35248if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive 35249// implementation using setTimeout. 35250typeof window === 'undefined' || // Check if MessageChannel is supported, too. 35251typeof MessageChannel !== 'function') { 35252 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, 35253 // fallback to a naive implementation. 35254 var _callback = null; 35255 var _timeoutID = null; 35256 35257 var _flushCallback = function () { 35258 if (_callback !== null) { 35259 try { 35260 var currentTime = exports.unstable_now(); 35261 var hasRemainingTime = true; 35262 35263 _callback(hasRemainingTime, currentTime); 35264 35265 _callback = null; 35266 } catch (e) { 35267 setTimeout(_flushCallback, 0); 35268 throw e; 35269 } 35270 } 35271 }; 35272 35273 var initialTime = Date.now(); 35274 35275 exports.unstable_now = function () { 35276 return Date.now() - initialTime; 35277 }; 35278 35279 requestHostCallback = function (cb) { 35280 if (_callback !== null) { 35281 // Protect against re-entrancy. 35282 setTimeout(requestHostCallback, 0, cb); 35283 } else { 35284 _callback = cb; 35285 setTimeout(_flushCallback, 0); 35286 } 35287 }; 35288 35289 requestHostTimeout = function (cb, ms) { 35290 _timeoutID = setTimeout(cb, ms); 35291 }; 35292 35293 cancelHostTimeout = function () { 35294 clearTimeout(_timeoutID); 35295 }; 35296 35297 shouldYieldToHost = function () { 35298 return false; 35299 }; 35300 35301 requestPaint = exports.unstable_forceFrameRate = function () {}; 35302} else { 35303 // Capture local references to native APIs, in case a polyfill overrides them. 35304 var performance = window.performance; 35305 var _Date = window.Date; 35306 var _setTimeout = window.setTimeout; 35307 var _clearTimeout = window.clearTimeout; 35308 35309 if (typeof console !== 'undefined') { 35310 // TODO: Scheduler no longer requires these methods to be polyfilled. But 35311 // maybe we want to continue warning if they don't exist, to preserve the 35312 // option to rely on it in the future? 35313 var requestAnimationFrame = window.requestAnimationFrame; 35314 var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link 35315 35316 if (typeof requestAnimationFrame !== 'function') { 35317 // Using console['error'] to evade Babel and ESLint 35318 console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 35319 } 35320 35321 if (typeof cancelAnimationFrame !== 'function') { 35322 // Using console['error'] to evade Babel and ESLint 35323 console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 35324 } 35325 } 35326 35327 if (typeof performance === 'object' && typeof performance.now === 'function') { 35328 exports.unstable_now = function () { 35329 return performance.now(); 35330 }; 35331 } else { 35332 var _initialTime = _Date.now(); 35333 35334 exports.unstable_now = function () { 35335 return _Date.now() - _initialTime; 35336 }; 35337 } 35338 35339 var isMessageLoopRunning = false; 35340 var scheduledHostCallback = null; 35341 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main 35342 // thread, like user events. By default, it yields multiple times per frame. 35343 // It does not attempt to align with frame boundaries, since most tasks don't 35344 // need to be frame aligned; for those that do, use requestAnimationFrame. 35345 35346 var yieldInterval = 5; 35347 var deadline = 0; // TODO: Make this configurable 35348 35349 { 35350 // `isInputPending` is not available. Since we have no way of knowing if 35351 // there's pending input, always yield at the end of the frame. 35352 shouldYieldToHost = function () { 35353 return exports.unstable_now() >= deadline; 35354 }; // Since we yield every frame regardless, `requestPaint` has no effect. 35355 35356 35357 requestPaint = function () {}; 35358 } 35359 35360 exports.unstable_forceFrameRate = function (fps) { 35361 if (fps < 0 || fps > 125) { 35362 // Using console['error'] to evade Babel and ESLint 35363 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported'); 35364 return; 35365 } 35366 35367 if (fps > 0) { 35368 yieldInterval = Math.floor(1000 / fps); 35369 } else { 35370 // reset the framerate 35371 yieldInterval = 5; 35372 } 35373 }; 35374 35375 var performWorkUntilDeadline = function () { 35376 if (scheduledHostCallback !== null) { 35377 var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync 35378 // cycle. This means there's always time remaining at the beginning of 35379 // the message event. 35380 35381 deadline = currentTime + yieldInterval; 35382 var hasTimeRemaining = true; 35383 35384 try { 35385 var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); 35386 35387 if (!hasMoreWork) { 35388 isMessageLoopRunning = false; 35389 scheduledHostCallback = null; 35390 } else { 35391 // If there's more work, schedule the next message event at the end 35392 // of the preceding one. 35393 port.postMessage(null); 35394 } 35395 } catch (error) { 35396 // If a scheduler task throws, exit the current browser task so the 35397 // error can be observed. 35398 port.postMessage(null); 35399 throw error; 35400 } 35401 } else { 35402 isMessageLoopRunning = false; 35403 } // Yielding to the browser will give it a chance to paint, so we can 35404 }; 35405 35406 var channel = new MessageChannel(); 35407 var port = channel.port2; 35408 channel.port1.onmessage = performWorkUntilDeadline; 35409 35410 requestHostCallback = function (callback) { 35411 scheduledHostCallback = callback; 35412 35413 if (!isMessageLoopRunning) { 35414 isMessageLoopRunning = true; 35415 port.postMessage(null); 35416 } 35417 }; 35418 35419 requestHostTimeout = function (callback, ms) { 35420 taskTimeoutID = _setTimeout(function () { 35421 callback(exports.unstable_now()); 35422 }, ms); 35423 }; 35424 35425 cancelHostTimeout = function () { 35426 _clearTimeout(taskTimeoutID); 35427 35428 taskTimeoutID = -1; 35429 }; 35430} 35431 35432function push(heap, node) { 35433 var index = heap.length; 35434 heap.push(node); 35435 siftUp(heap, node, index); 35436} 35437function peek(heap) { 35438 var first = heap[0]; 35439 return first === undefined ? null : first; 35440} 35441function pop(heap) { 35442 var first = heap[0]; 35443 35444 if (first !== undefined) { 35445 var last = heap.pop(); 35446 35447 if (last !== first) { 35448 heap[0] = last; 35449 siftDown(heap, last, 0); 35450 } 35451 35452 return first; 35453 } else { 35454 return null; 35455 } 35456} 35457 35458function siftUp(heap, node, i) { 35459 var index = i; 35460 35461 while (true) { 35462 var parentIndex = index - 1 >>> 1; 35463 var parent = heap[parentIndex]; 35464 35465 if (parent !== undefined && compare(parent, node) > 0) { 35466 // The parent is larger. Swap positions. 35467 heap[parentIndex] = node; 35468 heap[index] = parent; 35469 index = parentIndex; 35470 } else { 35471 // The parent is smaller. Exit. 35472 return; 35473 } 35474 } 35475} 35476 35477function siftDown(heap, node, i) { 35478 var index = i; 35479 var length = heap.length; 35480 35481 while (index < length) { 35482 var leftIndex = (index + 1) * 2 - 1; 35483 var left = heap[leftIndex]; 35484 var rightIndex = leftIndex + 1; 35485 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. 35486 35487 if (left !== undefined && compare(left, node) < 0) { 35488 if (right !== undefined && compare(right, left) < 0) { 35489 heap[index] = right; 35490 heap[rightIndex] = node; 35491 index = rightIndex; 35492 } else { 35493 heap[index] = left; 35494 heap[leftIndex] = node; 35495 index = leftIndex; 35496 } 35497 } else if (right !== undefined && compare(right, node) < 0) { 35498 heap[index] = right; 35499 heap[rightIndex] = node; 35500 index = rightIndex; 35501 } else { 35502 // Neither child is smaller. Exit. 35503 return; 35504 } 35505 } 35506} 35507 35508function compare(a, b) { 35509 // Compare sort index first, then task id. 35510 var diff = a.sortIndex - b.sortIndex; 35511 return diff !== 0 ? diff : a.id - b.id; 35512} 35513 35514// TODO: Use symbols? 35515var NoPriority = 0; 35516var ImmediatePriority = 1; 35517var UserBlockingPriority = 2; 35518var NormalPriority = 3; 35519var LowPriority = 4; 35520var IdlePriority = 5; 35521 35522var runIdCounter = 0; 35523var mainThreadIdCounter = 0; 35524var profilingStateSize = 4; 35525var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer 35526typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer 35527typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 35528; 35529var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks 35530 35531var PRIORITY = 0; 35532var CURRENT_TASK_ID = 1; 35533var CURRENT_RUN_ID = 2; 35534var QUEUE_SIZE = 3; 35535 35536{ 35537 profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue 35538 // array might include canceled tasks. 35539 35540 profilingState[QUEUE_SIZE] = 0; 35541 profilingState[CURRENT_TASK_ID] = 0; 35542} // Bytes per element is 4 35543 35544 35545var INITIAL_EVENT_LOG_SIZE = 131072; 35546var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes 35547 35548var eventLogSize = 0; 35549var eventLogBuffer = null; 35550var eventLog = null; 35551var eventLogIndex = 0; 35552var TaskStartEvent = 1; 35553var TaskCompleteEvent = 2; 35554var TaskErrorEvent = 3; 35555var TaskCancelEvent = 4; 35556var TaskRunEvent = 5; 35557var TaskYieldEvent = 6; 35558var SchedulerSuspendEvent = 7; 35559var SchedulerResumeEvent = 8; 35560 35561function logEvent(entries) { 35562 if (eventLog !== null) { 35563 var offset = eventLogIndex; 35564 eventLogIndex += entries.length; 35565 35566 if (eventLogIndex + 1 > eventLogSize) { 35567 eventLogSize *= 2; 35568 35569 if (eventLogSize > MAX_EVENT_LOG_SIZE) { 35570 // Using console['error'] to evade Babel and ESLint 35571 console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); 35572 stopLoggingProfilingEvents(); 35573 return; 35574 } 35575 35576 var newEventLog = new Int32Array(eventLogSize * 4); 35577 newEventLog.set(eventLog); 35578 eventLogBuffer = newEventLog.buffer; 35579 eventLog = newEventLog; 35580 } 35581 35582 eventLog.set(entries, offset); 35583 } 35584} 35585 35586function startLoggingProfilingEvents() { 35587 eventLogSize = INITIAL_EVENT_LOG_SIZE; 35588 eventLogBuffer = new ArrayBuffer(eventLogSize * 4); 35589 eventLog = new Int32Array(eventLogBuffer); 35590 eventLogIndex = 0; 35591} 35592function stopLoggingProfilingEvents() { 35593 var buffer = eventLogBuffer; 35594 eventLogSize = 0; 35595 eventLogBuffer = null; 35596 eventLog = null; 35597 eventLogIndex = 0; 35598 return buffer; 35599} 35600function markTaskStart(task, ms) { 35601 { 35602 profilingState[QUEUE_SIZE]++; 35603 35604 if (eventLog !== null) { 35605 // performance.now returns a float, representing milliseconds. When the 35606 // event is logged, it's coerced to an int. Convert to microseconds to 35607 // maintain extra degrees of precision. 35608 logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); 35609 } 35610 } 35611} 35612function markTaskCompleted(task, ms) { 35613 { 35614 profilingState[PRIORITY] = NoPriority; 35615 profilingState[CURRENT_TASK_ID] = 0; 35616 profilingState[QUEUE_SIZE]--; 35617 35618 if (eventLog !== null) { 35619 logEvent([TaskCompleteEvent, ms * 1000, task.id]); 35620 } 35621 } 35622} 35623function markTaskCanceled(task, ms) { 35624 { 35625 profilingState[QUEUE_SIZE]--; 35626 35627 if (eventLog !== null) { 35628 logEvent([TaskCancelEvent, ms * 1000, task.id]); 35629 } 35630 } 35631} 35632function markTaskErrored(task, ms) { 35633 { 35634 profilingState[PRIORITY] = NoPriority; 35635 profilingState[CURRENT_TASK_ID] = 0; 35636 profilingState[QUEUE_SIZE]--; 35637 35638 if (eventLog !== null) { 35639 logEvent([TaskErrorEvent, ms * 1000, task.id]); 35640 } 35641 } 35642} 35643function markTaskRun(task, ms) { 35644 { 35645 runIdCounter++; 35646 profilingState[PRIORITY] = task.priorityLevel; 35647 profilingState[CURRENT_TASK_ID] = task.id; 35648 profilingState[CURRENT_RUN_ID] = runIdCounter; 35649 35650 if (eventLog !== null) { 35651 logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); 35652 } 35653 } 35654} 35655function markTaskYield(task, ms) { 35656 { 35657 profilingState[PRIORITY] = NoPriority; 35658 profilingState[CURRENT_TASK_ID] = 0; 35659 profilingState[CURRENT_RUN_ID] = 0; 35660 35661 if (eventLog !== null) { 35662 logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); 35663 } 35664 } 35665} 35666function markSchedulerSuspended(ms) { 35667 { 35668 mainThreadIdCounter++; 35669 35670 if (eventLog !== null) { 35671 logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); 35672 } 35673 } 35674} 35675function markSchedulerUnsuspended(ms) { 35676 { 35677 if (eventLog !== null) { 35678 logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); 35679 } 35680 } 35681} 35682 35683/* eslint-disable no-var */ 35684// Math.pow(2, 30) - 1 35685// 0b111111111111111111111111111111 35686 35687var maxSigned31BitInt = 1073741823; // Times out immediately 35688 35689var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out 35690 35691var USER_BLOCKING_PRIORITY = 250; 35692var NORMAL_PRIORITY_TIMEOUT = 5000; 35693var LOW_PRIORITY_TIMEOUT = 10000; // Never times out 35694 35695var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap 35696 35697var taskQueue = []; 35698var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. 35699 35700var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. 35701var currentTask = null; 35702var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. 35703 35704var isPerformingWork = false; 35705var isHostCallbackScheduled = false; 35706var isHostTimeoutScheduled = false; 35707 35708function advanceTimers(currentTime) { 35709 // Check for tasks that are no longer delayed and add them to the queue. 35710 var timer = peek(timerQueue); 35711 35712 while (timer !== null) { 35713 if (timer.callback === null) { 35714 // Timer was cancelled. 35715 pop(timerQueue); 35716 } else if (timer.startTime <= currentTime) { 35717 // Timer fired. Transfer to the task queue. 35718 pop(timerQueue); 35719 timer.sortIndex = timer.expirationTime; 35720 push(taskQueue, timer); 35721 35722 { 35723 markTaskStart(timer, currentTime); 35724 timer.isQueued = true; 35725 } 35726 } else { 35727 // Remaining timers are pending. 35728 return; 35729 } 35730 35731 timer = peek(timerQueue); 35732 } 35733} 35734 35735function handleTimeout(currentTime) { 35736 isHostTimeoutScheduled = false; 35737 advanceTimers(currentTime); 35738 35739 if (!isHostCallbackScheduled) { 35740 if (peek(taskQueue) !== null) { 35741 isHostCallbackScheduled = true; 35742 requestHostCallback(flushWork); 35743 } else { 35744 var firstTimer = peek(timerQueue); 35745 35746 if (firstTimer !== null) { 35747 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 35748 } 35749 } 35750 } 35751} 35752 35753function flushWork(hasTimeRemaining, initialTime) { 35754 { 35755 markSchedulerUnsuspended(initialTime); 35756 } // We'll need a host callback the next time work is scheduled. 35757 35758 35759 isHostCallbackScheduled = false; 35760 35761 if (isHostTimeoutScheduled) { 35762 // We scheduled a timeout but it's no longer needed. Cancel it. 35763 isHostTimeoutScheduled = false; 35764 cancelHostTimeout(); 35765 } 35766 35767 isPerformingWork = true; 35768 var previousPriorityLevel = currentPriorityLevel; 35769 35770 try { 35771 if (enableProfiling) { 35772 try { 35773 return workLoop(hasTimeRemaining, initialTime); 35774 } catch (error) { 35775 if (currentTask !== null) { 35776 var currentTime = exports.unstable_now(); 35777 markTaskErrored(currentTask, currentTime); 35778 currentTask.isQueued = false; 35779 } 35780 35781 throw error; 35782 } 35783 } else { 35784 // No catch in prod codepath. 35785 return workLoop(hasTimeRemaining, initialTime); 35786 } 35787 } finally { 35788 currentTask = null; 35789 currentPriorityLevel = previousPriorityLevel; 35790 isPerformingWork = false; 35791 35792 { 35793 var _currentTime = exports.unstable_now(); 35794 35795 markSchedulerSuspended(_currentTime); 35796 } 35797 } 35798} 35799 35800function workLoop(hasTimeRemaining, initialTime) { 35801 var currentTime = initialTime; 35802 advanceTimers(currentTime); 35803 currentTask = peek(taskQueue); 35804 35805 while (currentTask !== null && !(enableSchedulerDebugging )) { 35806 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { 35807 // This currentTask hasn't expired, and we've reached the deadline. 35808 break; 35809 } 35810 35811 var callback = currentTask.callback; 35812 35813 if (callback !== null) { 35814 currentTask.callback = null; 35815 currentPriorityLevel = currentTask.priorityLevel; 35816 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; 35817 markTaskRun(currentTask, currentTime); 35818 var continuationCallback = callback(didUserCallbackTimeout); 35819 currentTime = exports.unstable_now(); 35820 35821 if (typeof continuationCallback === 'function') { 35822 currentTask.callback = continuationCallback; 35823 markTaskYield(currentTask, currentTime); 35824 } else { 35825 { 35826 markTaskCompleted(currentTask, currentTime); 35827 currentTask.isQueued = false; 35828 } 35829 35830 if (currentTask === peek(taskQueue)) { 35831 pop(taskQueue); 35832 } 35833 } 35834 35835 advanceTimers(currentTime); 35836 } else { 35837 pop(taskQueue); 35838 } 35839 35840 currentTask = peek(taskQueue); 35841 } // Return whether there's additional work 35842 35843 35844 if (currentTask !== null) { 35845 return true; 35846 } else { 35847 var firstTimer = peek(timerQueue); 35848 35849 if (firstTimer !== null) { 35850 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 35851 } 35852 35853 return false; 35854 } 35855} 35856 35857function unstable_runWithPriority(priorityLevel, eventHandler) { 35858 switch (priorityLevel) { 35859 case ImmediatePriority: 35860 case UserBlockingPriority: 35861 case NormalPriority: 35862 case LowPriority: 35863 case IdlePriority: 35864 break; 35865 35866 default: 35867 priorityLevel = NormalPriority; 35868 } 35869 35870 var previousPriorityLevel = currentPriorityLevel; 35871 currentPriorityLevel = priorityLevel; 35872 35873 try { 35874 return eventHandler(); 35875 } finally { 35876 currentPriorityLevel = previousPriorityLevel; 35877 } 35878} 35879 35880function unstable_next(eventHandler) { 35881 var priorityLevel; 35882 35883 switch (currentPriorityLevel) { 35884 case ImmediatePriority: 35885 case UserBlockingPriority: 35886 case NormalPriority: 35887 // Shift down to normal priority 35888 priorityLevel = NormalPriority; 35889 break; 35890 35891 default: 35892 // Anything lower than normal priority should remain at the current level. 35893 priorityLevel = currentPriorityLevel; 35894 break; 35895 } 35896 35897 var previousPriorityLevel = currentPriorityLevel; 35898 currentPriorityLevel = priorityLevel; 35899 35900 try { 35901 return eventHandler(); 35902 } finally { 35903 currentPriorityLevel = previousPriorityLevel; 35904 } 35905} 35906 35907function unstable_wrapCallback(callback) { 35908 var parentPriorityLevel = currentPriorityLevel; 35909 return function () { 35910 // This is a fork of runWithPriority, inlined for performance. 35911 var previousPriorityLevel = currentPriorityLevel; 35912 currentPriorityLevel = parentPriorityLevel; 35913 35914 try { 35915 return callback.apply(this, arguments); 35916 } finally { 35917 currentPriorityLevel = previousPriorityLevel; 35918 } 35919 }; 35920} 35921 35922function timeoutForPriorityLevel(priorityLevel) { 35923 switch (priorityLevel) { 35924 case ImmediatePriority: 35925 return IMMEDIATE_PRIORITY_TIMEOUT; 35926 35927 case UserBlockingPriority: 35928 return USER_BLOCKING_PRIORITY; 35929 35930 case IdlePriority: 35931 return IDLE_PRIORITY; 35932 35933 case LowPriority: 35934 return LOW_PRIORITY_TIMEOUT; 35935 35936 case NormalPriority: 35937 default: 35938 return NORMAL_PRIORITY_TIMEOUT; 35939 } 35940} 35941 35942function unstable_scheduleCallback(priorityLevel, callback, options) { 35943 var currentTime = exports.unstable_now(); 35944 var startTime; 35945 var timeout; 35946 35947 if (typeof options === 'object' && options !== null) { 35948 var delay = options.delay; 35949 35950 if (typeof delay === 'number' && delay > 0) { 35951 startTime = currentTime + delay; 35952 } else { 35953 startTime = currentTime; 35954 } 35955 35956 timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); 35957 } else { 35958 timeout = timeoutForPriorityLevel(priorityLevel); 35959 startTime = currentTime; 35960 } 35961 35962 var expirationTime = startTime + timeout; 35963 var newTask = { 35964 id: taskIdCounter++, 35965 callback: callback, 35966 priorityLevel: priorityLevel, 35967 startTime: startTime, 35968 expirationTime: expirationTime, 35969 sortIndex: -1 35970 }; 35971 35972 { 35973 newTask.isQueued = false; 35974 } 35975 35976 if (startTime > currentTime) { 35977 // This is a delayed task. 35978 newTask.sortIndex = startTime; 35979 push(timerQueue, newTask); 35980 35981 if (peek(taskQueue) === null && newTask === peek(timerQueue)) { 35982 // All tasks are delayed, and this is the task with the earliest delay. 35983 if (isHostTimeoutScheduled) { 35984 // Cancel an existing timeout. 35985 cancelHostTimeout(); 35986 } else { 35987 isHostTimeoutScheduled = true; 35988 } // Schedule a timeout. 35989 35990 35991 requestHostTimeout(handleTimeout, startTime - currentTime); 35992 } 35993 } else { 35994 newTask.sortIndex = expirationTime; 35995 push(taskQueue, newTask); 35996 35997 { 35998 markTaskStart(newTask, currentTime); 35999 newTask.isQueued = true; 36000 } // Schedule a host callback, if needed. If we're already performing work, 36001 // wait until the next time we yield. 36002 36003 36004 if (!isHostCallbackScheduled && !isPerformingWork) { 36005 isHostCallbackScheduled = true; 36006 requestHostCallback(flushWork); 36007 } 36008 } 36009 36010 return newTask; 36011} 36012 36013function unstable_pauseExecution() { 36014} 36015 36016function unstable_continueExecution() { 36017 36018 if (!isHostCallbackScheduled && !isPerformingWork) { 36019 isHostCallbackScheduled = true; 36020 requestHostCallback(flushWork); 36021 } 36022} 36023 36024function unstable_getFirstCallbackNode() { 36025 return peek(taskQueue); 36026} 36027 36028function unstable_cancelCallback(task) { 36029 { 36030 if (task.isQueued) { 36031 var currentTime = exports.unstable_now(); 36032 markTaskCanceled(task, currentTime); 36033 task.isQueued = false; 36034 } 36035 } // Null out the callback to indicate the task has been canceled. (Can't 36036 // remove from the queue because you can't remove arbitrary nodes from an 36037 // array based heap, only the first one.) 36038 36039 36040 task.callback = null; 36041} 36042 36043function unstable_getCurrentPriorityLevel() { 36044 return currentPriorityLevel; 36045} 36046 36047function unstable_shouldYield() { 36048 var currentTime = exports.unstable_now(); 36049 advanceTimers(currentTime); 36050 var firstTask = peek(taskQueue); 36051 return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); 36052} 36053 36054var unstable_requestPaint = requestPaint; 36055var unstable_Profiling = { 36056 startLoggingProfilingEvents: startLoggingProfilingEvents, 36057 stopLoggingProfilingEvents: stopLoggingProfilingEvents, 36058 sharedProfilingBuffer: sharedProfilingBuffer 36059} ; 36060 36061exports.unstable_IdlePriority = IdlePriority; 36062exports.unstable_ImmediatePriority = ImmediatePriority; 36063exports.unstable_LowPriority = LowPriority; 36064exports.unstable_NormalPriority = NormalPriority; 36065exports.unstable_Profiling = unstable_Profiling; 36066exports.unstable_UserBlockingPriority = UserBlockingPriority; 36067exports.unstable_cancelCallback = unstable_cancelCallback; 36068exports.unstable_continueExecution = unstable_continueExecution; 36069exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; 36070exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; 36071exports.unstable_next = unstable_next; 36072exports.unstable_pauseExecution = unstable_pauseExecution; 36073exports.unstable_requestPaint = unstable_requestPaint; 36074exports.unstable_runWithPriority = unstable_runWithPriority; 36075exports.unstable_scheduleCallback = unstable_scheduleCallback; 36076exports.unstable_shouldYield = unstable_shouldYield; 36077exports.unstable_wrapCallback = unstable_wrapCallback; 36078 })(); 36079} 36080 36081 36082/***/ }), 36083
vendor: 727 bytes, lines 36084-36100
36084/***/ "../../node_modules/scheduler/index.js": 36085/*!********************************************************************************************************************************!*\ 36086 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/scheduler/index.js ***! 36087 \********************************************************************************************************************************/ 36088/*! no static exports found */ 36089/***/ (function(module, exports, __webpack_require__) { 36090 36091"use strict"; 36092 36093 36094if (false) {} else { 36095 module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "../../node_modules/scheduler/cjs/scheduler.development.js"); 36096} 36097 36098 36099/***/ }), 36100
vendor: 751 bytes, lines 36101-36117
36101/***/ "../../node_modules/scheduler/tracing.js": 36102/*!**********************************************************************************************************************************!*\ 36103 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/scheduler/tracing.js ***! 36104 \**********************************************************************************************************************************/ 36105/*! no static exports found */ 36106/***/ (function(module, exports, __webpack_require__) { 36107 36108"use strict"; 36109 36110 36111if (false) {} else { 36112 module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js"); 36113} 36114 36115 36116/***/ }), 36117
vendor: 4,900 bytes, lines 36118-36170
36118/***/ "../../node_modules/superagent/lib/agent-base.js": 36119/*!******************************************************************************************************************************************!*\ 36120 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/agent-base.js ***! 36121 \******************************************************************************************************************************************/ 36122/*! no static exports found */ 36123/***/ (function(module, exports, __webpack_require__) { 36124 36125"use strict"; 36126 36127 36128function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } 36129 36130function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 36131 36132function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 36133 36134function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } 36135 36136function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 36137 36138function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 36139 36140function Agent() { 36141 this._defaults = []; 36142} 36143 36144['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts'].forEach(function (fn) { 36145 // Default setting for all requests from this agent 36146 Agent.prototype[fn] = function () { 36147 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 36148 args[_key] = arguments[_key]; 36149 } 36150 36151 this._defaults.push({ 36152 fn: fn, 36153 args: args 36154 }); 36155 36156 return this; 36157 }; 36158}); 36159 36160Agent.prototype._setDefaults = function (req) { 36161 this._defaults.forEach(function (def) { 36162 req[def.fn].apply(req, _toConsumableArray(def.args)); 36163 }); 36164}; 36165 36166module.exports = Agent; 36167//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9hZ2VudC1iYXNlLmpzIl0sIm5hbWVzIjpbIkFnZW50IiwiX2RlZmF1bHRzIiwiZm9yRWFjaCIsImZuIiwicHJvdG90eXBlIiwiYXJncyIsInB1c2giLCJfc2V0RGVmYXVsdHMiLCJyZXEiLCJkZWYiLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7OztBQUFBLFNBQVNBLEtBQVQsR0FBaUI7QUFDZixPQUFLQyxTQUFMLEdBQWlCLEVBQWpCO0FBQ0Q7O0FBRUQsQ0FDRSxLQURGLEVBRUUsSUFGRixFQUdFLE1BSEYsRUFJRSxLQUpGLEVBS0UsT0FMRixFQU1FLE1BTkYsRUFPRSxRQVBGLEVBUUUsTUFSRixFQVNFLGlCQVRGLEVBVUUsV0FWRixFQVdFLE9BWEYsRUFZRSxJQVpGLEVBYUUsV0FiRixFQWNFLFNBZEYsRUFlRSxRQWZGLEVBZ0JFLFdBaEJGLEVBaUJFLE9BakJGLEVBa0JFLElBbEJGLEVBbUJFLEtBbkJGLEVBb0JFLEtBcEJGLEVBcUJFLE1BckJGLEVBc0JFLGlCQXRCRixFQXVCRUMsT0F2QkYsQ0F1QlUsVUFBQUMsRUFBRSxFQUFJO0FBQ2Q7QUFDQUgs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Rpc2FibGVUTFNDZXJ0cydcbl0uZm9yRWFjaChmbiA9PiB7XG4gIC8vIERlZmF1bHQgc2V0dGluZyBmb3IgYWxsIHJlcXVlc3RzIGZyb20gdGhpcyBhZ2VudFxuICBBZ2VudC5wcm90b3R5cGVbZm5dID0gZnVuY3Rpb24oLi4uYXJncykge1xuICAgIHRoaXMuX2RlZmF1bHRzLnB1c2goeyBmbiwgYXJncyB9KTtcbiAgICByZXR1cm4gdGhpcztcbiAgfTtcbn0pO1xuXG5BZ2VudC5wcm90b3R5cGUuX3NldERlZmF1bHRzID0gZnVuY3Rpb24ocmVxKSB7XG4gIHRoaXMuX2RlZmF1bHRzLmZvckVhY2goZGVmID0+IHtcbiAgICByZXFbZGVmLmZuXSguLi5kZWYuYXJncyk7XG4gIH0pO1xufTtcblxubW9kdWxlLmV4cG9ydHMgPSBBZ2VudDtcbiJdfQ== 36168 36169/***/ }), 36170
vendor: 85,516 bytes, lines 36171-37201
36171/***/ "../../node_modules/superagent/lib/client.js": 36172/*!**************************************************************************************************************************************!*\ 36173 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/client.js ***! 36174 \**************************************************************************************************************************************/ 36175/*! no static exports found */ 36176/***/ (function(module, exports, __webpack_require__) { 36177 36178"use strict"; 36179 36180 36181function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 36182 36183/** 36184 * Root reference for iframes. 36185 */ 36186var root; 36187 36188if (typeof window !== 'undefined') { 36189 // Browser window 36190 root = window; 36191} else if (typeof self === 'undefined') { 36192 // Other environments 36193 console.warn('Using browser-only version of superagent in non-browser environment'); 36194 root = void 0; 36195} else { 36196 // Web Worker 36197 root = self; 36198} 36199 36200var Emitter = __webpack_require__(/*! component-emitter */ "../../node_modules/component-emitter/index.js"); 36201 36202var safeStringify = __webpack_require__(/*! fast-safe-stringify */ "../../node_modules/fast-safe-stringify/index.js"); 36203 36204var RequestBase = __webpack_require__(/*! ./request-base */ "../../node_modules/superagent/lib/request-base.js"); 36205 36206var isObject = __webpack_require__(/*! ./is-object */ "../../node_modules/superagent/lib/is-object.js"); 36207 36208var ResponseBase = __webpack_require__(/*! ./response-base */ "../../node_modules/superagent/lib/response-base.js"); 36209 36210var Agent = __webpack_require__(/*! ./agent-base */ "../../node_modules/superagent/lib/agent-base.js"); 36211/** 36212 * Noop. 36213 */ 36214 36215 36216function noop() {} 36217/** 36218 * Expose `request`. 36219 */ 36220 36221 36222module.exports = function (method, url) { 36223 // callback 36224 if (typeof url === 'function') { 36225 return new exports.Request('GET', method).end(url); 36226 } // url first 36227 36228 36229 if (arguments.length === 1) { 36230 return new exports.Request('GET', method); 36231 } 36232 36233 return new exports.Request(method, url); 36234}; 36235 36236exports = module.exports; 36237var request = exports; 36238exports.Request = Request; 36239/** 36240 * Determine XHR. 36241 */ 36242 36243request.getXHR = function () { 36244 if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) { 36245 return new XMLHttpRequest(); 36246 } 36247 36248 try { 36249 return new ActiveXObject('Microsoft.XMLHTTP'); 36250 } catch (_unused) {} 36251 36252 try { 36253 return new ActiveXObject('Msxml2.XMLHTTP.6.0'); 36254 } catch (_unused2) {} 36255 36256 try { 36257 return new ActiveXObject('Msxml2.XMLHTTP.3.0'); 36258 } catch (_unused3) {} 36259 36260 try { 36261 return new ActiveXObject('Msxml2.XMLHTTP'); 36262 } catch (_unused4) {} 36263 36264 throw new Error('Browser-only version of superagent could not find XHR'); 36265}; 36266/** 36267 * Removes leading and trailing whitespace, added to support IE. 36268 * 36269 * @param {String} s 36270 * @return {String} 36271 * @api private 36272 */ 36273 36274 36275var trim = ''.trim ? function (s) { 36276 return s.trim(); 36277} : function (s) { 36278 return s.replace(/(^\s*|\s*$)/g, ''); 36279}; 36280/** 36281 * Serialize the given `obj`. 36282 * 36283 * @param {Object} obj 36284 * @return {String} 36285 * @api private 36286 */ 36287 36288function serialize(obj) { 36289 if (!isObject(obj)) return obj; 36290 var pairs = []; 36291 36292 for (var key in obj) { 36293 if (Object.prototype.hasOwnProperty.call(obj, key)) pushEncodedKeyValuePair(pairs, key, obj[key]); 36294 } 36295 36296 return pairs.join('&'); 36297} 36298/** 36299 * Helps 'serialize' with serializing arrays. 36300 * Mutates the pairs array. 36301 * 36302 * @param {Array} pairs 36303 * @param {String} key 36304 * @param {Mixed} val 36305 */ 36306 36307 36308function pushEncodedKeyValuePair(pairs, key, val) { 36309 if (val === undefined) return; 36310 36311 if (val === null) { 36312 pairs.push(encodeURI(key)); 36313 return; 36314 } 36315 36316 if (Array.isArray(val)) { 36317 val.forEach(function (v) { 36318 pushEncodedKeyValuePair(pairs, key, v); 36319 }); 36320 } else if (isObject(val)) { 36321 for (var subkey in val) { 36322 if (Object.prototype.hasOwnProperty.call(val, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), val[subkey]); 36323 } 36324 } else { 36325 pairs.push(encodeURI(key) + '=' + encodeURIComponent(val)); 36326 } 36327} 36328/** 36329 * Expose serialization method. 36330 */ 36331 36332 36333request.serializeObject = serialize; 36334/** 36335 * Parse the given x-www-form-urlencoded `str`. 36336 * 36337 * @param {String} str 36338 * @return {Object} 36339 * @api private 36340 */ 36341 36342function parseString(str) { 36343 var obj = {}; 36344 var pairs = str.split('&'); 36345 var pair; 36346 var pos; 36347 36348 for (var i = 0, len = pairs.length; i < len; ++i) { 36349 pair = pairs[i]; 36350 pos = pair.indexOf('='); 36351 36352 if (pos === -1) { 36353 obj[decodeURIComponent(pair)] = ''; 36354 } else { 36355 obj[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1)); 36356 } 36357 } 36358 36359 return obj; 36360} 36361/** 36362 * Expose parser. 36363 */ 36364 36365 36366request.parseString = parseString; 36367/** 36368 * Default MIME type map. 36369 * 36370 * superagent.types.xml = 'application/xml'; 36371 * 36372 */ 36373 36374request.types = { 36375 html: 'text/html', 36376 json: 'application/json', 36377 xml: 'text/xml', 36378 urlencoded: 'application/x-www-form-urlencoded', 36379 form: 'application/x-www-form-urlencoded', 36380 'form-data': 'application/x-www-form-urlencoded' 36381}; 36382/** 36383 * Default serialization map. 36384 * 36385 * superagent.serialize['application/xml'] = function(obj){ 36386 * return 'generated xml here'; 36387 * }; 36388 * 36389 */ 36390 36391request.serialize = { 36392 'application/x-www-form-urlencoded': serialize, 36393 'application/json': safeStringify 36394}; 36395/** 36396 * Default parsers. 36397 * 36398 * superagent.parse['application/xml'] = function(str){ 36399 * return { object parsed from str }; 36400 * }; 36401 * 36402 */ 36403 36404request.parse = { 36405 'application/x-www-form-urlencoded': parseString, 36406 'application/json': JSON.parse 36407}; 36408/** 36409 * Parse the given header `str` into 36410 * an object containing the mapped fields. 36411 * 36412 * @param {String} str 36413 * @return {Object} 36414 * @api private 36415 */ 36416 36417function parseHeader(str) { 36418 var lines = str.split(/\r?\n/); 36419 var fields = {}; 36420 var index; 36421 var line; 36422 var field; 36423 var val; 36424 36425 for (var i = 0, len = lines.length; i < len; ++i) { 36426 line = lines[i]; 36427 index = line.indexOf(':'); 36428 36429 if (index === -1) { 36430 // could be empty line, just skip it 36431 continue; 36432 } 36433 36434 field = line.slice(0, index).toLowerCase(); 36435 val = trim(line.slice(index + 1)); 36436 fields[field] = val; 36437 } 36438 36439 return fields; 36440} 36441/** 36442 * Check if `mime` is json or has +json structured syntax suffix. 36443 * 36444 * @param {String} mime 36445 * @return {Boolean} 36446 * @api private 36447 */ 36448 36449 36450function isJSON(mime) { 36451 // should match /json or +json 36452 // but not /json-seq 36453 return /[/+]json($|[^-\w])/.test(mime); 36454} 36455/** 36456 * Initialize a new `Response` with the given `xhr`. 36457 * 36458 * - set flags (.ok, .error, etc) 36459 * - parse header 36460 * 36461 * Examples: 36462 * 36463 * Aliasing `superagent` as `request` is nice: 36464 * 36465 * request = superagent; 36466 * 36467 * We can use the promise-like API, or pass callbacks: 36468 * 36469 * request.get('/').end(function(res){}); 36470 * request.get('/', function(res){}); 36471 * 36472 * Sending data can be chained: 36473 * 36474 * request 36475 * .post('/user') 36476 * .send({ name: 'tj' }) 36477 * .end(function(res){}); 36478 * 36479 * Or passed to `.send()`: 36480 * 36481 * request 36482 * .post('/user') 36483 * .send({ name: 'tj' }, function(res){}); 36484 * 36485 * Or passed to `.post()`: 36486 * 36487 * request 36488 * .post('/user', { name: 'tj' }) 36489 * .end(function(res){}); 36490 * 36491 * Or further reduced to a single call for simple cases: 36492 * 36493 * request 36494 * .post('/user', { name: 'tj' }, function(res){}); 36495 * 36496 * @param {XMLHTTPRequest} xhr 36497 * @param {Object} options 36498 * @api private 36499 */ 36500 36501 36502function Response(req) { 36503 this.req = req; 36504 this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers 36505 36506 this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null; 36507 this.statusText = this.req.xhr.statusText; 36508 var status = this.xhr.status; // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request 36509 36510 if (status === 1223) { 36511 status = 204; 36512 } 36513 36514 this._setStatusProperties(status); 36515 36516 this.headers = parseHeader(this.xhr.getAllResponseHeaders()); 36517 this.header = this.headers; // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but 36518 // getResponseHeader still works. so we get content-type even if getting 36519 // other headers fails. 36520 36521 this.header['content-type'] = this.xhr.getResponseHeader('content-type'); 36522 36523 this._setHeaderProperties(this.header); 36524 36525 if (this.text === null && req._responseType) { 36526 this.body = this.xhr.response; 36527 } else { 36528 this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response); 36529 } 36530} // eslint-disable-next-line new-cap 36531 36532 36533ResponseBase(Response.prototype); 36534/** 36535 * Parse the given body `str`. 36536 * 36537 * Used for auto-parsing of bodies. Parsers 36538 * are defined on the `superagent.parse` object. 36539 * 36540 * @param {String} str 36541 * @return {Mixed} 36542 * @api private 36543 */ 36544 36545Response.prototype._parseBody = function (str) { 36546 var parse = request.parse[this.type]; 36547 36548 if (this.req._parser) { 36549 return this.req._parser(this, str); 36550 } 36551 36552 if (!parse && isJSON(this.type)) { 36553 parse = request.parse['application/json']; 36554 } 36555 36556 return parse && str && (str.length > 0 || str instanceof Object) ? parse(str) : null; 36557}; 36558/** 36559 * Return an `Error` representative of this response. 36560 * 36561 * @return {Error} 36562 * @api public 36563 */ 36564 36565 36566Response.prototype.toError = function () { 36567 var req = this.req; 36568 var method = req.method; 36569 var url = req.url; 36570 var msg = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")"); 36571 var err = new Error(msg); 36572 err.status = this.status; 36573 err.method = method; 36574 err.url = url; 36575 return err; 36576}; 36577/** 36578 * Expose `Response`. 36579 */ 36580 36581 36582request.Response = Response; 36583/** 36584 * Initialize a new `Request` with the given `method` and `url`. 36585 * 36586 * @param {String} method 36587 * @param {String} url 36588 * @api public 36589 */ 36590 36591function Request(method, url) { 36592 var self = this; 36593 this._query = this._query || []; 36594 this.method = method; 36595 this.url = url; 36596 this.header = {}; // preserves header name case 36597 36598 this._header = {}; // coerces header names to lowercase 36599 36600 this.on('end', function () { 36601 var err = null; 36602 var res = null; 36603 36604 try { 36605 res = new Response(self); 36606 } catch (err_) { 36607 err = new Error('Parser is unable to parse the response'); 36608 err.parse = true; 36609 err.original = err_; // issue #675: return the raw response if the response parsing fails 36610 36611 if (self.xhr) { 36612 // ie9 doesn't have 'response' property 36613 err.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response; // issue #876: return the http status code if the response parsing fails 36614 36615 err.status = self.xhr.status ? self.xhr.status : null; 36616 err.statusCode = err.status; // backwards-compat only 36617 } else { 36618 err.rawResponse = null; 36619 err.status = null; 36620 } 36621 36622 return self.callback(err); 36623 } 36624 36625 self.emit('response', res); 36626 var new_err; 36627 36628 try { 36629 if (!self._isResponseOK(res)) { 36630 new_err = new Error(res.statusText || res.text || 'Unsuccessful HTTP response'); 36631 } 36632 } catch (err_) { 36633 new_err = err_; // ok() callback can throw 36634 } // #1000 don't catch errors from the callback to avoid double calling it 36635 36636 36637 if (new_err) { 36638 new_err.original = err; 36639 new_err.response = res; 36640 new_err.status = res.status; 36641 self.callback(new_err, res); 36642 } else { 36643 self.callback(null, res); 36644 } 36645 }); 36646} 36647/** 36648 * Mixin `Emitter` and `RequestBase`. 36649 */ 36650// eslint-disable-next-line new-cap 36651 36652 36653Emitter(Request.prototype); // eslint-disable-next-line new-cap 36654 36655RequestBase(Request.prototype); 36656/** 36657 * Set Content-Type to `type`, mapping values from `request.types`. 36658 * 36659 * Examples: 36660 * 36661 * superagent.types.xml = 'application/xml'; 36662 * 36663 * request.post('/') 36664 * .type('xml') 36665 * .send(xmlstring) 36666 * .end(callback); 36667 * 36668 * request.post('/') 36669 * .type('application/xml') 36670 * .send(xmlstring) 36671 * .end(callback); 36672 * 36673 * @param {String} type 36674 * @return {Request} for chaining 36675 * @api public 36676 */ 36677 36678Request.prototype.type = function (type) { 36679 this.set('Content-Type', request.types[type] || type); 36680 return this; 36681}; 36682/** 36683 * Set Accept to `type`, mapping values from `request.types`. 36684 * 36685 * Examples: 36686 * 36687 * superagent.types.json = 'application/json'; 36688 * 36689 * request.get('/agent') 36690 * .accept('json') 36691 * .end(callback); 36692 * 36693 * request.get('/agent') 36694 * .accept('application/json') 36695 * .end(callback); 36696 * 36697 * @param {String} accept 36698 * @return {Request} for chaining 36699 * @api public 36700 */ 36701 36702 36703Request.prototype.accept = function (type) { 36704 this.set('Accept', request.types[type] || type); 36705 return this; 36706}; 36707/** 36708 * Set Authorization field value with `user` and `pass`. 36709 * 36710 * @param {String} user 36711 * @param {String} [pass] optional in case of using 'bearer' as type 36712 * @param {Object} options with 'type' property 'auto', 'basic' or 'bearer' (default 'basic') 36713 * @return {Request} for chaining 36714 * @api public 36715 */ 36716 36717 36718Request.prototype.auth = function (user, pass, options) { 36719 if (arguments.length === 1) pass = ''; 36720 36721 if (_typeof(pass) === 'object' && pass !== null) { 36722 // pass is optional and can be replaced with options 36723 options = pass; 36724 pass = ''; 36725 } 36726 36727 if (!options) { 36728 options = { 36729 type: typeof btoa === 'function' ? 'basic' : 'auto' 36730 }; 36731 } 36732 36733 var encoder = function encoder(string) { 36734 if (typeof btoa === 'function') { 36735 return btoa(string); 36736 } 36737 36738 throw new Error('Cannot use basic auth, btoa is not a function'); 36739 }; 36740 36741 return this._auth(user, pass, options, encoder); 36742}; 36743/** 36744 * Add query-string `val`. 36745 * 36746 * Examples: 36747 * 36748 * request.get('/shoes') 36749 * .query('size=10') 36750 * .query({ color: 'blue' }) 36751 * 36752 * @param {Object|String} val 36753 * @return {Request} for chaining 36754 * @api public 36755 */ 36756 36757 36758Request.prototype.query = function (val) { 36759 if (typeof val !== 'string') val = serialize(val); 36760 if (val) this._query.push(val); 36761 return this; 36762}; 36763/** 36764 * Queue the given `file` as an attachment to the specified `field`, 36765 * with optional `options` (or filename). 36766 * 36767 * ``` js 36768 * request.post('/upload') 36769 * .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"})) 36770 * .end(callback); 36771 * ``` 36772 * 36773 * @param {String} field 36774 * @param {Blob|File} file 36775 * @param {String|Object} options 36776 * @return {Request} for chaining 36777 * @api public 36778 */ 36779 36780 36781Request.prototype.attach = function (field, file, options) { 36782 if (file) { 36783 if (this._data) { 36784 throw new Error("superagent can't mix .send() and .attach()"); 36785 } 36786 36787 this._getFormData().append(field, file, options || file.name); 36788 } 36789 36790 return this; 36791}; 36792 36793Request.prototype._getFormData = function () { 36794 if (!this._formData) { 36795 this._formData = new root.FormData(); 36796 } 36797 36798 return this._formData; 36799}; 36800/** 36801 * Invoke the callback with `err` and `res` 36802 * and handle arity check. 36803 * 36804 * @param {Error} err 36805 * @param {Response} res 36806 * @api private 36807 */ 36808 36809 36810Request.prototype.callback = function (err, res) { 36811 if (this._shouldRetry(err, res)) { 36812 return this._retry(); 36813 } 36814 36815 var fn = this._callback; 36816 this.clearTimeout(); 36817 36818 if (err) { 36819 if (this._maxRetries) err.retries = this._retries - 1; 36820 this.emit('error', err); 36821 } 36822 36823 fn(err, res); 36824}; 36825/** 36826 * Invoke callback with x-domain error. 36827 * 36828 * @api private 36829 */ 36830 36831 36832Request.prototype.crossDomainError = function () { 36833 var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); 36834 err.crossDomain = true; 36835 err.status = this.status; 36836 err.method = this.method; 36837 err.url = this.url; 36838 this.callback(err); 36839}; // This only warns, because the request is still likely to work 36840 36841 36842Request.prototype.agent = function () { 36843 console.warn('This is not supported in browser version of superagent'); 36844 return this; 36845}; 36846 36847Request.prototype.ca = Request.prototype.agent; 36848Request.prototype.buffer = Request.prototype.ca; // This throws, because it can't send/receive data as expected 36849 36850Request.prototype.write = function () { 36851 throw new Error('Streaming is not supported in browser version of superagent'); 36852}; 36853 36854Request.prototype.pipe = Request.prototype.write; 36855/** 36856 * Check if `obj` is a host object, 36857 * we don't want to serialize these :) 36858 * 36859 * @param {Object} obj host object 36860 * @return {Boolean} is a host object 36861 * @api private 36862 */ 36863 36864Request.prototype._isHost = function (obj) { 36865 // Native objects stringify to [object File], [object Blob], [object FormData], etc. 36866 return obj && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]'; 36867}; 36868/** 36869 * Initiate request, invoking callback `fn(res)` 36870 * with an instanceof `Response`. 36871 * 36872 * @param {Function} fn 36873 * @return {Request} for chaining 36874 * @api public 36875 */ 36876 36877 36878Request.prototype.end = function (fn) { 36879 if (this._endCalled) { 36880 console.warn('Warning: .end() was called twice. This is not supported in superagent'); 36881 } 36882 36883 this._endCalled = true; // store callback 36884 36885 this._callback = fn || noop; // querystring 36886 36887 this._finalizeQueryString(); 36888 36889 this._end(); 36890}; 36891 36892Request.prototype._setUploadTimeout = function () { 36893 var self = this; // upload timeout it's wokrs only if deadline timeout is off 36894 36895 if (this._uploadTimeout && !this._uploadTimeoutTimer) { 36896 this._uploadTimeoutTimer = setTimeout(function () { 36897 self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT'); 36898 }, this._uploadTimeout); 36899 } 36900}; // eslint-disable-next-line complexity 36901 36902 36903Request.prototype._end = function () { 36904 if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called')); 36905 var self = this; 36906 this.xhr = request.getXHR(); 36907 var xhr = this.xhr; 36908 var data = this._formData || this._data; 36909 36910 this._setTimeouts(); // state change 36911 36912 36913 xhr.onreadystatechange = function () { 36914 var readyState = xhr.readyState; 36915 36916 if (readyState >= 2 && self._responseTimeoutTimer) { 36917 clearTimeout(self._responseTimeoutTimer); 36918 } 36919 36920 if (readyState !== 4) { 36921 return; 36922 } // In IE9, reads to any property (e.g. status) off of an aborted XHR will 36923 // result in the error "Could not complete the operation due to error c00c023f" 36924 36925 36926 var status; 36927 36928 try { 36929 status = xhr.status; 36930 } catch (_unused5) { 36931 status = 0; 36932 } 36933 36934 if (!status) { 36935 if (self.timedout || self._aborted) return; 36936 return self.crossDomainError(); 36937 } 36938 36939 self.emit('end'); 36940 }; // progress 36941 36942 36943 var handleProgress = function handleProgress(direction, e) { 36944 if (e.total > 0) { 36945 e.percent = e.loaded / e.total * 100; 36946 36947 if (e.percent === 100) { 36948 clearTimeout(self._uploadTimeoutTimer); 36949 } 36950 } 36951 36952 e.direction = direction; 36953 self.emit('progress', e); 36954 }; 36955 36956 if (this.hasListeners('progress')) { 36957 try { 36958 xhr.addEventListener('progress', handleProgress.bind(null, 'download')); 36959 36960 if (xhr.upload) { 36961 xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload')); 36962 } 36963 } catch (_unused6) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. 36964 // Reported here: 36965 // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context 36966 } 36967 } 36968 36969 if (xhr.upload) { 36970 this._setUploadTimeout(); 36971 } // initiate request 36972 36973 36974 try { 36975 if (this.username && this.password) { 36976 xhr.open(this.method, this.url, true, this.username, this.password); 36977 } else { 36978 xhr.open(this.method, this.url, true); 36979 } 36980 } catch (err) { 36981 // see #1149 36982 return this.callback(err); 36983 } // CORS 36984 36985 36986 if (this._withCredentials) xhr.withCredentials = true; // body 36987 36988 if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) { 36989 // serialize stuff 36990 var contentType = this._header['content-type']; 36991 36992 var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : '']; 36993 36994 if (!_serialize && isJSON(contentType)) { 36995 _serialize = request.serialize['application/json']; 36996 } 36997 36998 if (_serialize) data = _serialize(data); 36999 } // set header fields 37000 37001 37002 for (var field in this.header) { 37003 if (this.header[field] === null) continue; 37004 if (Object.prototype.hasOwnProperty.call(this.header, field)) xhr.setRequestHeader(field, this.header[field]); 37005 } 37006 37007 if (this._responseType) { 37008 xhr.responseType = this._responseType; 37009 } // send stuff 37010 37011 37012 this.emit('request', this); // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) 37013 // We need null here if data is undefined 37014 37015 xhr.send(typeof data === 'undefined' ? null : data); 37016}; 37017 37018request.agent = function () { 37019 return new Agent(); 37020}; 37021 37022['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'].forEach(function (method) { 37023 Agent.prototype[method.toLowerCase()] = function (url, fn) { 37024 var req = new request.Request(method, url); 37025 37026 this._setDefaults(req); 37027 37028 if (fn) { 37029 req.end(fn); 37030 } 37031 37032 return req; 37033 }; 37034}); 37035Agent.prototype.del = Agent.prototype.delete; 37036/** 37037 * GET `url` with optional callback `fn(res)`. 37038 * 37039 * @param {String} url 37040 * @param {Mixed|Function} [data] or fn 37041 * @param {Function} [fn] 37042 * @return {Request} 37043 * @api public 37044 */ 37045 37046request.get = function (url, data, fn) { 37047 var req = request('GET', url); 37048 37049 if (typeof data === 'function') { 37050 fn = data; 37051 data = null; 37052 } 37053 37054 if (data) req.query(data); 37055 if (fn) req.end(fn); 37056 return req; 37057}; 37058/** 37059 * HEAD `url` with optional callback `fn(res)`. 37060 * 37061 * @param {String} url 37062 * @param {Mixed|Function} [data] or fn 37063 * @param {Function} [fn] 37064 * @return {Request} 37065 * @api public 37066 */ 37067 37068 37069request.head = function (url, data, fn) { 37070 var req = request('HEAD', url); 37071 37072 if (typeof data === 'function') { 37073 fn = data; 37074 data = null; 37075 } 37076 37077 if (data) req.query(data); 37078 if (fn) req.end(fn); 37079 return req; 37080}; 37081/** 37082 * OPTIONS query to `url` with optional callback `fn(res)`. 37083 * 37084 * @param {String} url 37085 * @param {Mixed|Function} [data] or fn 37086 * @param {Function} [fn] 37087 * @return {Request} 37088 * @api public 37089 */ 37090 37091 37092request.options = function (url, data, fn) { 37093 var req = request('OPTIONS', url); 37094 37095 if (typeof data === 'function') { 37096 fn = data; 37097 data = null; 37098 } 37099 37100 if (data) req.send(data); 37101 if (fn) req.end(fn); 37102 return req; 37103}; 37104/** 37105 * DELETE `url` with optional `data` and callback `fn(res)`. 37106 * 37107 * @param {String} url 37108 * @param {Mixed} [data] 37109 * @param {Function} [fn] 37110 * @return {Request} 37111 * @api public 37112 */ 37113 37114 37115function del(url, data, fn) { 37116 var req = request('DELETE', url); 37117 37118 if (typeof data === 'function') { 37119 fn = data; 37120 data = null; 37121 } 37122 37123 if (data) req.send(data); 37124 if (fn) req.end(fn); 37125 return req; 37126} 37127 37128request.del = del; 37129request.delete = del; 37130/** 37131 * PATCH `url` with optional `data` and callback `fn(res)`. 37132 * 37133 * @param {String} url 37134 * @param {Mixed} [data] 37135 * @param {Function} [fn] 37136 * @return {Request} 37137 * @api public 37138 */ 37139 37140request.patch = function (url, data, fn) { 37141 var req = request('PATCH', url); 37142 37143 if (typeof data === 'function') { 37144 fn = data; 37145 data = null; 37146 } 37147 37148 if (data) req.send(data); 37149 if (fn) req.end(fn); 37150 return req; 37151}; 37152/** 37153 * POST `url` with optional `data` and callback `fn(res)`. 37154 * 37155 * @param {String} url 37156 * @param {Mixed} [data] 37157 * @param {Function} [fn] 37158 * @return {Request} 37159 * @api public 37160 */ 37161 37162 37163request.post = function (url, data, fn) { 37164 var req = request('POST', url); 37165 37166 if (typeof data === 'function') { 37167 fn = data; 37168 data = null; 37169 } 37170 37171 if (data) req.send(data); 37172 if (fn) req.end(fn); 37173 return req; 37174}; 37175/** 37176 * PUT `url` with optional `data` and callback `fn(res)`. 37177 * 37178 * @param {String} url 37179 * @param {Mixed|Function} [data] or fn 37180 * @param {Function} [fn] 37181 * @return {Request} 37182 * @api public 37183 */ 37184 37185 37186request.put = function (url, data, fn) { 37187 var req = request('PUT', url); 37188 37189 if (typeof data === 'function') { 37190 fn = data; 37191 data = null; 37192 } 37193 37194 if (data) req.send(data); 37195 if (fn) req.end(fn); 37196 return req; 37197}; 37198//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jbGllbnQuanMiXSwibmFtZXMiOlsicm9vdCIsIndpbmRvdyIsInNlbGYiLCJjb25zb2xlIiwid2FybiIsIkVtaXR0ZXIiLCJyZXF1aXJlIiwic2FmZVN0cmluZ2lmeSIsIlJlcXVlc3RCYXNlIiwiaXNPYmplY3QiLCJSZXNwb25zZUJhc2UiLCJBZ2VudCIsIm5vb3AiLCJtb2R1bGUiLCJleHBvcnRzIiwibWV0aG9kIiwidXJsIiwiUmVxdWVzdCIsImVuZCIsImFyZ3VtZW50cyIsImxlbmd0aCIsInJlcXVlc3QiLCJnZXRYSFIiLCJYTUxIdHRwUmVxdWVzdC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XN0fVxuICogQGFwaSBwdWJsaWNcbiAqL1xuXG5yZXF1ZXN0LnBvc3QgPSAodXJsLCBkYXRhLCBmbikgPT4ge1xuICBjb25zdCByZXEgPSByZXF1ZXN0KCdQT1NUJywgdXJsKTtcbiAgaWYgKHR5cGVvZiBkYXRhID09PSAnZnVuY3Rpb24nKSB7XG4gICAgZm4gPSBkYXRhO1xuICAgIGRhdGEgPSBudWxsO1xuICB9XG5cbiAgaWYgKGRhdGEpIHJlcS5zZW5kKGRhdGEpO1xuICBpZiAoZm4pIHJlcS5lbmQoZm4pO1xuICByZXR1cm4gcmVxO1xufTtcblxuLyoqXG4gKiBQVVQgYHVybGAgd2l0aCBvcHRpb25hbCBgZGF0YWAgYW5kIGNhbGxiYWNrIGBmbihyZXMpYC5cbiAqXG4gKiBAcGFyYW0ge1N0cmluZ30gdXJsXG4gKiBAcGFyYW0ge01peGVkfEZ1bmN0aW9ufSBbZGF0YV0gb3IgZm5cbiAqIEBwYXJhbSB7RnVuY3Rpb259IFtmbl1cbiAqIEByZXR1cm4ge1JlcXVlc3R9XG4gKiBAYXBpIHB1YmxpY1xuICovXG5cbnJlcXVlc3QucHV0ID0gKHVybCwgZGF0YSwgZm4pID0+IHtcbiAgY29uc3QgcmVxID0gcmVxdWVzdCgnUFVUJywgdXJsKTtcbiAgaWYgKHR5cGVvZiBkYXRhID09PSAnZnVuY3Rpb24nKSB7XG4gICAgZm4gPSBkYXRhO1xuICAgIGRhdGEgPSBudWxsO1xuICB9XG5cbiAgaWYgKGRhdGEpIHJlcS5zZW5kKGRhdGEpO1xuICBpZiAoZm4pIHJlcS5lbmQoZm4pO1xuICByZXR1cm4gcmVxO1xufTtcbiJdfQ== 37199 37200/***/ }), 37201
vendor: 1,919 bytes, lines 37202-37229
37202/***/ "../../node_modules/superagent/lib/is-object.js": 37203/*!*****************************************************************************************************************************************!*\ 37204 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/is-object.js ***! 37205 \*****************************************************************************************************************************************/ 37206/*! no static exports found */ 37207/***/ (function(module, exports, __webpack_require__) { 37208 37209"use strict"; 37210 37211 37212function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 37213 37214/** 37215 * Check if `obj` is an object. 37216 * 37217 * @param {Object} obj 37218 * @return {Boolean} 37219 * @api private 37220 */ 37221function isObject(obj) { 37222 return obj !== null && _typeof(obj) === 'object'; 37223} 37224 37225module.exports = isObject; 37226//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pcy1vYmplY3QuanMiXSwibmFtZXMiOlsiaXNPYmplY3QiLCJvYmoiLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOzs7O0FBQUE7Ozs7Ozs7QUFRQSxTQUFTQSxRQUFULENBQWtCQyxHQUFsQixFQUF1QjtBQUNyQixTQUFPQSxHQUFHLEtBQUssSUFBUixJQUFnQixRQUFPQSxHQUFQLE1BQWUsUUFBdEM7QUFDRDs7QUFFREMsTUFBTSxDQUFDQyxPQUFQLEdBQWlCSCxRQUFqQiIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ2hlY2sgaWYgYG9iamAgaXMgYW4gb2JqZWN0LlxuICpcbiAqIEBwYXJhbSB7T2JqZWN0fSBvYmpcbiAqIEByZXR1cm4ge0Jvb2xlYW59XG4gKiBAYXBpIHByaXZhdGVcbiAqL1xuXG5mdW5jdGlvbiBpc09iamVjdChvYmopIHtcbiAgcmV0dXJuIG9iaiAhPT0gbnVsbCAmJiB0eXBlb2Ygb2JqID09PSAnb2JqZWN0Jztcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBpc09iamVjdDtcbiJdfQ== 37227 37228/***/ }), 37229
vendor: 60,532 bytes, lines 37230-37997
37230/***/ "../../node_modules/superagent/lib/request-base.js": 37231/*!********************************************************************************************************************************************!*\ 37232 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/request-base.js ***! 37233 \********************************************************************************************************************************************/ 37234/*! no static exports found */ 37235/***/ (function(module, exports, __webpack_require__) { 37236 37237"use strict"; 37238 37239 37240function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 37241 37242/** 37243 * Module of mixed-in functions shared between node and client code 37244 */ 37245var isObject = __webpack_require__(/*! ./is-object */ "../../node_modules/superagent/lib/is-object.js"); 37246/** 37247 * Expose `RequestBase`. 37248 */ 37249 37250 37251module.exports = RequestBase; 37252/** 37253 * Initialize a new `RequestBase`. 37254 * 37255 * @api public 37256 */ 37257 37258function RequestBase(obj) { 37259 if (obj) return mixin(obj); 37260} 37261/** 37262 * Mixin the prototype properties. 37263 * 37264 * @param {Object} obj 37265 * @return {Object} 37266 * @api private 37267 */ 37268 37269 37270function mixin(obj) { 37271 for (var key in RequestBase.prototype) { 37272 if (Object.prototype.hasOwnProperty.call(RequestBase.prototype, key)) obj[key] = RequestBase.prototype[key]; 37273 } 37274 37275 return obj; 37276} 37277/** 37278 * Clear previous timeout. 37279 * 37280 * @return {Request} for chaining 37281 * @api public 37282 */ 37283 37284 37285RequestBase.prototype.clearTimeout = function () { 37286 clearTimeout(this._timer); 37287 clearTimeout(this._responseTimeoutTimer); 37288 clearTimeout(this._uploadTimeoutTimer); 37289 delete this._timer; 37290 delete this._responseTimeoutTimer; 37291 delete this._uploadTimeoutTimer; 37292 return this; 37293}; 37294/** 37295 * Override default response body parser 37296 * 37297 * This function will be called to convert incoming data into request.body 37298 * 37299 * @param {Function} 37300 * @api public 37301 */ 37302 37303 37304RequestBase.prototype.parse = function (fn) { 37305 this._parser = fn; 37306 return this; 37307}; 37308/** 37309 * Set format of binary response body. 37310 * In browser valid formats are 'blob' and 'arraybuffer', 37311 * which return Blob and ArrayBuffer, respectively. 37312 * 37313 * In Node all values result in Buffer. 37314 * 37315 * Examples: 37316 * 37317 * req.get('/') 37318 * .responseType('blob') 37319 * .end(callback); 37320 * 37321 * @param {String} val 37322 * @return {Request} for chaining 37323 * @api public 37324 */ 37325 37326 37327RequestBase.prototype.responseType = function (val) { 37328 this._responseType = val; 37329 return this; 37330}; 37331/** 37332 * Override default request body serializer 37333 * 37334 * This function will be called to convert data set via .send or .attach into payload to send 37335 * 37336 * @param {Function} 37337 * @api public 37338 */ 37339 37340 37341RequestBase.prototype.serialize = function (fn) { 37342 this._serializer = fn; 37343 return this; 37344}; 37345/** 37346 * Set timeouts. 37347 * 37348 * - response timeout is time between sending request and receiving the first byte of the response. Includes DNS and connection time. 37349 * - deadline is the time from start of the request to receiving response body in full. If the deadline is too short large files may not load at all on slow connections. 37350 * - upload is the time since last bit of data was sent or received. This timeout works only if deadline timeout is off 37351 * 37352 * Value of 0 or false means no timeout. 37353 * 37354 * @param {Number|Object} ms or {response, deadline} 37355 * @return {Request} for chaining 37356 * @api public 37357 */ 37358 37359 37360RequestBase.prototype.timeout = function (options) { 37361 if (!options || _typeof(options) !== 'object') { 37362 this._timeout = options; 37363 this._responseTimeout = 0; 37364 this._uploadTimeout = 0; 37365 return this; 37366 } 37367 37368 for (var option in options) { 37369 if (Object.prototype.hasOwnProperty.call(options, option)) { 37370 switch (option) { 37371 case 'deadline': 37372 this._timeout = options.deadline; 37373 break; 37374 37375 case 'response': 37376 this._responseTimeout = options.response; 37377 break; 37378 37379 case 'upload': 37380 this._uploadTimeout = options.upload; 37381 break; 37382 37383 default: 37384 console.warn('Unknown timeout option', option); 37385 } 37386 } 37387 } 37388 37389 return this; 37390}; 37391/** 37392 * Set number of retry attempts on error. 37393 * 37394 * Failed requests will be retried 'count' times if timeout or err.code >= 500. 37395 * 37396 * @param {Number} count 37397 * @param {Function} [fn] 37398 * @return {Request} for chaining 37399 * @api public 37400 */ 37401 37402 37403RequestBase.prototype.retry = function (count, fn) { 37404 // Default to 1 if no count passed or true 37405 if (arguments.length === 0 || count === true) count = 1; 37406 if (count <= 0) count = 0; 37407 this._maxRetries = count; 37408 this._retries = 0; 37409 this._retryCallback = fn; 37410 return this; 37411}; 37412 37413var ERROR_CODES = ['ECONNRESET', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT']; 37414/** 37415 * Determine if a request should be retried. 37416 * (Borrowed from segmentio/superagent-retry) 37417 * 37418 * @param {Error} err an error 37419 * @param {Response} [res] response 37420 * @returns {Boolean} if segment should be retried 37421 */ 37422 37423RequestBase.prototype._shouldRetry = function (err, res) { 37424 if (!this._maxRetries || this._retries++ >= this._maxRetries) { 37425 return false; 37426 } 37427 37428 if (this._retryCallback) { 37429 try { 37430 var override = this._retryCallback(err, res); 37431 37432 if (override === true) return true; 37433 if (override === false) return false; // undefined falls back to defaults 37434 } catch (err_) { 37435 console.error(err_); 37436 } 37437 } 37438 37439 if (res && res.status && res.status >= 500 && res.status !== 501) return true; 37440 37441 if (err) { 37442 if (err.code && ERROR_CODES.includes(err.code)) return true; // Superagent timeout 37443 37444 if (err.timeout && err.code === 'ECONNABORTED') return true; 37445 if (err.crossDomain) return true; 37446 } 37447 37448 return false; 37449}; 37450/** 37451 * Retry request 37452 * 37453 * @return {Request} for chaining 37454 * @api private 37455 */ 37456 37457 37458RequestBase.prototype._retry = function () { 37459 this.clearTimeout(); // node 37460 37461 if (this.req) { 37462 this.req = null; 37463 this.req = this.request(); 37464 } 37465 37466 this._aborted = false; 37467 this.timedout = false; 37468 this.timedoutError = null; 37469 return this._end(); 37470}; 37471/** 37472 * Promise support 37473 * 37474 * @param {Function} resolve 37475 * @param {Function} [reject] 37476 * @return {Request} 37477 */ 37478 37479 37480RequestBase.prototype.then = function (resolve, reject) { 37481 var _this = this; 37482 37483 if (!this._fullfilledPromise) { 37484 var self = this; 37485 37486 if (this._endCalled) { 37487 console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises'); 37488 } 37489 37490 this._fullfilledPromise = new Promise(function (resolve, reject) { 37491 self.on('abort', function () { 37492 if (_this._maxRetries && _this._maxRetries > _this._retries) { 37493 return; 37494 } 37495 37496 if (_this.timedout && _this.timedoutError) { 37497 reject(_this.timedoutError); 37498 return; 37499 } 37500 37501 var err = new Error('Aborted'); 37502 err.code = 'ABORTED'; 37503 err.status = _this.status; 37504 err.method = _this.method; 37505 err.url = _this.url; 37506 reject(err); 37507 }); 37508 self.end(function (err, res) { 37509 if (err) reject(err);else resolve(res); 37510 }); 37511 }); 37512 } 37513 37514 return this._fullfilledPromise.then(resolve, reject); 37515}; 37516 37517RequestBase.prototype.catch = function (cb) { 37518 return this.then(undefined, cb); 37519}; 37520/** 37521 * Allow for extension 37522 */ 37523 37524 37525RequestBase.prototype.use = function (fn) { 37526 fn(this); 37527 return this; 37528}; 37529 37530RequestBase.prototype.ok = function (cb) { 37531 if (typeof cb !== 'function') throw new Error('Callback required'); 37532 this._okCallback = cb; 37533 return this; 37534}; 37535 37536RequestBase.prototype._isResponseOK = function (res) { 37537 if (!res) { 37538 return false; 37539 } 37540 37541 if (this._okCallback) { 37542 return this._okCallback(res); 37543 } 37544 37545 return res.status >= 200 && res.status < 300; 37546}; 37547/** 37548 * Get request header `field`. 37549 * Case-insensitive. 37550 * 37551 * @param {String} field 37552 * @return {String} 37553 * @api public 37554 */ 37555 37556 37557RequestBase.prototype.get = function (field) { 37558 return this._header[field.toLowerCase()]; 37559}; 37560/** 37561 * Get case-insensitive header `field` value. 37562 * This is a deprecated internal API. Use `.get(field)` instead. 37563 * 37564 * (getHeader is no longer used internally by the superagent code base) 37565 * 37566 * @param {String} field 37567 * @return {String} 37568 * @api private 37569 * @deprecated 37570 */ 37571 37572 37573RequestBase.prototype.getHeader = RequestBase.prototype.get; 37574/** 37575 * Set header `field` to `val`, or multiple fields with one object. 37576 * Case-insensitive. 37577 * 37578 * Examples: 37579 * 37580 * req.get('/') 37581 * .set('Accept', 'application/json') 37582 * .set('X-API-Key', 'foobar') 37583 * .end(callback); 37584 * 37585 * req.get('/') 37586 * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) 37587 * .end(callback); 37588 * 37589 * @param {String|Object} field 37590 * @param {String} val 37591 * @return {Request} for chaining 37592 * @api public 37593 */ 37594 37595RequestBase.prototype.set = function (field, val) { 37596 if (isObject(field)) { 37597 for (var key in field) { 37598 if (Object.prototype.hasOwnProperty.call(field, key)) this.set(key, field[key]); 37599 } 37600 37601 return this; 37602 } 37603 37604 this._header[field.toLowerCase()] = val; 37605 this.header[field] = val; 37606 return this; 37607}; 37608/** 37609 * Remove header `field`. 37610 * Case-insensitive. 37611 * 37612 * Example: 37613 * 37614 * req.get('/') 37615 * .unset('User-Agent') 37616 * .end(callback); 37617 * 37618 * @param {String} field field name 37619 */ 37620 37621 37622RequestBase.prototype.unset = function (field) { 37623 delete this._header[field.toLowerCase()]; 37624 delete this.header[field]; 37625 return this; 37626}; 37627/** 37628 * Write the field `name` and `val`, or multiple fields with one object 37629 * for "multipart/form-data" request bodies. 37630 * 37631 * ``` js 37632 * request.post('/upload') 37633 * .field('foo', 'bar') 37634 * .end(callback); 37635 * 37636 * request.post('/upload') 37637 * .field({ foo: 'bar', baz: 'qux' }) 37638 * .end(callback); 37639 * ``` 37640 * 37641 * @param {String|Object} name name of field 37642 * @param {String|Blob|File|Buffer|fs.ReadStream} val value of field 37643 * @return {Request} for chaining 37644 * @api public 37645 */ 37646 37647 37648RequestBase.prototype.field = function (name, val) { 37649 // name should be either a string or an object. 37650 if (name === null || undefined === name) { 37651 throw new Error('.field(name, val) name can not be empty'); 37652 } 37653 37654 if (this._data) { 37655 throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"); 37656 } 37657 37658 if (isObject(name)) { 37659 for (var key in name) { 37660 if (Object.prototype.hasOwnProperty.call(name, key)) this.field(key, name[key]); 37661 } 37662 37663 return this; 37664 } 37665 37666 if (Array.isArray(val)) { 37667 for (var i in val) { 37668 if (Object.prototype.hasOwnProperty.call(val, i)) this.field(name, val[i]); 37669 } 37670 37671 return this; 37672 } // val should be defined now 37673 37674 37675 if (val === null || undefined === val) { 37676 throw new Error('.field(name, val) val can not be empty'); 37677 } 37678 37679 if (typeof val === 'boolean') { 37680 val = String(val); 37681 } 37682 37683 this._getFormData().append(name, val); 37684 37685 return this; 37686}; 37687/** 37688 * Abort the request, and clear potential timeout. 37689 * 37690 * @return {Request} request 37691 * @api public 37692 */ 37693 37694 37695RequestBase.prototype.abort = function () { 37696 if (this._aborted) { 37697 return this; 37698 } 37699 37700 this._aborted = true; 37701 if (this.xhr) this.xhr.abort(); // browser 37702 37703 if (this.req) this.req.abort(); // node 37704 37705 this.clearTimeout(); 37706 this.emit('abort'); 37707 return this; 37708}; 37709 37710RequestBase.prototype._auth = function (user, pass, options, base64Encoder) { 37711 switch (options.type) { 37712 case 'basic': 37713 this.set('Authorization', "Basic ".concat(base64Encoder("".concat(user, ":").concat(pass)))); 37714 break; 37715 37716 case 'auto': 37717 this.username = user; 37718 this.password = pass; 37719 break; 37720 37721 case 'bearer': 37722 // usage would be .auth(accessToken, { type: 'bearer' }) 37723 this.set('Authorization', "Bearer ".concat(user)); 37724 break; 37725 37726 default: 37727 break; 37728 } 37729 37730 return this; 37731}; 37732/** 37733 * Enable transmission of cookies with x-domain requests. 37734 * 37735 * Note that for this to work the origin must not be 37736 * using "Access-Control-Allow-Origin" with a wildcard, 37737 * and also must set "Access-Control-Allow-Credentials" 37738 * to "true". 37739 * 37740 * @api public 37741 */ 37742 37743 37744RequestBase.prototype.withCredentials = function (on) { 37745 // This is browser-only functionality. Node side is no-op. 37746 if (on === undefined) on = true; 37747 this._withCredentials = on; 37748 return this; 37749}; 37750/** 37751 * Set the max redirects to `n`. Does nothing in browser XHR implementation. 37752 * 37753 * @param {Number} n 37754 * @return {Request} for chaining 37755 * @api public 37756 */ 37757 37758 37759RequestBase.prototype.redirects = function (n) { 37760 this._maxRedirects = n; 37761 return this; 37762}; 37763/** 37764 * Maximum size of buffered response body, in bytes. Counts uncompressed size. 37765 * Default 200MB. 37766 * 37767 * @param {Number} n number of bytes 37768 * @return {Request} for chaining 37769 */ 37770 37771 37772RequestBase.prototype.maxResponseSize = function (n) { 37773 if (typeof n !== 'number') { 37774 throw new TypeError('Invalid argument'); 37775 } 37776 37777 this._maxResponseSize = n; 37778 return this; 37779}; 37780/** 37781 * Convert to a plain javascript object (not JSON string) of scalar properties. 37782 * Note as this method is designed to return a useful non-this value, 37783 * it cannot be chained. 37784 * 37785 * @return {Object} describing method, url, and data of this request 37786 * @api public 37787 */ 37788 37789 37790RequestBase.prototype.toJSON = function () { 37791 return { 37792 method: this.method, 37793 url: this.url, 37794 data: this._data, 37795 headers: this._header 37796 }; 37797}; 37798/** 37799 * Send `data` as the request body, defaulting the `.type()` to "json" when 37800 * an object is given. 37801 * 37802 * Examples: 37803 * 37804 * // manual json 37805 * request.post('/user') 37806 * .type('json') 37807 * .send('{"name":"tj"}') 37808 * .end(callback) 37809 * 37810 * // auto json 37811 * request.post('/user') 37812 * .send({ name: 'tj' }) 37813 * .end(callback) 37814 * 37815 * // manual x-www-form-urlencoded 37816 * request.post('/user') 37817 * .type('form') 37818 * .send('name=tj') 37819 * .end(callback) 37820 * 37821 * // auto x-www-form-urlencoded 37822 * request.post('/user') 37823 * .type('form') 37824 * .send({ name: 'tj' }) 37825 * .end(callback) 37826 * 37827 * // defaults to x-www-form-urlencoded 37828 * request.post('/user') 37829 * .send('name=tobi') 37830 * .send('species=ferret') 37831 * .end(callback) 37832 * 37833 * @param {String|Object} data 37834 * @return {Request} for chaining 37835 * @api public 37836 */ 37837// eslint-disable-next-line complexity 37838 37839 37840RequestBase.prototype.send = function (data) { 37841 var isObj = isObject(data); 37842 var type = this._header['content-type']; 37843 37844 if (this._formData) { 37845 throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"); 37846 } 37847 37848 if (isObj && !this._data) { 37849 if (Array.isArray(data)) { 37850 this._data = []; 37851 } else if (!this._isHost(data)) { 37852 this._data = {}; 37853 } 37854 } else if (data && this._data && this._isHost(this._data)) { 37855 throw new Error("Can't merge these send calls"); 37856 } // merge 37857 37858 37859 if (isObj && isObject(this._data)) { 37860 for (var key in data) { 37861 if (Object.prototype.hasOwnProperty.call(data, key)) this._data[key] = data[key]; 37862 } 37863 } else if (typeof data === 'string') { 37864 // default to x-www-form-urlencoded 37865 if (!type) this.type('form'); 37866 type = this._header['content-type']; 37867 37868 if (type === 'application/x-www-form-urlencoded') { 37869 this._data = this._data ? "".concat(this._data, "&").concat(data) : data; 37870 } else { 37871 this._data = (this._data || '') + data; 37872 } 37873 } else { 37874 this._data = data; 37875 } 37876 37877 if (!isObj || this._isHost(data)) { 37878 return this; 37879 } // default to json 37880 37881 37882 if (!type) this.type('json'); 37883 return this; 37884}; 37885/** 37886 * Sort `querystring` by the sort function 37887 * 37888 * 37889 * Examples: 37890 * 37891 * // default order 37892 * request.get('/user') 37893 * .query('name=Nick') 37894 * .query('search=Manny') 37895 * .sortQuery() 37896 * .end(callback) 37897 * 37898 * // customized sort function 37899 * request.get('/user') 37900 * .query('name=Nick') 37901 * .query('search=Manny') 37902 * .sortQuery(function(a, b){ 37903 * return a.length - b.length; 37904 * }) 37905 * .end(callback) 37906 * 37907 * 37908 * @param {Function} sort 37909 * @return {Request} for chaining 37910 * @api public 37911 */ 37912 37913 37914RequestBase.prototype.sortQuery = function (sort) { 37915 // _sort default to true but otherwise can be a function or boolean 37916 this._sort = typeof sort === 'undefined' ? true : sort; 37917 return this; 37918}; 37919/** 37920 * Compose querystring to append to req.url 37921 * 37922 * @api private 37923 */ 37924 37925 37926RequestBase.prototype._finalizeQueryString = function () { 37927 var query = this._query.join('&'); 37928 37929 if (query) { 37930 this.url += (this.url.includes('?') ? '&' : '?') + query; 37931 } 37932 37933 this._query.length = 0; // Makes the call idempotent 37934 37935 if (this._sort) { 37936 var index = this.url.indexOf('?'); 37937 37938 if (index >= 0) { 37939 var queryArr = this.url.slice(index + 1).split('&'); 37940 37941 if (typeof this._sort === 'function') { 37942 queryArr.sort(this._sort); 37943 } else { 37944 queryArr.sort(); 37945 } 37946 37947 this.url = this.url.slice(0, index) + '?' + queryArr.join('&'); 37948 } 37949 } 37950}; // For backwards compat only 37951 37952 37953RequestBase.prototype._appendQueryString = function () { 37954 console.warn('Unsupported'); 37955}; 37956/** 37957 * Invoke callback with timeout error. 37958 * 37959 * @api private 37960 */ 37961 37962 37963RequestBase.prototype._timeoutError = function (reason, timeout, errno) { 37964 if (this._aborted) { 37965 return; 37966 } 37967 37968 var err = new Error("".concat(reason + timeout, "ms exceeded")); 37969 err.timeout = timeout; 37970 err.code = 'ECONNABORTED'; 37971 err.errno = errno; 37972 this.timedout = true; 37973 this.timedoutError = err; 37974 this.abort(); 37975 this.callback(err); 37976}; 37977 37978RequestBase.prototype._setTimeouts = function () { 37979 var self = this; // deadline 37980 37981 if (this._timeout && !this._timer) { 37982 this._timer = setTimeout(function () { 37983 self._timeoutError('Timeout of ', self._timeout, 'ETIME'); 37984 }, this._timeout); 37985 } // response timeout 37986 37987 37988 if (this._responseTimeout && !this._responseTimeoutTimer) { 37989 this._responseTimeoutTimer = setTimeout(function () { 37990 self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT'); 37991 }, this._responseTimeout); 37992 } 37993}; 37994//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9yZXF1ZXN0LWJhc2UuanMiXSwibmFtZXMiOlsiaXNPYmplY3QiLCJyZXF1aXJlIiwibW9kdWxlIi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pO1xuICB9XG5cbiAgLy8gcmVzcG9uc2UgdGltZW91dFxuICBpZiAodGhpcy5fcmVzcG9uc2VUaW1lb3V0ICYmICF0aGlzLl9yZXNwb25zZVRpbWVvdXRUaW1lcikge1xuICAgIHRoaXMuX3Jlc3BvbnNlVGltZW91dFRpbWVyID0gc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICBzZWxmLl90aW1lb3V0RXJyb3IoXG4gICAgICAgICdSZXNwb25zZSB0aW1lb3V0IG9mICcsXG4gICAgICAgIHNlbGYuX3Jlc3BvbnNlVGltZW91dCxcbiAgICAgICAgJ0VUSU1FRE9VVCdcbiAgICAgICk7XG4gICAgfSwgdGhpcy5fcmVzcG9uc2VUaW1lb3V0KTtcbiAgfVxufTtcbiJdfQ== 37995 37996/***/ }), 37997
vendor: 11,453 bytes, lines 37998-38139
37998/***/ "../../node_modules/superagent/lib/response-base.js": 37999/*!*********************************************************************************************************************************************!*\ 38000 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/response-base.js ***! 38001 \*********************************************************************************************************************************************/ 38002/*! no static exports found */ 38003/***/ (function(module, exports, __webpack_require__) { 38004 38005"use strict"; 38006 38007 38008/** 38009 * Module dependencies. 38010 */ 38011var utils = __webpack_require__(/*! ./utils */ "../../node_modules/superagent/lib/utils.js"); 38012/** 38013 * Expose `ResponseBase`. 38014 */ 38015 38016 38017module.exports = ResponseBase; 38018/** 38019 * Initialize a new `ResponseBase`. 38020 * 38021 * @api public 38022 */ 38023 38024function ResponseBase(obj) { 38025 if (obj) return mixin(obj); 38026} 38027/** 38028 * Mixin the prototype properties. 38029 * 38030 * @param {Object} obj 38031 * @return {Object} 38032 * @api private 38033 */ 38034 38035 38036function mixin(obj) { 38037 for (var key in ResponseBase.prototype) { 38038 if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key)) obj[key] = ResponseBase.prototype[key]; 38039 } 38040 38041 return obj; 38042} 38043/** 38044 * Get case-insensitive `field` value. 38045 * 38046 * @param {String} field 38047 * @return {String} 38048 * @api public 38049 */ 38050 38051 38052ResponseBase.prototype.get = function (field) { 38053 return this.header[field.toLowerCase()]; 38054}; 38055/** 38056 * Set header related properties: 38057 * 38058 * - `.type` the content type without params 38059 * 38060 * A response of "Content-Type: text/plain; charset=utf-8" 38061 * will provide you with a `.type` of "text/plain". 38062 * 38063 * @param {Object} header 38064 * @api private 38065 */ 38066 38067 38068ResponseBase.prototype._setHeaderProperties = function (header) { 38069 // TODO: moar! 38070 // TODO: make this a util 38071 // content-type 38072 var ct = header['content-type'] || ''; 38073 this.type = utils.type(ct); // params 38074 38075 var params = utils.params(ct); 38076 38077 for (var key in params) { 38078 if (Object.prototype.hasOwnProperty.call(params, key)) this[key] = params[key]; 38079 } 38080 38081 this.links = {}; // links 38082 38083 try { 38084 if (header.link) { 38085 this.links = utils.parseLinks(header.link); 38086 } 38087 } catch (_unused) {// ignore 38088 } 38089}; 38090/** 38091 * Set flags such as `.ok` based on `status`. 38092 * 38093 * For example a 2xx response will give you a `.ok` of __true__ 38094 * whereas 5xx will be __false__ and `.error` will be __true__. The 38095 * `.clientError` and `.serverError` are also available to be more 38096 * specific, and `.statusType` is the class of error ranging from 1..5 38097 * sometimes useful for mapping respond colors etc. 38098 * 38099 * "sugar" properties are also defined for common cases. Currently providing: 38100 * 38101 * - .noContent 38102 * - .badRequest 38103 * - .unauthorized 38104 * - .notAcceptable 38105 * - .notFound 38106 * 38107 * @param {Number} status 38108 * @api private 38109 */ 38110 38111 38112ResponseBase.prototype._setStatusProperties = function (status) { 38113 var type = status / 100 | 0; // status / class 38114 38115 this.statusCode = status; 38116 this.status = this.statusCode; 38117 this.statusType = type; // basics 38118 38119 this.info = type === 1; 38120 this.ok = type === 2; 38121 this.redirect = type === 3; 38122 this.clientError = type === 4; 38123 this.serverError = type === 5; 38124 this.error = type === 4 || type === 5 ? this.toError() : false; // sugar 38125 38126 this.created = status === 201; 38127 this.accepted = status === 202; 38128 this.noContent = status === 204; 38129 this.badRequest = status === 400; 38130 this.unauthorized = status === 401; 38131 this.notAcceptable = status === 406; 38132 this.forbidden = status === 403; 38133 this.notFound = status === 404; 38134 this.unprocessableEntity = status === 422; 38135}; 38136//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9yZXNwb25zZS1iYXNlLmpzIl0sIm5hbWVzIjpbInV0aWxzIiwicmVxdWlyZSIsIm1vZHVsZSIsImV4cG9ydHMiLCJSZXNwb25zZUJhc2UiLCJvYmoiLCJtaXhpbiIsImtleSIsInByb3RvdHlwZSIsIk9iamVjdCIsImhhc093blByb3BlcnR5IiwiY2FsbCIsImdldCIsImZpZWxkIiwiaGVhZGVyIiwidG9Mb3dlckNhc2UiLCJfc2V0SGVhZGVyUHJvcGVydGllcyIsImN0IiwidHlwZSIsInBhcmFtcyIsImxpbmtzIiwibGluayIsInBhcnNlTGlua3MiLCJfc2V0U3RhdHVzUHJvcGVydGllcyIsInN0YXR1cyIsInN0YXR1c0NvZGUiLCJzdGF0dXNUeXBlIiwiaW5mbyIsIm9rIiwicmVkaXJlY3QiLCJjbGllbnRFcnJvciIsInNlcnZlckVycm9yIiwiZXJyb3IiLCJ0b0Vycm9yIiwiY3JlYXRlZCIsImFjY2VwdGVkIiwibm9Db250ZW50IiwiYmFkUmVxdWVzdCIsInVuYXV0aG9yaXplZCIsIm5vdEFjY2VwdGFibGUiLCJmb3JiaWRkZW4iLCJub3RGb3VuZCIsInVucHJvY2Vzc2FibGVFbnRpdHkiXSwibWFwcGluZ3MiOiI7O0FBQUE7OztBQUlBLElBQU1BLEtBQUssR0FBR0MsT0FBTyxDQUFDLFNBQUQsQ0FBckI7QUFFQTs7Ozs7QUFJQUMsTUFBTSxDQUFDQyxPQUFQLEdBQWlCQyxZQUFqQjtBQUVBOzs7Ozs7QUFNQSxTQUFTQSxZQUFULENBQXNCQyxHQUF0QixFQUEyQjtBQ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b0Vycm9yKCkgOiBmYWxzZTtcblxuICAvLyBzdWdhclxuICB0aGlzLmNyZWF0ZWQgPSBzdGF0dXMgPT09IDIwMTtcbiAgdGhpcy5hY2NlcHRlZCA9IHN0YXR1cyA9PT0gMjAyO1xuICB0aGlzLm5vQ29udGVudCA9IHN0YXR1cyA9PT0gMjA0O1xuICB0aGlzLmJhZFJlcXVlc3QgPSBzdGF0dXMgPT09IDQwMDtcbiAgdGhpcy51bmF1dGhvcml6ZWQgPSBzdGF0dXMgPT09IDQwMTtcbiAgdGhpcy5ub3RBY2NlcHRhYmxlID0gc3RhdHVzID09PSA0MDY7XG4gIHRoaXMuZm9yYmlkZGVuID0gc3RhdHVzID09PSA0MDM7XG4gIHRoaXMubm90Rm91bmQgPSBzdGF0dXMgPT09IDQwNDtcbiAgdGhpcy51bnByb2Nlc3NhYmxlRW50aXR5ID0gc3RhdHVzID09PSA0MjI7XG59O1xuIl19 38137 38138/***/ }), 38139
vendor: 5,932 bytes, lines 38140-38221
38140/***/ "../../node_modules/superagent/lib/utils.js": 38141/*!*************************************************************************************************************************************!*\ 38142 !*** /Applications/XAMPP/xamppfiles/htdocs/gwu-wordpress/wp-content/themes/gardnerwebb-twenty/node_modules/superagent/lib/utils.js ***! 38143 \*************************************************************************************************************************************/ 38144/*! no static exports found */ 38145/***/ (function(module, exports, __webpack_require__) { 38146 38147"use strict"; 38148 38149 38150/** 38151 * Return the mime type for the given `str`. 38152 * 38153 * @param {String} str 38154 * @return {String} 38155 * @api private 38156 */ 38157exports.type = function (str) { 38158 return str.split(/ *; */).shift(); 38159}; 38160/** 38161 * Return header field parameters. 38162 * 38163 * @param {String} str 38164 * @return {Object} 38165 * @api private 38166 */ 38167 38168 38169exports.params = function (str) { 38170 return str.split(/ *; */).reduce(function (obj, str) { 38171 var parts = str.split(/ *= */); 38172 var key = parts.shift(); 38173 var val = parts.shift(); 38174 if (key && val) obj[key] = val; 38175 return obj; 38176 }, {}); 38177}; 38178/** 38179 * Parse Link header fields. 38180 * 38181 * @param {String} str 38182 * @return {Object} 38183 * @api private 38184 */ 38185 38186 38187exports.parseLinks = function (str) { 38188 return str.split(/ *, */).reduce(function (obj, str) { 38189 var parts = str.split(/ *; */); 38190 var url = parts[0].slice(1, -1); 38191 var rel = parts[1].split(/ *= */)[1].slice(1, -1); 38192 obj[rel] = url; 38193 return obj; 38194 }, {}); 38195}; 38196/** 38197 * Strip content related fields from `header`. 38198 * 38199 * @param {Object} header 38200 * @return {Object} header 38201 * @api private 38202 */ 38203 38204 38205exports.cleanHeader = function (header, changesOrigin) { 38206 delete header['content-type']; 38207 delete header['content-length']; 38208 delete header['transfer-encoding']; 38209 delete header.host; // secuirty 38210 38211 if (changesOrigin) { 38212 delete header.authorization; 38213 delete header.cookie; 38214 } 38215 38216 return header; 38217}; 38218//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy5qcyJdLCJuYW1lcyI6WyJleHBvcnRzIiwidHlwZSIsInN0ciIsInNwbGl0Iiwic2hpZnQiLCJwYXJhbXMiLCJyZWR1Y2UiLCJvYmoiLCJwYXJ0cyIsImtleSIsInZhbCIsInBhcnNlTGlua3MiLCJ1cmwiLCJzbGljZSIsInJlbCIsImNsZWFuSGVhZGVyIiwiaGVhZGVyIiwiY2hhbmdlc09yaWdpbiIsImhvc3QiLCJhdXRob3JpemF0aW9uIiwiY29va2llIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7O0FBUUFBLE9BQU8sQ0FBQ0MsSUFBUixHQUFlLFVBQUFDLEdBQUc7QUFBQSxTQUFJQSxHQUFHLENBQUNDLEtBQUosQ0FBVSxPQUFWLEVBQW1CQyxLQUFuQixFQUFKO0FBQUEsQ0FBbEI7QUFFQTs7Ozs7Ozs7O0FBUUFKLE9BQU8sQ0FBQ0ssTUFBUixHQUFpQixVQUFBSCxHQUFHO0FBQUEsU0FDbEJBLEdBQUcsQ0FBQ0MsS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C8vIHNlY3VpcnR5XG4gIGlmIChjaGFuZ2VzT3JpZ2luKSB7XG4gICAgZGVsZXRlIGhlYWRlci5hdXRob3JpemF0aW9uO1xuICAgIGRlbGV0ZSBoZWFkZXIuY29va2llO1xuICB9XG5cbiAgcmV0dXJuIGhlYWRlcjtcbn07XG4iXX0= 38219 38220/***/ }), 38221
38222/***/ "./full-width-media.js": 38223/*!*****************************!*\ 38224 !*** ./full-width-media.js ***! 38225 \*****************************/ 38226/*! exports provided: default */ 38227/***/ (function(module, __webpack_exports__, __webpack_require__) { 38228 38229"use strict"; 38230__webpack_require__.r(__webpack_exports__); 38231/* harmony import */ var _upup_baseline_js_src_youtube_player__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../upup-baseline/js/src/youtube-player */ "../../../upup-baseline/js/src/youtube-player.js"); 38232function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 38233 38234function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 38235 38236function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38237 38238function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38239 38240function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 38241 38242function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38243 38244 38245 38246var FullWidthMediaManager = function FullWidthMediaManager() { 38247 _classCallCheck(this, FullWidthMediaManager); 38248 38249 this.players = document.querySelectorAll('.full-width-media'); 38250 this.players.forEach(function (player) { 38251 var videoNode = player.querySelector('.full-width-media__player'); 38252 38253 if (videoNode) { 38254 new FullWidthMediaPlayer(player); 38255 } 38256 }); 38257}; 38258/** 38259 * TODO: nice to have here would be to show the screen on video pause or video end 38260 * Set up instance for one player element 38261 */ 38262 38263 38264var FullWidthMediaPlayer = /*#__PURE__*/function () { 38265 function FullWidthMediaPlayer(playerElement) { 38266 var _this = this; 38267 38268 _classCallCheck(this, FullWidthMediaPlayer); 38269 38270 _defineProperty(this, "handlePlayheadClick", function (e) { 38271 if (_this.playhead && _this.yt.player) { 38272 _this.yt.iframe.classList.add('active'); 38273 38274 _this.yt.player.playVideo(); 38275 38276 _this.screen.classList.add('hidden'); 38277 } 38278 }); 38279 38280 var playerNode = playerElement.querySelector('.full-width-media__player'), 38281 playhead = playerElement.querySelector('.full-width-media__playhead'), 38282 screen = playerElement.querySelector('.full-width-media__screen'); 38283 this.screen = screen; 38284 this.playhead = playhead; 38285 this.video = playerNode; 38286 this.yt = null; 38287 this.loadYTAPI(); 38288 this.setupPlayer(); 38289 this.setupControls(); 38290 } 38291 /** 38292 * Load the youtube API 38293 * Add a script tag to the page 38294 */ 38295 38296 38297 _createClass(FullWidthMediaPlayer, [{ 38298 key: "loadYTAPI", 38299 value: function loadYTAPI() { 38300 var ytScript = document.querySelector('script[src^="https://www.youtube.com/iframe_api"]'); 38301 38302 if (!ytScript && !window.YT) { 38303 var tag = document.createElement('script'); 38304 tag.src = "https://www.youtube.com/iframe_api"; 38305 var firstScriptTag = document.getElementsByTagName('script')[0]; 38306 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 38307 } 38308 } 38309 }, { 38310 key: "setupPlayer", 38311 value: function setupPlayer() { 38312 var _this2 = this; 38313 38314 var defaults = { 38315 thumbnail: 0, 38316 modestbranding: 1, 38317 version: 3, 38318 controls: 1, 38319 showinfo: 0, 38320 autoplay: 0, 38321 mute: 0, 38322 playsinline: 0, 38323 rel: 0 38324 }; 38325 this.yt = new _upup_baseline_js_src_youtube_player__WEBPACK_IMPORTED_MODULE_0__["default"](this.video, { 38326 onReady: function onReady() { 38327 if (!_this2.playhead) { 38328 _this2.yt.iframe.classList.add('active'); 38329 } 38330 }, 38331 playerVars: _objectSpread({}, defaults) 38332 }); 38333 } 38334 }, { 38335 key: "setupControls", 38336 value: function setupControls() { 38337 if (this.playhead) { 38338 this.playhead.addEventListener('click', this.handlePlayheadClick); 38339 } 38340 } 38341 }]); 38342 38343 return FullWidthMediaPlayer; 38344}(); 38345 38346/* harmony default export */ __webpack_exports__["default"] = (FullWidthMediaManager); 38347 38348/***/ }), 38349
38350/***/ "./global.jsx": 38351/*!********************!*\ 38352 !*** ./global.jsx ***! 38353 \********************/ 38354/*! no exports provided */ 38355/***/ (function(module, __webpack_exports__, __webpack_require__) { 38356 38357"use strict"; 38358__webpack_require__.r(__webpack_exports__); 38359/* harmony import */ var element_scroll_polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! element-scroll-polyfill */ "../../node_modules/element-scroll-polyfill/index.js"); 38360/* harmony import */ var element_scroll_polyfill__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(element_scroll_polyfill__WEBPACK_IMPORTED_MODULE_0__); 38361/* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utility */ "./utility.js"); 38362/* harmony import */ var _menu_primaryMenuController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./menu/primaryMenuController */ "./menu/primaryMenuController.js"); 38363/* harmony import */ var _menu_mobileMenuController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./menu/mobileMenuController */ "./menu/mobileMenuController.js"); 38364/* harmony import */ var _nav_panel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nav-panel */ "./nav-panel.js"); 38365/* harmony import */ var _plugins_upup_baseline_plugin_js_src_navigation_button_navigation_button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../plugins/upup-baseline-plugin/js/src/navigation-button/navigation-button */ "../../../../plugins/upup-baseline-plugin/js/src/navigation-button/navigation-button.js"); 38366/* harmony import */ var _plugins_upup_baseline_plugin_js_src_contextual_nav__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../plugins/upup-baseline-plugin/js/src/contextual-nav */ "../../../../plugins/upup-baseline-plugin/js/src/contextual-nav.js"); 38367/* harmony import */ var _upup_baseline_js_src_header_sticky_header__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../upup-baseline/js/src/header/sticky-header */ "../../../upup-baseline/js/src/header/sticky-header.js"); 38368/* harmony import */ var _full_width_media__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./full-width-media */ "./full-width-media.js"); 38369var _this = undefined; 38370 38371 38372 38373 38374 38375 38376 38377 38378 38379 38380var headerPrimaryMenu = document.getElementById('header-primary-menu'), 38381 headerUtilityMenu = document.getElementById('header-utility-menu'), 38382 mobileMenu = document.getElementById('mobile-primary-menu'), 38383 siteHeader = document.getElementById('site-header'), 38384 anchors = Array.from(document.querySelectorAll("a[href^='#']")); 38385new _menu_primaryMenuController__WEBPACK_IMPORTED_MODULE_2__["default"](headerPrimaryMenu); 38386new _menu_primaryMenuController__WEBPACK_IMPORTED_MODULE_2__["default"](headerUtilityMenu); 38387new _menu_mobileMenuController__WEBPACK_IMPORTED_MODULE_3__["default"](mobileMenu); 38388new _plugins_upup_baseline_plugin_js_src_navigation_button_navigation_button__WEBPACK_IMPORTED_MODULE_5__["default"](); 38389new _plugins_upup_baseline_plugin_js_src_contextual_nav__WEBPACK_IMPORTED_MODULE_6__["default"](); 38390new _nav_panel__WEBPACK_IMPORTED_MODULE_4__["default"](); 38391new _upup_baseline_js_src_header_sticky_header__WEBPACK_IMPORTED_MODULE_7__["default"](); 38392new _full_width_media__WEBPACK_IMPORTED_MODULE_8__["default"](); // video modules 38393 38394Object(_utility__WEBPACK_IMPORTED_MODULE_1__["setSearchHeaderHeight"])(); 38395window.addEventListener('resize', _utility__WEBPACK_IMPORTED_MODULE_1__["setSearchHeaderHeight"]); // keep up with how tall the header should be at the top of the page after a resize 38396// this was proving extra tricky since the header height transitions after scrolling down 38397 38398window.addEventListener('resize', function (e) { 38399 if (window.innerWidth > 992) { 38400 siteHeader.setAttribute('data-original-height', 124); 38401 } else { 38402 siteHeader.setAttribute('data-original-height', 80); 38403 } 38404}); // check for a comment form and label it if found 38405 38406var commentForm = document.getElementById('commentform'); 38407 38408if (commentForm) { 38409 commentForm.setAttribute('title', 'Leave a Comment'); 38410} // on load handle an anchor if present 38411// add a listener to on-page anchors to handle clicking on in-page anchors as well. 38412 38413 38414Object(_utility__WEBPACK_IMPORTED_MODULE_1__["handleAnchorHashJump"])(window.location.href); 38415 38416if (anchors.length > 0) {
38417 anchors.forEach(function (anchor) { 38418 anchor.addEventListener('click', _utility__WEBPACK_IMPORTED_MODULE_1__["handleAnchorHashJump"].bind(_this, anchor.href)); 38419 }); 38420} 38421 38422/***/ }), 38423
vendor: 4,184 bytes, lines 38424-38459
38424/***/ "./menu/mobileMenuController.js": 38425/*!**************************************!*\ 38426 !*** ./menu/mobileMenuController.js ***! 38427 \**************************************/ 38428/*! exports provided: default */ 38429/***/ (function(module, __webpack_exports__, __webpack_require__) { 38430 38431"use strict"; 38432__webpack_require__.r(__webpack_exports__); 38433/* harmony import */ var _upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuController */ "../../../upup-baseline/js/src/menu/menuController.js"); 38434/* harmony import */ var _mobileMenuItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mobileMenuItem */ "./menu/mobileMenuItem.js"); 38435function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38436 38437function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38438 38439function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38440 38441function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38442 38443function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } 38444 38445function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } 38446 38447function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38448 38449function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38450 38451function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 38452 38453function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 38454 38455function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 38456 38457function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 38458 38459function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o
38459) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 38460 38461 38462 38463/** 38464 * Specific methods for the mobile menu 38465 * Handles some special behavior for the submenus at the mobile size 38466 */ 38467 38468var MobileMenuController = /*#__PURE__*/function (_MenuController) { 38469 _inherits(MobileMenuController, _MenuController); 38470 38471 var _super = _createSuper(MobileMenuController); 38472 38473 function MobileMenuController() { 38474 _classCallCheck(this, MobileMenuController); 38475 38476 return _super.apply(this, arguments); 38477 } 38478 38479 _createClass(MobileMenuController, [{ 38480 key: "setup", 38481 38482 /** 38483 * set up the menu item objects 38484 */ 38485 value: function setup() { 38486 var _this = this; 38487 38488 this.menuItemObjects = this.menuItems.map(function (item) { 38489 return new _mobileMenuItem__WEBPACK_IMPORTED_MODULE_1__["default"](item, _this, { 38490 onSubmenuChange: _this.handleSubmenuChange.bind(_this) // this is a little confusing. Can't implicitly bind with inheritance? 38491 38492 }); 38493 }); // when setting up top-level, make sure first nav item is focusable to start out with 38494 38495 this.menuItemObjects.forEach(function (item) { 38496 return item.focusabilityOff(); 38497 }); 38498 this.menuItemObjects[0].focusabilityOn(); 38499 } 38500 /** 38501 * Pick up a change in a submenu (open or closed) 38502 * When one submenu opens, close the others and scroll to the selected one 38503 * @param menuItem 38504 * @param submenuState 38505 */ 38506 38507 }, { 38508 key: "handleSubmenuChange", 38509 value: function handleSubmenuChange(menuItem, submenuState) { 38510 // submenu has been opened 38511 if (submenuState === true) { 38512 // close other submenus 38513 this.menuItemObjects.forEach(function (object) { 38514 // this is the one we are responding to 38515 if (object.item === menuItem.item) { 38516 return; 38517 } 38518 38519 if (object.subMenu && object.subMenu.isActive) { 38520 object.closeSubMenu(); 38521 } 38522 }); // scroll menu container to the submenu that just opened 38523 // how to get the menu container? 38524 38525 var menuColumnContent = document.querySelector('.nav-panel__menu-column-content'), 38526 menuColumn = document.querySelector('.nav-panel__menu-column'), 38527 menuItemOffset = menuItem.item.offsetTop, 38528 scrollOptions = { 38529 left: 0, 38530 top: menuItemOffset, 38531 behavior: 'smooth' 38532 }; // TODO: this is a very specific adjustment for accessibility - is there a more flexible way to handle this? 38533 // magic number - scrolling is handled by different container at very small screen sizes 38534 38535 if (window.innerWidth < 350) { 38536 scrollOptions.behavior = 'auto'; 38537 menuColumn.scroll(scrollOptions); 38538 } else if (menuItem.isMobile()) { 38539 menuColumnContent.scroll(scrollOptions); 38540 } 38541 } 38542 } 38543 /** 38544 * When resetting primary menu focus 38545 * Allow the first item to be focused 38546 */ 38547 38548 }, { 38549 key: "resetFocus", 38550 value: function resetFocus() { 38551 _get(_getPrototypeOf(MobileMenuController.prototype), "resetFocus", this).call(this); 38552 38553 this.menuItemObjects[0].focusabilityOn(); 38554 } 38555 }]); 38556 38557 return MobileMenuController; 38558}(_upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__["default"]); 38559 38560/* harmony default export */ __webpack_exports__["default"] = (MobileMenuController); 38561 38562/***/ }), 38563
vendor: 4,844 bytes, lines 38564-38642
38564/***/ "./menu/mobileMenuItem.js": 38565/*!********************************!*\ 38566 !*** ./menu/mobileMenuItem.js ***! 38567 \********************************/ 38568/*! exports provided: default */ 38569/***/ (function(module, __webpack_exports__, __webpack_require__) { 38570 38571"use strict"; 38572__webpack_require__.r(__webpack_exports__); 38573/* harmony import */ var _upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuItem */ "../../../upup-baseline/js/src/menu/menuItem.js"); 38574/* harmony import */ var _upup_baseline_js_src_menu_verticalMenuController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/verticalMenuController */ "../../../upup-baseline/js/src/menu/verticalMenuController.js"); 38575function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38576 38577function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38578 38579function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38580 38581function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38582 38583function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38584 38585function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38586 38587function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 38588 38589function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 38590 38591function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 38592 38593function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 38594 38595function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 38596 38597 38598 38599/** 38600 * Item in the mobile menu 38601 * Also handles the submenu toggle buttons 38602 */ 38603 38604var mobileMenuItem = /*#__PURE__*/function (_MenuItem) { 38605 _inherits(mobileMenuItem, _MenuItem); 38606 38607 var _super = _createSuper(mobileMenuItem); 38608 38609 function mobileMenuItem() { 38610 _classCallCheck(this, mobileMenuItem); 38611 38612 return _super.apply(this, arguments); 38613 } 38614 38615 _createClass(mobileMenuItem, [{ 38616 key: "setup", 38617 38618 /** 38619 * Look for a submenu 38620 * If one is found, set it up with the proper constructor 38621 */ 38622 value: function setup() { 38623 var submenu = this.item.querySelector('.sub-menu'), 38624 toggle = this.item.querySelector('.mobile-nav-primary__subnav-toggle'); 38625 38626 if (submenu) { 38627 this.subMenu = new _upup_baseline_js_src_menu_verticalMenuController__WEBPACK_IMPORTED_MODULE_1__["default"](submenu, this); 38628 } 38629 38630 if (toggle) { 38631 this.submenuToggle = toggle; 38632 } 38633 } 38634 }, { 38635 key: "handleUp", 38636 value: function handleUp() { 38637 this.menu.focusPrevious(); 38638 } 38639 }, { 38640 key: "handleDown", 38641 value: function handleDown() { 38642 if (this.subMenu && this.subMenu.isActive) {
38643 this.subMenu.focusFirst(); 38644 } else { 38645 this.menu.focusNext(); 38646 } 38647 } 38648 }, { 38649 key: "handleLeft", 38650 value: function handleLeft() { 38651 if (!this.isMobile()) { 38652 this.focusSubmenuToggle(); 38653 } 38654 } 38655 }, { 38656 key: "handleRight", 38657 value: function handleRight() { 38658 if (this.isMobile()) { 38659 this.focusSubmenuToggle(); 38660 } 38661 } 38662 }, { 38663 key: "handleToggleRight", 38664 value: function handleToggleRight() { 38665 if (!this.isMobile()) { 38666 this.focus(); 38667 } 38668 } 38669 }, { 38670 key: "handleToggleLeft", 38671 value: function handleToggleLeft() { 38672 if (this.isMobile()) { 38673 this.focus(); 38674 } 38675 } 38676 }, { 38677 key: "handleToggleDown", 38678 value: function handleToggleDown() { 38679 if (this.subMenu) { 38680 if (!this.subMenu.isActive) { 38681 this.handleSubMenuToggle(); 38682 } 38683 38684 this.subMenu.focusFirst(); 38685 } 38686 } 38687 }]); 38688 38689 return mobileMenuItem; 38690}(_upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__["default"]); 38691 38692/* harmony default export */ __webpack_exports__["default"] = (mobileMenuItem); 38693 38694/***/ }), 38695
vendor: 4,191 bytes, lines 38696-38731
38696/***/ "./menu/primaryMenuController.js": 38697/*!***************************************!*\ 38698 !*** ./menu/primaryMenuController.js ***! 38699 \***************************************/ 38700/*! exports provided: default */ 38701/***/ (function(module, __webpack_exports__, __webpack_require__) { 38702 38703"use strict"; 38704__webpack_require__.r(__webpack_exports__); 38705/* harmony import */ var _upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuController */ "../../../upup-baseline/js/src/menu/menuController.js"); 38706/* harmony import */ var _primaryMenuItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./primaryMenuItem */ "./menu/primaryMenuItem.js"); 38707function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38708 38709function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38710 38711function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38712 38713function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38714 38715function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } 38716 38717function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } 38718 38719function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38720 38721function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38722 38723function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 38724 38725function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 38726 38727function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 38728 38729function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 38730 38731function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o
38731) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 38732 38733 38734 38735 38736var PrimaryMenuController = /*#__PURE__*/function (_MenuController) { 38737 _inherits(PrimaryMenuController, _MenuController); 38738 38739 var _super = _createSuper(PrimaryMenuController); 38740 38741 function PrimaryMenuController() { 38742 _classCallCheck(this, PrimaryMenuController); 38743 38744 return _super.apply(this, arguments); 38745 } 38746 38747 _createClass(PrimaryMenuController, [{ 38748 key: "setup", 38749 38750 /** 38751 * set up the menu item objects 38752 */ 38753 value: function setup() { 38754 var _this = this; 38755 38756 this.menuItemObjects = this.menuItems.map(function (item) { 38757 return new _primaryMenuItem__WEBPACK_IMPORTED_MODULE_1__["default"](item, _this); 38758 }); // when setting up top-level, make sure first nav item is focusable to start out with 38759 38760 this.menuItemObjects.forEach(function (item) { 38761 return item.focusabilityOff(); 38762 }); 38763 this.menuItemObjects[0].focusabilityOn(); 38764 } 38765 /** 38766 * When resetting primary menu focus 38767 * Allow the first item to be focused 38768 */ 38769 38770 }, { 38771 key: "resetFocus", 38772 value: function resetFocus() { 38773 _get(_getPrototypeOf(PrimaryMenuController.prototype), "resetFocus", this).call(this); 38774 38775 this.menuItemObjects[0].focusabilityOn(); 38776 } 38777 }]); 38778 38779 return PrimaryMenuController; 38780}(_upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__["default"]); 38781 38782/* harmony default export */ __webpack_exports__["default"] = (PrimaryMenuController); 38783 38784/***/ }), 38785
vendor: 3,740 bytes, lines 38786-38824
38786/***/ "./menu/primaryMenuItem.js": 38787/*!*********************************!*\ 38788 !*** ./menu/primaryMenuItem.js ***! 38789 \*********************************/ 38790/*! exports provided: default */ 38791/***/ (function(module, __webpack_exports__, __webpack_require__) { 38792 38793"use strict"; 38794__webpack_require__.r(__webpack_exports__); 38795/* harmony import */ var _upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuItem */ "../../../upup-baseline/js/src/menu/menuItem.js"); 38796/* harmony import */ var _secondaryMenuController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./secondaryMenuController */ "./menu/secondaryMenuController.js"); 38797function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38798 38799function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38800 38801function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38802 38803function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38804 38805function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38806 38807function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38808 38809function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 38810 38811function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 38812 38813function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 38814 38815function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 38816 38817function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 38818 38819 38820 38821 38822var primaryMenuItem = /*#__PURE__*/function (_MenuItem) { 38823 _inherits(primaryMenuItem, _MenuItem); 38824
38825 var _super = _createSuper(primaryMenuItem); 38826 38827 function primaryMenuItem() { 38828 _classCallCheck(this, primaryMenuItem); 38829 38830 return _super.apply(this, arguments); 38831 } 38832 38833 _createClass(primaryMenuItem, [{ 38834 key: "setup", 38835 38836 /** 38837 * Look for a submenu 38838 * If one is found, set it up with the proper constructor 38839 */ 38840 value: function setup() { 38841 var submenu = this.item.querySelector('.sub-menu'), 38842 toggle = this.item.querySelector('.primary-navigation__subnav-toggle'); 38843 38844 if (submenu) { 38845 this.subMenu = new _secondaryMenuController__WEBPACK_IMPORTED_MODULE_1__["default"](submenu, this); 38846 } 38847 38848 if (toggle) { 38849 this.submenuToggle = toggle; 38850 } 38851 } 38852 }, { 38853 key: "handleUp", 38854 value: function handleUp() { 38855 if (this.isMobile()) { 38856 this.menu.focusPrevious(); 38857 } else if (this.subMenu) { 38858 this.subMenu.focusLast(); 38859 } 38860 } 38861 }, { 38862 key: "handleDown", 38863 value: function handleDown() { 38864 // on mobile, only focus into a submenu if it is active 38865 if (this.isMobile()) { 38866 if (this.subMenu && this.subMenu.isActive) { 38867 this.subMenu.focusFirst(); 38868 } else { 38869 this.menu.focusNext(); 38870 } 38871 } else if (this.subMenu) { 38872 if (!this.subMenu.isActive) { 38873 this.item.classList.remove('dismissed'); 38874 this.handleSubMenuToggle(); 38875 } 38876 38877 this.subMenu.focusFirst(); 38878 } 38879 } 38880 }, { 38881 key: "handleLeft", 38882 value: function handleLeft() { 38883 if (this.isMobile()) { 38884 this.focusSubmenuToggle(); 38885 } else { 38886 this.menu.focusPrevious(); 38887 } 38888 } 38889 }, { 38890 key: "handleRight", 38891 value: function handleRight() { 38892 if (!this.isMobile()) { 38893 this.menu.focusNext(); 38894 } 38895 } 38896 }]); 38897 38898 return primaryMenuItem; 38899}(_upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__["default"]); 38900 38901/* harmony default export */ __webpack_exports__["default"] = (primary
38901MenuItem); 38902 38903/***/ }), 38904
vendor: 4,328 bytes, lines 38905-38963
38905/***/ "./menu/secondaryMenuController.js": 38906/*!*****************************************!*\ 38907 !*** ./menu/secondaryMenuController.js ***! 38908 \*****************************************/ 38909/*! exports provided: default */ 38910/***/ (function(module, __webpack_exports__, __webpack_require__) { 38911 38912"use strict"; 38913__webpack_require__.r(__webpack_exports__); 38914/* harmony import */ var _upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuController */ "../../../upup-baseline/js/src/menu/menuController.js"); 38915/* harmony import */ var _secondaryMenuItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./secondaryMenuItem */ "./menu/secondaryMenuItem.js"); 38916function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38917 38918function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38919 38920function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38921 38922function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38923 38924function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38925 38926function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38927 38928function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 38929 38930function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 38931 38932function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 38933 38934function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 38935 38936function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 38937 38938 38939 38940 38941var SecondaryMenuController = /*#__PURE__*/function (_MenuController) { 38942 _inherits(SecondaryMenuController, _MenuController); 38943 38944 var _super = _createSuper(SecondaryMenuController); 38945 38946 function SecondaryMenuController() { 38947 _classCallCheck(this, SecondaryMenuController); 38948 38949 return _super.apply(this, arguments); 38950 } 38951 38952 _createClass(SecondaryMenuController, [{ 38953 key: "setup", 38954 38955 /** 38956 * Get the menu items set up 38957 */ 38958 value: function setup() { 38959 var _this = this; 38960 38961 this.menuItemObjects = this.menuItems.map(function (item) { 38962 return new _secondaryMenuItem__WEBPACK_IMPORTED_MODULE_1__["default"](item, _this); 38963 });
38964 this.menuItemObjects.forEach(function (item) { 38965 return item.focusabilityOff(); 38966 }); 38967 } 38968 }]); 38969 38970 return SecondaryMenuController; 38971}(_upup_baseline_js_src_menu_menuController__WEBPACK_IMPORTED_MODULE_0__["default"]); 38972 38973/* harmony default export */ __webpack_exports__["default"] = (SecondaryMenuController); 38974 38975/***/ }), 38976
vendor: 4,644 bytes, lines 38977-39062
38977/***/ "./menu/secondaryMenuItem.js": 38978/*!***********************************!*\ 38979 !*** ./menu/secondaryMenuItem.js ***! 38980 \***********************************/ 38981/*! exports provided: default */ 38982/***/ (function(module, __webpack_exports__, __webpack_require__) { 38983 38984"use strict"; 38985__webpack_require__.r(__webpack_exports__); 38986/* harmony import */ var _upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/menu/menuItem */ "../../../upup-baseline/js/src/menu/menuItem.js"); 38987function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 38988 38989function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38990 38991function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 38992 38993function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 38994 38995function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 38996 38997function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 38998 38999function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39000 39001function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39002 39003function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39004 39005function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39006 39007function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 39008 39009 39010 39011var SecondaryMenuItem = /*#__PURE__*/function (_MenuItem) { 39012 _inherits(SecondaryMenuItem, _MenuItem); 39013 39014 var _super = _createSuper(SecondaryMenuItem); 39015 39016 function SecondaryMenuItem() { 39017 _classCallCheck(this, SecondaryMenuItem); 39018 39019 return _super.apply(this, arguments); 39020 } 39021 39022 _createClass(SecondaryMenuItem, [{ 39023 key: "handleUp", 39024 value: function handleUp() { 39025 this.menu.focusPrevious(); 39026 } 39027 }, { 39028 key: "handleDown", 39029 value: function handleDown() { 39030 this.menu.focusNext(); 39031 } 39032 /** 39033 * Will move to the previous item in the parent 39034 */ 39035 39036 }, { 39037 key: "handleLeft", 39038 value: function handleLeft() { 39039 if (!this.isMobile()) { 39040 this.menu.parentItem.menu.focusPrevious(); 39041 } 39042 } 39043 /** 39044 * Move to the next item in the parent 39045 */ 39046 39047 }, { 39048 key: "handleRight", 39049 value: function handleRight() { 39050 if (!this.isMobile()) { 39051 this.menu.parentItem.menu.focusNext(); 39052 } 39053 } 39054 }]); 39055 39056 return SecondaryMenuItem; 39057}(_upup_baseline_js_src_menu_menuItem__WEBPACK_IMPORTED_MODULE_0__["default"]); 39058 39059/* harmony default export */ __webpack_exports__["default"] = (SecondaryMenuItem); 39060 39061/***/ }), 39062
39063/***/ "./nav-panel.js": 39064/*!**********************!*\ 39065 !*** ./nav-panel.js ***! 39066 \**********************/ 39067/*! exports provided: default */ 39068/***/ (function(module, __webpack_exports__, __webpack_require__) { 39069 39070"use strict"; 39071__webpack_require__.r(__webpack_exports__); 39072/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39073/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39074/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../node_modules/react-dom/index.js"); 39075/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__); 39076/* harmony import */ var _search_search_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./search/search-container */ "./search/search-container.jsx"); 39077/* harmony import */ var _upup_baseline_js_src_menu_verticalMenuController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../upup-baseline/js/src/menu/verticalMenuController */ "../../../upup-baseline/js/src/menu/verticalMenuController.js"); 39078/* harmony import */ var _upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../upup-baseline/js/src/utility */ "../../../upup-baseline/js/src/utility.js"); 39079/* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utility */ "./utility.js"); 39080function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39081 39082function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39083 39084function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39085 39086function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 39087 39088 39089 39090 39091 39092 39093 39094/** 39095 * Handling for the nav panel 39096 * handle open, close and focus trap 39097 * Have some high-level control over the contained parts of the nav panel as well 39098 */ 39099 39100var navPanel = /*#__PURE__*/function () { 39101 function navPanel() { 39102 var _this = this; 39103 39104 _classCallCheck(this, navPanel); 39105 39106 _defineProperty(this, "onSearchActiveChange", function (searchActive) { 39107 if (searchActive) { 39108 _this.isSearchActive = true; 39109 39110 _this.mobileResourceMenuObjects.forEach(function (menu) { 39111 menu.focusOff(); 39112 }); 39113 } else if (!searchActive) { 39114 _this.isSearchActive = false; 39115 39116 _this.mobileResourceMenuObjects.forEach(function (menu) { 39117 menu.resetFocus(); 39118 }); 39119 } 39120 }); 39121 39122 _defineProperty(this, "handleIconClick", function (e) { 39123 if (!_this.isActive) { 39124 _this.activatePanel(); 39125 } 39126 }); 39127 39128 _defineProperty(this, "handleCloseButtonClick", function (e) { 39129 if (_this.isActive) { 39130 _this.deactivatePanel(); 39131 } 39132 }); 39133 39134 _defineProperty(this, "activatePanel", function () { 39135 if (_this.isActive) { 39136 return false; 39137 } 39138 39139 _this.panelIcon.classList.remove('focus-visible'); 39140 39141 _this.panelIcon.removeAttribute('data-focus-visible-added'); // using 2 classes with a time hiccup to keep panel hidden when not open 39142 39143 39144 _this.panel.classList.add('block'); 39145 39146 setTimeout(function () { 39147 _this.panel.classList.add('active'); 39148 39149 _this.isActive = true; 39150 }, 1); 39151 Object(_utility__WEBPACK_IMPORTED_MODULE_5__["setSearchHeaderHeight"])(); 39152 39153 _this.panelCloseButton.focus(); 39154 }); 39155 39156 _defineProperty(this, "deactivatePanel", function () { 39157 if (!_this.isActive) { 39158 return false;
39159 } 39160 39161 _this.panel.classList.remove('active'); 39162 39163 setTimeout(function () { 39164 _this.panel.classList.remove('block'); 39165 39166 _this.isActive = false; 39167 }, 250); // allow for transition out 39168 39169 setTimeout(function () { 39170 _this.panelIcon.focus(); // focus after marking the panel as inactive as not to trip the window focusin listener 39171 39172 39173 _this.panelIcon.classList.add('focus-visible'); 39174 39175 _this.panelIcon.setAttribute('data-focus-visible-added', ''); 39176 }, 250); 39177 }); 39178 39179 this.isActive = false; 39180 this.isSearchActive = false; 39181 this.panelIcon = document.querySelector('.site-header__nav-button'); 39182 this.panelCloseButton = document.querySelector('.nav-panel__container-close'); 39183 this.panel = document.querySelector('.nav-panel'); 39184 this.menuColumn = document.querySelector('.nav-panel__menu-column'); 39185 this.menuColumnContent = document.querySelector('.nav-panel__menu-column-content'); 39186 this.siteSearch = document.getElementById('site-search'); 39187 this.mobileResourcesMenus = Array.from(document.querySelectorAll('.mobile-resources-menu')); 39188 this.mobileResourceMenuObjects = []; // scrolling is handled differently inside the menu column at the smallest of screen sizes 39189 39190 Object(_upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_4__["containScroll"])(this.menuColumn); // only apply this restriction to inner container when window width > 350 39191 // this is to satisfy 1.4.10 - reflow - the bottom portion of the nav should not stick 39192 39193 Object(_upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_4__["containScroll"])(this.menuColumnContent, { 39194 x: function x(w) { 39195 return w > 350; 39196 }, 39197 y: function y(h) { 39198 return h > 0; 39199 } 39200 }); 39201 this.setup(); 39202 this.listen(); 39203 } 39204 /** 39205 * When the search is activated or de-activated 39206 * We need to disbale focus on the nav that shows up behind the search 39207 * @param searchActive 39208 */ 39209 39210 39211 _createClass(navPanel, [{ 39212 key: "setup", 39213 value: function setup() { 39214 // utility menus 39215 this.mobileResourceMenuObjects = this.mobileResourcesMenus.map(function (menu) { 39216 return new _upup_baseline_js_src_menu_verticalMenuController__WEBPACK_IMPORTED_MODULE_3__["default"](menu, null); 39217 }); // search experience 39218 39219 react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_search_search_container__WEBPACK_IMPORTED_MODULE_2__["default"], { 39220 logo: "/wp-content/themes/gardnerwebb-twenty/img/shield.svg", 39221 logoUrl: this.siteSearch.dataset.homeUrl, 39222 logoAlt: "Gardner-Webb University", 39223 endpoint: "/wp-json/gardner-webb/v1/site-search/", 39224 label: "Search Gardner Webb", 39225 onActiveChange: this.onSearchActiveChange 39226 }), this.siteSearch); 39227 } 39228 }, { 39229 key: "listen", 39230 value: function listen() { 39231 var _this2 = this; 39232 39233 this.panelIcon.addEventListener('click', this.handleIconClick); 39234 this.panelCloseButton.addEventListener('click', this.handleCloseButtonClick); // stop scrolling coming through the panel 39235 39236 this.panel.addEventListener('wheel', function (e) { 39237 return e.preventDefault(); 39238 }); 39239 this.panel.addEventListener('touchmove', function (e) { 39240 return e.preventDefault(); 39241 }); // close panel on escape 39242 39243 this.panel.addEventListener('keydown', function (e) { 39244 if (e.key === 'Esc' || e.key === 'Escape') { 39245 // other sub-controls should prevent bubbling of keypress 39246 // escape in the search panel has its own behavior 39247 if (!e.target.closest('#site-search') || !_this2.isSearchActive) { 39248 _this2.deactivatePanel(); 39249 } 39250 } 39251 }); // listen for focus events on the window 39252 // we can use this to gauge whether focus is inside the main nav panel or the search panel 39253 39254 window.addEventListener('focusin', function (e) { 39255 if (_this2.isActive && !e.target.closest(".nav-panel")) { 39256 _this2.panelCloseButton.focus(); 39257 39258 return; 39259 } // on mobile, the focus should not be able to leave the active search panel 39260 39261 39262 if (_this2.isMobile() && _this2.isActive && _this2.isSearchActive && !e.target.closest('#site-search')) { 39263 _this2.panelCloseButton.focus(); 39264 } 39265 }); 39266 } 39267 }, { 39268 key: "isMobile", 39269 39270 /** 39271 * Are we in the mobile view? 39272 * this will affect some re-focusing mechanisms 39273 */ 39274 value: function isMobile() { 39275 return window.innerWidth <= 992; 39276 } 39277 }]); 39278 39279 return navPanel; 39280}(); 39281 39282/* harmony default export */ __webpack_exports__["default"] = (navPanel); 39283 39284/***/ }), 39285
39286/***/ "./search/people-result.jsx": 39287/*!**********************************!*\ 39288 !*** ./search/people-result.jsx ***! 39289 \**********************************/ 39290/*! exports provided: default */ 39291/***/ (function(module, __webpack_exports__, __webpack_require__) { 39292 39293"use strict"; 39294__webpack_require__.r(__webpack_exports__); 39295/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39296/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39297function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 39298 39299function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39300 39301function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39302 39303function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39304 39305function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 39306 39307function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 39308 39309function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39310 39311function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39312 39313function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39314 39315function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39316 39317function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 39318 39319function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 39320 39321 39322 39323var PeopleResult = /*#__PURE__*/function (_React$Component) { 39324 _inherits(PeopleResult, _React$Component); 39325 39326 var _super = _createSuper(PeopleResult); 39327 39328 function PeopleResult(props) { 39329 var _this; 39330 39331 _classCallCheck(this, PeopleResult); 39332 39333 _this = _super.call(this, props); 39334 39335 _defineProperty(_assertThisInitialized(_this), "handleToggle", function (e) { 39336 // do not toggle on the link 39337 if (e.target.nodeName.toUpperCase() === 'A') { 39338 return; 39339 } 39340 39341 e.preventDefault(); 39342 e.stopPropagation(); 39343 39344 _this.setState({ 39345 collapsed: !_this.state.collapsed 39346 }); 39347 }); 39348 39349 _this.state = { 39350 collapsed: true 39351 }; 39352 return _this; 39353 } 39354 39355 _createClass(PeopleResult, [{ 39356 key: "render", 39357 value: function render() { 39358 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", { 39359 className: "people-search__person " + (!this.state.collapsed ? 'expanded' : ''), 39360 key: this.props.ID 39361 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39362 className: "people-search__name", 39363 onClick: this.handleToggle 39364 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 39365 href: this.props.permalink 39366 }, this.props.post_title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button", { 39367 "aria-label": "Toggle details for " + this.props.post_title, 39368 className: "people-search__expand", 39369 tabIndex: "0", 39370 onClick: this.handleToggle, 39371 "aria-expanded": !this.state.collapsed, 39372 "aria-controls": 'people_' + this.props.ID 39373 })), this._getDetails()); 39374 } 39375 }, { 39376 key: "_getDetails", 39377 value: function _getDetails() { 39378 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 39379 id: 'people_' + this.props.ID, 39380 className: "people-search__details" 39381 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", { 39382 className: "mb-0" 39383 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39384 style: { 39385 whiteSpace: 'pre-line' 39386 } 39387 }, this.props.people_meta.title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null, this.props.people_meta.phone), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null, this.props.people_meta.box), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39388 style: { 39389 whiteSpace: 'pre-line' 39390 } 39391 }, this.props.people_meta.address), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 39392 href: "mailto:" + this.props.people_meta.email 39393 }, this.props.people_meta.email))); 39394 } 39395 }]); 39396 39397 return PeopleResult; 39398}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component); 39399 39400/* harmony default export */ __webpack_exports__["default"] = (PeopleResult); 39401 39402/***/ }), 39403
vendor: 4,105 bytes, lines 39404-39439
39404/***/ "./search/people-search.jsx": 39405/*!**********************************!*\ 39406 !*** ./search/people-search.jsx ***! 39407 \**********************************/ 39408/*! exports provided: default */ 39409/***/ (function(module, __webpack_exports__, __webpack_require__) { 39410 39411"use strict"; 39412__webpack_require__.r(__webpack_exports__); 39413/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39414/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39415/* harmony import */ var _people_result__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./people-result */ "./search/people-result.jsx"); 39416/* harmony import */ var _upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/utility */ "../../../upup-baseline/js/src/utility.js"); 39417function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 39418 39419function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } 39420 39421function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39422 39423function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39424 39425function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39426 39427function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 39428 39429function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 39430 39431function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39432 39433function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39434 39435function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39436 39437function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39438 39439function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o
39439) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 39440 39441 39442 39443 39444/** 39445 * Search the people index 39446 * This data is loaded on mount and then searched locally for speed of return 39447 */ 39448 39449var PeopleSearch = /*#__PURE__*/function (_React$Component) { 39450 _inherits(PeopleSearch, _React$Component); 39451 39452 var _super = _createSuper(PeopleSearch); 39453 39454 function PeopleSearch(props) { 39455 var _this; 39456 39457 _classCallCheck(this, PeopleSearch); 39458 39459 _this = _super.call(this, props); 39460 _this.peopleContainerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef(); 39461 return _this; 39462 } 39463 /** 39464 * On mount, manage scroll within the people container 39465 */ 39466 39467 39468 _createClass(PeopleSearch, [{ 39469 key: "componentDidMount", 39470 value: function componentDidMount() { 39471 Object(_upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_2__["allowScrollWithinContainedScroll"])(this.peopleContainerRef.current); 39472 } 39473 }, { 39474 key: "render", 39475 value: function render() { 39476 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 39477 className: "people-search", 39478 ref: this.peopleContainerRef 39479 }, this._getInnner()); 39480 } // this is a little silly, but is for the ref - so it is always available 39481 39482 }, { 39483 key: "_getInnner", 39484 value: function _getInnner() { 39485 if (this.props.query && this.props.query.length >= 2) { 39486 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 39487 className: "people-search__inner" 39488 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", { 39489 id: "people-search__title", 39490 className: "people-search__title" 39491 }, "Directory Results"), this._getResults()); 39492 } 39493 } 39494 }, { 39495 key: "_getResults", 39496 value: function _getResults() { 39497 if (this.props.matches.length > 0) { 39498 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("ul", { 39499 "aria-labelledby": "people-search__title", 39500 className: "people-search__list" 39501 }, this.props.matches.map(function (person) { 39502 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_people_result__WEBPACK_IMPORTED_MODULE_1__["default"], _extends({ 39503 key: person.ID 39504 }, person)); 39505 })); 39506 } else { 39507 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null, "No matches for \"", this.props.query, "\" in the directory."); 39508 } 39509 } 39510 }]); 39511 39512 return PeopleSearch; 39513}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component); 39514 39515/* harmony default export */ __webpack_exports__["default"] = (PeopleSearch); 39516 39517/***/ }), 39518
vendor: 4,100 bytes, lines 39519-39554
39519/***/ "./search/search-container.jsx": 39520/*!*************************************!*\ 39521 !*** ./search/search-container.jsx ***! 39522 \*************************************/ 39523/*! exports provided: default */ 39524/***/ (function(module, __webpack_exports__, __webpack_require__) { 39525 39526"use strict"; 39527__webpack_require__.r(__webpack_exports__); 39528/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39529/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39530/* harmony import */ var _search_form__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./search-form */ "./search/search-form.jsx"); 39531/* harmony import */ var _search_results__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./search-results */ "./search/search-results.jsx"); 39532/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! superagent */ "../../node_modules/superagent/lib/client.js"); 39533/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(superagent__WEBPACK_IMPORTED_MODULE_3__); 39534function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 39535 39536function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39537 39538function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39539 39540function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39541 39542function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 39543 39544function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 39545 39546function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39547 39548function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39549 39550function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39551 39552function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39553 39554function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); };
39554 return _getPrototypeOf(o); } 39555 39556function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 39557 39558 39559 39560 39561 39562/** 39563 * Manage Searching 39564 * This portion should be re-usable for any search 39565 * It manages querying an endpoint, holding results and passing them down 39566 * Output/ formatting can be re-worked per instance 39567 */ 39568 39569var SearchContainer = /*#__PURE__*/function (_React$Component) { 39570 _inherits(SearchContainer, _React$Component); 39571 39572 var _super = _createSuper(SearchContainer); 39573 39574 function SearchContainer(props) { 39575 var _this; 39576 39577 _classCallCheck(this, SearchContainer); 39578 39579 _this = _super.call(this, props); 39580 39581 _defineProperty(_assertThisInitialized(_this), "handleSearchUpdate", function (e) { 39582 clearTimeout(_this.searchTimeout); 39583 var stateObject = { 39584 query: e.target.value 39585 }; // the user backed out the search query, mark state as not having searched 39586 39587 if (e.target.value === '') { 39588 stateObject['searched'] = false; 39589 stateObject['results'] = []; 39590 } 39591 39592 _this.setState(stateObject, function () { 39593 _this.searchTimeout = setTimeout(_this.getResults, 500); 39594 }); 39595 }); 39596 39597 _defineProperty(_assertThisInitialized(_this), "handleSearchClear", function (e) { 39598 _this.setState({ 39599 query: '', 39600 searched: '', 39601 results: [] 39602 }); 39603 }); 39604 39605 _defineProperty(_assertThisInitialized(_this), "getResults", function () { 39606 // don't search if there is nothing to search against 39607 if (_this.state.query === '') { 39608 return false; 39609 } 39610 39611 _this.setState({ 39612 searching: true 39613 }); 39614 39615 superagent__WEBPACK_IMPORTED_MODULE_3___default.a.get(_this.props.endpoint).set('Accept', 'application/json').query({ 39616 s: _this.state.query 39617 }).then(function (resp) { 39618 if (resp.body && resp.body.results) { 39619 _this.setState({ 39620 searching: false, 39621 searched: true, 39622 results: resp.body.results, 39623 results_count: resp.body.results_count 39624 }); 39625 } 39626 }).catch(function (err) { 39627 _this.setState({ 39628 searching: false, 39629 searched: true, 39630 error: err.response.body ? err.response.body.message : err.message 39631 }); 39632 }); 39633 }); 39634 39635 _this.state = { 39636 searching: false, 39637 searched: false, 39638 error: false, 39639 query: '', 39640 filters: [], 39641 // optional, pass term filters indexed by taxonomy 39642 results: [], 39643 results_count: 0, 39644 peopleIndex: [], 39645 peopleError: null 39646 }; 39647 _this.searchTimeout = null; 39648 return _this; 39649 } 39650 39651 _createClass(SearchContainer, [{ 39652 key: "componentDidUpdate", 39653 value: function componentDidUpdate(prevProps, prevState, snapshot) { 39654 if (this.state.searching || this.state.query) { 39655 this.props.onActiveChange(true); 39656 } else { 39657 this.props.onActiveChange(false); 39658 } 39659 } 39660 /** 39661 * On mount - load the people index 39662 */ 39663 39664 }, { 39665 key: "componentDidMount", 39666 value: function componentDidMount() { 39667 var _this2 = this; 39668 39669 superagent__WEBPACK_IMPORTED_MODULE_3___default.a.get('/wp-json/gardner-webb/v1/people-index/').set('Accept', 'application/json').then(function (resp) { 39670 _this2.setState({ 39671 peopleIndex: resp.body.results 39672 }); 39673 }).catch(function (err) { 39674 _this2.setState({ 39675 peopleError: err.response.body ? err.response.body.message : err.message 39676 }); 39677 }); 39678 } 39679 }, { 39680 key: "getPeopleMatches", 39681 39682 /** 39683 * Get matches for the people 39684 * @returns {*[]} 39685 */ 39686 value: function getPeopleMatches() { 39687 var _this3 = this; 39688 39689 var matched = []; 39690 matched = this.state.peopleIndex.filter(function (person) { 39691 return person.post_title.match(new RegExp(_this3.state.query, 'i')); 39692 }); 39693 return matched; 39694 } 39695 }, { 39696 key: "render", 39697 value: function render() { 39698 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_search_form__WEBPACK_IMPORTED_MODULE_1__["default"], { 39699 logo: this.props.logo, 39700 logoUrl: this.props.logoUrl, 39701 logoAlt: this.props.logoAlt, 39702 label: this.props.label, 39703 query: this.state.query, 39704 onChange: this.handleSearchUpdate, 39705 onClear: this.handleSearchClear 39706 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_search_results__WEBPACK_IMPORTED_MODULE_2__["default"], { 39707 query: this.state.query, 39708 searching: this.state.searching, 39709 searched: this.state.searched, 39710 results: this.state.results, 39711 results_count: this.state.results_count, 39712 onClear: this.handleSearchClear, 39713 peopleMatches: this.getPeopleMatches(), 39714 peopleError: this.state.peopleError 39715 })); 39716 } 39717 }]); 39718 39719 return SearchContainer; 39720}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component); 39721 39722/* harmony default export */ __webpack_exports__["default"] = (SearchContainer); 39723 39724/***/ }), 39725
39726/***/ "./search/search-form.jsx": 39727/*!********************************!*\ 39728 !*** ./search/search-form.jsx ***! 39729 \********************************/ 39730/*! exports provided: default */ 39731/***/ (function(module, __webpack_exports__, __webpack_require__) { 39732 39733"use strict"; 39734__webpack_require__.r(__webpack_exports__); 39735/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39736/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39737function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 39738 39739function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39740 39741function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39742 39743function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39744 39745function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 39746 39747function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 39748 39749function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39750 39751function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39752 39753function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39754 39755function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39756 39757function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 39758 39759function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 39760 39761 39762 39763var SearchForm = /*#__PURE__*/function (_React$Component) { 39764 _inherits(SearchForm, _React$Component); 39765 39766 var _super = _createSuper(SearchForm); 39767 39768 function SearchForm(props) { 39769 var _this; 39770 39771 _classCallCheck(this, SearchForm); 39772 39773 _this = _super.call(this, props); 39774 39775 _defineProperty(_assertThisInitialized(_this), "handleInputKeyDown", function (e) { 39776 if (e.key === 'Esc' || e.key === 'Escape') { 39777 _this.props.onClear(); 39778 } 39779 }); 39780 39781 _this.inputRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef(); 39782 return _this; 39783 } 39784 39785 _createClass(SearchForm, [{ 39786 key: "componentDidUpdate", 39787 value: function componentDidUpdate(prevProps, prevState, snapshot) { 39788 // handle focusing input when it is cleared of content 39789 if (this.props.query === '' && prevProps.query.length > 0) { 39790 this.inputRef.current.focus(); 39791 } 39792 } 39793 /** 39794 * allow results to be cleared when esc is pressed 39795 */ 39796 39797 }, { 39798 key: "render", 39799 value: function render() { 39800 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("header", { 39801 className: "site-search__header" 39802 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 39803 href: this.props.logoUrl 39804 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("img", { 39805 className: "site-search__logo", 39806 src: this.props.logo, 39807 alt: this.props.logoAlt 39808 })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("form", { 39809 role: "search", 39810 className: "site-search__form", 39811 method: "get", 39812 action: "/", 39813 "aria-label": "Site Search Form" 39814 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", { 39815 htmlFor: "site-search-input", 39816 className: "screen-reader-text" 39817 }, this.props.label), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 39818 onKeyDown: this.handleInputKeyDown, 39819 ref: this.inputRef, 39820 onChange: this.props.onChange, 39821 value: this.props.query, 39822 type: "search", 39823 autoComplete: "off", 39824 name: "s", 39825 id: "site-search-input", 39826 className: "site-search__input", 39827 placeholder: this.props.label 39828 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button", { 39829 className: "btn-reset site-search__submit", 39830 type: "submit", 39831 "aria-label": "Submit Search" 39832 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("svg", { 39833 className: "site-search__icon" 39834 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("use", { 39835 href: "#search", 39836 xlinkHref: "#search" 39837 }))), this._getClearButton())); 39838 } 39839 /** 39840 * Clear button 39841 * @private 39842 */ 39843 39844 }, { 39845 key: "_getClearButton", 39846 value: function _getClearButton() { 39847 if (this.props.query && this.props.query.length > 0) { 39848 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button", { 39849 onClick: this.props.onClear, 39850 className: "site-search__clear btn-reset" 39851 }, "CLEAR ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39852 className: "screen-reader-text" 39853 }, "Search Input")); 39854 } 39855 } 39856 }]); 39857 39858 return SearchForm; 39859}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component); 39860 39861/* harmony default export */ __webpack_exports__["default"] = (SearchForm); 39862 39863/***/ }), 39864
39865/***/ "./search/search-results.jsx": 39866/*!***********************************!*\ 39867 !*** ./search/search-results.jsx ***! 39868 \***********************************/ 39869/*! exports provided: default */ 39870/***/ (function(module, __webpack_exports__, __webpack_require__) { 39871 39872"use strict"; 39873__webpack_require__.r(__webpack_exports__); 39874/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js"); 39875/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 39876/* harmony import */ var _upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../upup-baseline/js/src/utility */ "../../../upup-baseline/js/src/utility.js"); 39877/* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utility */ "./utility.js"); 39878/* harmony import */ var _people_search__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./people-search */ "./search/people-search.jsx"); 39879function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 39880 39881function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39882 39883function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 39884 39885function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 39886 39887function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 39888 39889function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 39890 39891function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 39892 39893function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 39894 39895function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 39896 39897function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 39898 39899function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 39900 39901function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 39902 39903 39904 39905 39906 39907 39908var SearchResults = /*#__PURE__*/function (_React$Component) { 39909 _inherits(SearchResults, _React$Component); 39910 39911 var _super = _createSuper(SearchResults); 39912 39913 function SearchResults(props) { 39914 var _this; 39915 39916 _classCallCheck(this, SearchResults); 39917 39918 _this = _super.call(this, props); 39919 39920 _defineProperty(_assertThisInitialized(_this), "handleResultsKeyDown", function (e) { 39921 if (e.key === 'Esc' || e.key === 'Escape') { 39922 _this.props.onClear(); 39923 } 39924 }); 39925 39926 _this.resultsInnerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef(); 39927 _this.state = { 39928 peopleMatches: 0 39929 }; 39930 return _this; 39931 } 39932 39933 _createClass(SearchResults, [{ 39934 key: "componentDidMount", 39935 value: function componentDidMount() { 39936 Object(_upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_1__["containScroll"])(this.resultsInnerRef.current); 39937 } 39938 /** 39939 * Update matches found for the people 39940 * @param numberMatches 39941 */ 39942 39943 }, { 39944 key: "handlePeopleResultsUpdate", 39945 value: function handlePeopleResultsUpdate(numberMatches) { 39946 this.setState({ 39947 peopleMatches: numberMatches 39948 }); 39949 } 39950 /** 39951 * allow results to be cleared when esc is pressed 39952 */ 39953 39954 }, { 39955 key: "render", 39956 value: function render() { 39957 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 39958 className: "site-search__results-panel " + (this._getIsActive() ? 'active' : ''), 39959 onKeyDown: this.handleResultsKeyDown 39960 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 39961 ref: this.resultsInnerRef, 39962 className: "site-search__results-inner" 39963 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39964 className: "screen-reader-text", 39965 "aria-live": "polite" 39966 }, this._getLiveLabel()), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_people_search__WEBPACK_IMPORTED_MODULE_3__["default"], { 39967 matches: this.props.peopleMatches, 39968 query: this.props.query 39969 }), this._getResults())); 39970 } 39971 }, { 39972 key: "_getResults", 39973 value: function _getResults() { 39974 // only output results if active 39975 if (!this._getIsActive()) { 39976 return null; 39977 } 39978 39979 if (this.props.searching) { 39980 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", { 39981 className: "site-search__loading" 39982 }, "Searching...."); 39983 } 39984 39985 if (this.props.searched && this.props.results.length > 0) { 39986 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2", { 39987 className: "screen-reader-text" 39988 }, "Search Results"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("ul", { 39989 className: "site-search__results-list search-results-list" 39990 }, this.props.results.map(function (result) { 39991 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", { 39992 key: result.ID, 39993 className: "search-results-list__item" 39994 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 39995 href: result.permalink, 39996 "aria-labelledby": result.ID 39997 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 39998 className: "supercap search-results-list__supercap" 39999 }, result.post_type_name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h3", { 40000 id: result.ID, 40001 className: "search-results-list__title" 40002 }, result.post_title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", { 40003 className: "search-results-list__description" 40004 }, Object(_utility__WEBPACK_IMPORTED_MODULE_2__["decodeString"])(result.post_excerpt)))); 40005 })), this._getViewAllButton()); 40006 } 40007 40008 if (this.props.searched && this.props.results.length === 0) { 40009 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h3", null, "No Results Found"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", null, "Looks like nothing matched your search query."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 40010 href: "/", 40011 className: "btn btn--white" 40012 }, "Back to the home page", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("svg", { 40013 className: "btn__icon" 40014 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("use", { 40015 href: "#arrow-right", 40016 xlinkHref: "#arrow-right" 40017 })))); 40018 } 40019 40020 return null; 40021 } 40022 /** 40023 * Label to be read by screen reader 40024 * @private 40025 */ 40026 40027 }, { 40028 key: "_getLiveLabel", 40029 value: function _getLiveLabel() { 40030 var liveText = ''; 40031 40032 if (this.props.searching) { 40033 liveText = "Searching"; 40034 } else if (this.props.searched && this.props.results.length > 0) { 40035 liveText = this._getDirectoryLiveLabel(liveText); 40036 liveText += "Found " + this.props.results_count + " result" + (this.props.results_count > 1 ? 's ' : ' '); 40037 liveText += "across the site."; 40038 40039 if (this.props.results_count > this.props.results.length) { 40040 liveText += " Showing the first " + this.props.results.length + " results"; 40041 } 40042 } else if (this.props.searched && this.props.results.length === 0) { 40043 liveText = this._getDirectoryLiveLabel(liveText); 40044 liveText += "No results found across the site."; 40045 } 40046 40047 return liveText; 40048 } 40049 }, { 40050 key: "_getDirectoryLiveLabel", 40051 value: function _getDirectoryLiveLabel(liveText) { 40052 // make sure query is of adequate length - this check is in the directory display as well 40053 if (this.props.query.length >= 2) { 40054 if (this.props.peopleMatches.length > 0) { 40055 liveText += "Found " + this.props.peopleMatches.length + " result" + (this.props.peopleMatches.length > 1 ? 's' : '') + " in the directory. "; 40056 } else { 40057 liveText += "No results found in the directory. "; 40058 } 40059 } 40060 40061 return liveText; 40062 } 40063 }, { 40064 key: "_getViewAllButton", 40065 value: function _getViewAllButton() { 40066 // more found than are shown, go to the search results page 40067 if (this.props.results_count > this.props.results.length) { 40068 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 40069 href: "/?s=" + this.props.query, 40070 className: "search-results-list__button btn btn--white" 40071 }, "View All Results", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("svg", { 40072 className: "btn__icon" 40073 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("use", { 40074 href: "#arrow-right", 40075 xlinkHref: "#arrow-right" 40076 }))); 40077 } 40078 } 40079 /** 40080 * Check if the search panel is active 40081 * Will be considered active if a query string has been entered 40082 * @private 40083 */ 40084 40085 }, { 40086 key: "_getIsActive", 40087 value: function _getIsActive() { 40088 if (this.props.query && this.props.query.length > 0) { 40089 return true; 40090 } 40091 40092 return false;
40093 } 40094 }]); 40095 40096 return SearchResults; 40097}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component); 40098 40099/* harmony default export */ __webpack_exports__["default"] = (SearchResults); 40100 40101/***/ }), 40102
40103/***/ "./utility.js": 40104/*!********************!*\ 40105 !*** ./utility.js ***! 40106 \********************/ 40107/*! exports provided: setSearchHeaderHeight, handleAnchorHashJump, decodeString, decimalToUnicode, htmlEntityToUnicode */ 40108/***/ (function(module, __webpack_exports__, __webpack_require__) { 40109 40110"use strict"; 40111__webpack_require__.r(__webpack_exports__); 40112/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSearchHeaderHeight", function() { return setSearchHeaderHeight; }); 40113/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "handleAnchorHashJump", function() { return handleAnchorHashJump; }); 40114/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeString", function() { return decodeString; }); 40115/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decimalToUnicode", function() { return decimalToUnicode; }); 40116/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "htmlEntityToUnicode", function() { return htmlEntityToUnicode; }); 40117/* harmony import */ var _upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../upup-baseline/js/src/utility */ "../../../upup-baseline/js/src/utility.js"); 40118 40119function setSearchHeaderHeight() { 40120 var siteSearch = document.getElementById('site-search'), 40121 searchHeader = siteSearch.querySelector('.site-search__header'), 40122 searchHeaderHeight = searchHeader.offsetHeight; 40123 document.documentElement.style.setProperty('--searchHeaderHeight', searchHeaderHeight + 'px'); 40124} 40125/** 40126 * Handles anchor jumping behavior 40127 * This is to handle offset for the fixed header 40128 */ 40129 40130function handleAnchorHashJump(path) { 40131 // grab the hash 40132 // get the ID - look for this element on the page 40133 var link = document.createElement('a'), 40134 headerBottom = parseInt(document.documentElement.style.getPropertyValue('--headerBottom')), 40135 elem = null, 40136 offset = null; 40137 link.href = path; 40138 40139 if (link.hash) { 40140 elem = document.getElementById(link.hash.replace('#', '')); 40141 40142 if (elem) { 40143 offset = Object(_upup_baseline_js_src_utility__WEBPACK_IMPORTED_MODULE_0__["getElOffset"])(elem); // timing hiccup allows this to be applied after initial load/ behavior 40144 40145 setTimeout(function () { 40146 window.scrollTo({ 40147 top: offset.top - (headerBottom ? headerBottom : 100) - 32, 40148 // offset for the header 40149 left: offset.left 40150 }); 40151 }, 1); 40152 } 40153 } 40154} 40155function decodeString(incomingString) { 40156 return htmlEntityToUnicode(decimalToUnicode(incomingString)); 40157} 40158/** 40159 * Map decimal values to char codes and output string using the char code 40160 * Since decimal format uses char code natively, this will catch/ convert all decimal codes 40161 * React will escape this output before render 40162 * @param incomingString 40163 * @returns {*} 40164 */ 40165 40166function decimalToUnicode(incomingString) { 40167 return incomingString.replace(/&#(\w+);/gi, function (a, b) { 40168 var charCode = parseInt(b); 40169 return String.fromCharCode(charCode); 40170 }); 40171} 40172/** 40173 * Convert select html entities in strings to corresponding unicode characters. 40174 * The contained map can be expanded as additional characters are identified. 40175 * React will escape this output before render 40176 * @param incomingString 40177 * @returns {*} 40178 */ 40179 40180function htmlEntityToUnicode(incomingString) { 40181 var map = { 40182 'amp': 38, 40183 'nbsp': 160, 40184 'rsquo': 8217, 40185 'lsquo': 8216 40186 }; 40187 return incomingString.replace(/&(\w+);/gi, function (a, b) { 40188 if (map[b]) { 40189 return String.fromCharCode(map[b]); 40190 } // no mapped value, return the original 40191 40192 40193 return a; 40194 }); 40195} 40196 40197/***/ })
40197, 40198 40199/***/ 0: 40200/*!**********************!*\ 40201 !*** multi ./global ***! 40202 \**********************/ 40203/*! no static exports found */ 40204/***/ (function(module, exports, __webpack_require__) { 40205 40206module.exports = __webpack_require__(/*! ./global */"./global.jsx"); 40207 40208 40209/***/ }) 40210 40211/******/ });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.