1348 | | * All rights reserved. |
1349 | | * |
1350 | | * This source code is licensed under the BSD-style license found in the |
1351 | | * LICENSE file in the root directory of this source tree. An additional grant |
1352 | | * of patent rights can be found in the PATENTS file in the same directory. |
1353 | | * |
1354 | | * @typechecks |
1355 | | */ |
1356 | | |
1357 | | var invariant = require('./invariant'); |
1358 | | |
1359 | | /** |
1360 | | * Convert array-like objects to arrays. |
1361 | | * |
1362 | | * This API assumes the caller knows the contents of the data type. For less |
1363 | | * well defined inputs use createArrayFromMixed. |
1364 | | * |
1365 | | * @param {object|function|filelist} obj |
1366 | | * @return {array} |
1367 | | */ |
1368 | | function toArray(obj) { |
1369 | | var length = obj.length; |
1370 | | |
1371 | | // Some browsers builtin objects can report typeof 'function' (e.g. NodeList |
1372 | | // in old versions of Safari). |
1373 | | !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0; |
1374 | | |
1375 | | !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0; |
1376 | | |
1377 | | !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0; |
1378 | | |
1379 | | !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0; |
1380 | | |
1381 | | // Old IE doesn't give collections access to hasOwnProperty. Assume inputs |
1382 | | // without method will throw during the slice call and skip straight to the |
1383 | | // fallback. |
1384 | | if (obj.hasOwnProperty) { |
1385 | | try { |
1386 | | return Array.prototype.slice.call(obj); |
1387 | | } catch (e) { |
1388 | | // IE < 9 does not support Array#slice on collections objects |
1389 | | } |
1390 | | } |
1391 | | |
1392 | | // Fall back to copying key by key. This assumes all keys have a value, |
1393 | | // so will not preserve sparsely populated inputs. |
1394 | | var ret = Array(length); |
1395 | | for (var ii = 0; ii < length; ii++) { |
1396 | | ret[ii] = obj[ii]; |
1397 | | } |
1398 | | return ret; |
1399 | | } |
1400 | | |
1401 | | /** |
1402 | | * Perform a heuristic test to determine if an object is "array-like". |
1403 | | * |
1404 | | * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" |
1405 | | * Joshu replied: "Mu." |
1406 | | * |
1407 | | * This function determines if its argument has "array nature": it returns |
1408 | | * true if the argument is an actual array, an `arguments' object, or an |
1409 | | * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). |
1410 | | * |
1411 | | * It will return false for other array-like objects like Filelist. |
1412 | | * |
1413 | | * @param {*} obj |
1414 | | * @return {boolean} |
1415 | | */ |
1416 | | function hasArrayNature(obj) { |
1417 | | return ( |
1418 | | // not null/false |
1419 | | !!obj && ( |
1420 | | // arrays are objects, NodeLists are functions in Safari |
1421 | | typeof obj == 'object' || typeof obj == 'function') && |
1422 | | // quacks like an array |
1423 | | 'length' in obj && |
1424 | | // not window |
1425 | | !('setInterval' in obj) && |
1426 | | // no DOM node should be considered an array-like |
1427 | | // a 'select' element has 'length' and 'item' properties on IE8 |
1428 | | typeof obj.nodeType != 'number' && ( |
1429 | | // a real array |
1430 | | Array.isArray(obj) || |
1431 | | // arguments |
1432 | | 'callee' in obj || |
1433 | | // HTMLCollection/NodeList |
1434 | | 'item' in obj) |
1435 | | ); |
1436 | | } |
1437 | | |
1438 | | /** |
1439 | | * Ensure that the argument is an array by wrapping it in an array if it is not. |
1440 | | * Creates a copy of the argument if it is already an array. |
1441 | | * |
1442 | | * This is mostly useful idiomatically: |
1443 | | * |
1444 | | * var createArrayFromMixed = require('createArrayFromMixed'); |
1445 | | * |
1446 | | * function takesOneOrMoreThings(things) { |
1447 | | * things = createArrayFromMixed(things); |
1448 | | * ... |
1449 | | * } |
1450 | | * |
1451 | | * This allows you to treat `things' as an array, but accept scalars in the API. |
1452 | | * |
1453 | | * If you need to convert an array-like object, like `arguments`, into an array |
1454 | | * use toArray instead. |
1455 | | * |
1456 | | * @param {*} obj |
1457 | | * @return {array} |
1458 | | */ |
1459 | | function createArrayFromMixed(obj) { |
1460 | | if (!hasArrayNature(obj)) { |
1461 | | return [obj]; |
1462 | | } else if (Array.isArray(obj)) { |
1463 | | return obj.slice(); |
1464 | | } else { |
1465 | | return toArray(obj); |
1466 | | } |
1467 | | } |
1468 | | |
1469 | | module.exports = createArrayFromMixed; |
1470 | | }).call(this,require('_process')) |
1471 | | },{"./invariant":23,"_process":1}],14:[function(require,module,exports){ |
1472 | | (function (process){ |
1473 | | 'use strict'; |
1474 | | |
1475 | | /** |
1476 | | * Copyright (c) 2013-present, Facebook, Inc. |
1477 | | * All rights reserved. |
1478 | | * |
1479 | | * This source code is licensed under the BSD-style license found in the |
1480 | | * LICENSE file in the root directory of this source tree. An additional grant |
1481 | | * of patent rights can be found in the PATENTS file in the same directory. |
1482 | | * |
1483 | | * @typechecks |
1484 | | */ |
1485 | | |
1486 | | /*eslint-disable fb-www/unsafe-html*/ |
1487 | | |
1488 | | var ExecutionEnvironment = require('./ExecutionEnvironment'); |
1489 | | |
1490 | | var createArrayFromMixed = require('./createArrayFromMixed'); |
1491 | | var getMarkupWrap = require('./getMarkupWrap'); |
1492 | | var invariant = require('./invariant'); |
1493 | | |
1494 | | /** |
1495 | | * Dummy container used to render all markup. |
1496 | | */ |
1497 | | var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; |
1498 | | |
1499 | | /** |
1500 | | * Pattern used by `getNodeName`. |
1501 | | */ |
1502 | | var nodeNamePattern = /^\s*<(\w+)/; |
1503 | | |
1504 | | /** |
1505 | | * Extracts the `nodeName` of the first element in a string of markup. |
1506 | | * |
1507 | | * @param {string} markup String of markup. |
1508 | | * @return {?string} Node name of the supplied markup. |
1509 | | */ |
1510 | | function getNodeName(markup) { |
1511 | | var nodeNameMatch = markup.match(nodeNamePattern); |
1512 | | return nodeNameMatch && nodeNameMatch[1].toLowerCase(); |
1513 | | } |
1514 | | |
1515 | | /** |
1516 | | * Creates an array containing the nodes rendered from the supplied markup. The |
1517 | | * optionally supplied `handleScript` function will be invoked once for each |
1518 | | * <script> element that is rendered. If no `handleScript` function is supplied, |
1519 | | * an exception is thrown if any <script> elements are rendered. |
1520 | | * |
1521 | | * @param {string} markup A string of valid HTML markup. |
1522 | | * @param {?function} handleScript Invoked once for each rendered <script>. |
1523 | | * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes. |
1524 | | */ |
1525 | | function createNodesFromMarkup(markup, handleScript) { |
1526 | | var node = dummyNode; |
1527 | | !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : void 0; |
1528 | | var nodeName = getNodeName(markup); |
1529 | | |
1530 | | var wrap = nodeName && getMarkupWrap(nodeName); |
1531 | | if (wrap) { |
1532 | | node.innerHTML = wrap[1] + markup + wrap[2]; |
1533 | | |
1534 | | var wrapDepth = wrap[0]; |
1535 | | while (wrapDepth--) { |
1536 | | node = node.lastChild; |
1537 | | } |
1538 | | } else { |
1539 | | node.innerHTML = markup; |
1540 | | } |
1541 | | |
1542 | | var scripts = node.getElementsByTagName('script'); |
1543 | | if (scripts.length) { |
1544 | | !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : void 0; |
1545 | | createArrayFromMixed(scripts).forEach(handleScript); |
1546 | | } |
1547 | | |
1548 | | var nodes = Array.from(node.childNodes); |
1549 | | while (node.lastChild) { |
1550 | | node.removeChild(node.lastChild); |
1551 | | } |
1552 | | return nodes; |
1553 | | } |
1554 | | |
1555 | | module.exports = createNodesFromMarkup; |
1556 | | }).call(this,require('_process')) |
1557 | | },{"./ExecutionEnvironment":9,"./createArrayFromMixed":13,"./getMarkupWrap":19,"./invariant":23,"_process":1}],15:[function(require,module,exports){ |
1558 | | "use strict"; |
1559 | | |
1560 | | /** |
1561 | | * Copyright (c) 2013-present, Facebook, Inc. |
1562 | | * All rights reserved. |
1563 | | * |
1564 | | * This source code is licensed under the BSD-style license found in the |
1565 | | * LICENSE file in the root directory of this source tree. An additional grant |
1566 | | * of patent rights can be found in the PATENTS file in the same directory. |
| 1212 | * |
| 1213 | * This source code is licensed under the MIT license found in the |
| 1214 | * LICENSE file in the root directory of this source tree. |
1690 | | * All rights reserved. |
1691 | | * |
1692 | | * This source code is licensed under the BSD-style license found in the |
1693 | | * LICENSE file in the root directory of this source tree. An additional grant |
1694 | | * of patent rights can be found in the PATENTS file in the same directory. |
1695 | | * |
1696 | | */ |
1697 | | |
1698 | | /*eslint-disable fb-www/unsafe-html */ |
1699 | | |
1700 | | var ExecutionEnvironment = require('./ExecutionEnvironment'); |
1701 | | |
1702 | | var invariant = require('./invariant'); |
1703 | | |
1704 | | /** |
1705 | | * Dummy container used to detect which wraps are necessary. |
1706 | | */ |
1707 | | var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; |
1708 | | |
1709 | | /** |
1710 | | * Some browsers cannot use `innerHTML` to render certain elements standalone, |
1711 | | * so we wrap them, render the wrapped nodes, then extract the desired node. |
1712 | | * |
1713 | | * In IE8, certain elements cannot render alone, so wrap all elements ('*'). |
1714 | | */ |
1715 | | |
1716 | | var shouldWrap = {}; |
1717 | | |
1718 | | var selectWrap = [1, '<select multiple="true">', '</select>']; |
1719 | | var tableWrap = [1, '<table>', '</table>']; |
1720 | | var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>']; |
1721 | | |
1722 | | var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>']; |
1723 | | |
1724 | | var markupWrap = { |
1725 | | '*': [1, '?<div>', '</div>'], |
1726 | | |
1727 | | 'area': [1, '<map>', '</map>'], |
1728 | | 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], |
1729 | | 'legend': [1, '<fieldset>', '</fieldset>'], |
1730 | | 'param': [1, '<object>', '</object>'], |
1731 | | 'tr': [2, '<table><tbody>', '</tbody></table>'], |
1732 | | |
1733 | | 'optgroup': selectWrap, |
1734 | | 'option': selectWrap, |
1735 | | |
1736 | | 'caption': tableWrap, |
1737 | | 'colgroup': tableWrap, |
1738 | | 'tbody': tableWrap, |
1739 | | 'tfoot': tableWrap, |
1740 | | 'thead': tableWrap, |
1741 | | |
1742 | | 'td': trWrap, |
1743 | | 'th': trWrap |
1744 | | }; |
1745 | | |
1746 | | // Initialize the SVG elements since we know they'll always need to be wrapped |
1747 | | // consistently. If they are created inside a <div> they will be initialized in |
1748 | | // the wrong namespace (and will not display). |
1749 | | var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan']; |
1750 | | svgElements.forEach(function (nodeName) { |
1751 | | markupWrap[nodeName] = svgWrap; |
1752 | | shouldWrap[nodeName] = true; |
1753 | | }); |
1754 | | |
1755 | | /** |
1756 | | * Gets the markup wrap configuration for the supplied `nodeName`. |
1757 | | * |
1758 | | * NOTE: This lazily detects which wraps are necessary for the current browser. |
1759 | | * |
1760 | | * @param {string} nodeName Lowercase `nodeName`. |
1761 | | * @return {?array} Markup wrap configuration, if applicable. |
1762 | | */ |
1763 | | function getMarkupWrap(nodeName) { |
1764 | | !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : void 0; |
1765 | | if (!markupWrap.hasOwnProperty(nodeName)) { |
1766 | | nodeName = '*'; |
1767 | | } |
1768 | | if (!shouldWrap.hasOwnProperty(nodeName)) { |
1769 | | if (nodeName === '*') { |
1770 | | dummyNode.innerHTML = '<link />'; |
1771 | | } else { |
1772 | | dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>'; |
1773 | | } |
1774 | | shouldWrap[nodeName] = !dummyNode.firstChild; |
1775 | | } |
1776 | | return shouldWrap[nodeName] ? markupWrap[nodeName] : null; |
1777 | | } |
1778 | | |
1779 | | module.exports = getMarkupWrap; |
1780 | | }).call(this,require('_process')) |
1781 | | },{"./ExecutionEnvironment":9,"./invariant":23,"_process":1}],20:[function(require,module,exports){ |
1782 | | /** |
1783 | | * Copyright (c) 2013-present, Facebook, Inc. |
1784 | | * All rights reserved. |
1785 | | * |
1786 | | * This source code is licensed under the BSD-style license found in the |
1787 | | * LICENSE file in the root directory of this source tree. An additional grant |
1788 | | * of patent rights can be found in the PATENTS file in the same directory. |
1789 | | * |
1790 | | * @typechecks |
1791 | | */ |
1792 | | |
1793 | | 'use strict'; |
1794 | | |
1795 | | /** |
1796 | | * Gets the scroll position of the supplied element or window. |
1797 | | * |
1798 | | * The return values are unbounded, unlike `getScrollPosition`. This means they |
1799 | | * may be negative or exceed the element boundaries (which is possible using |
1800 | | * inertial scrolling). |
1801 | | * |
1802 | | * @param {DOMWindow|DOMElement} scrollable |
1803 | | * @return {object} Map with `x` and `y` keys. |
1804 | | */ |
1805 | | |
1806 | | function getUnboundedScrollPosition(scrollable) { |
1807 | | if (scrollable.Window && scrollable instanceof scrollable.Window) { |
1808 | | return { |
1809 | | x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft, |
1810 | | y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop |
1811 | | }; |
1812 | | } |
1813 | | return { |
1814 | | x: scrollable.scrollLeft, |
1815 | | y: scrollable.scrollTop |
1816 | | }; |
1817 | | } |
1818 | | |
1819 | | module.exports = getUnboundedScrollPosition; |
1820 | | },{}],21:[function(require,module,exports){ |
1821 | | 'use strict'; |
1822 | | |
1823 | | /** |
1824 | | * Copyright (c) 2013-present, Facebook, Inc. |
1825 | | * All rights reserved. |
1826 | | * |
1827 | | * This source code is licensed under the BSD-style license found in the |
1828 | | * LICENSE file in the root directory of this source tree. An additional grant |
1829 | | * of patent rights can be found in the PATENTS file in the same directory. |
| 1331 | * |
| 1332 | * This source code is licensed under the MIT license found in the |
| 1333 | * LICENSE file in the root directory of this source tree. |
2314 | | },{}],32:[function(require,module,exports){ |
| 1772 | },{}],26:[function(require,module,exports){ |
| 1773 | // shim for using process in browser |
| 1774 | var process = module.exports = {}; |
| 1775 | |
| 1776 | // cached from whatever global is present so that test runners that stub it |
| 1777 | // don't break things. But we need to wrap it in a try catch in case it is |
| 1778 | // wrapped in strict mode code which doesn't define any globals. It's inside a |
| 1779 | // function because try/catches deoptimize in certain engines. |
| 1780 | |
| 1781 | var cachedSetTimeout; |
| 1782 | var cachedClearTimeout; |
| 1783 | |
| 1784 | function defaultSetTimout() { |
| 1785 | throw new Error('setTimeout has not been defined'); |
| 1786 | } |
| 1787 | function defaultClearTimeout () { |
| 1788 | throw new Error('clearTimeout has not been defined'); |
| 1789 | } |
| 1790 | (function () { |
| 1791 | try { |
| 1792 | if (typeof setTimeout === 'function') { |
| 1793 | cachedSetTimeout = setTimeout; |
| 1794 | } else { |
| 1795 | cachedSetTimeout = defaultSetTimout; |
| 1796 | } |
| 1797 | } catch (e) { |
| 1798 | cachedSetTimeout = defaultSetTimout; |
| 1799 | } |
| 1800 | try { |
| 1801 | if (typeof clearTimeout === 'function') { |
| 1802 | cachedClearTimeout = clearTimeout; |
| 1803 | } else { |
| 1804 | cachedClearTimeout = defaultClearTimeout; |
| 1805 | } |
| 1806 | } catch (e) { |
| 1807 | cachedClearTimeout = defaultClearTimeout; |
| 1808 | } |
| 1809 | } ()) |
| 1810 | function runTimeout(fun) { |
| 1811 | if (cachedSetTimeout === setTimeout) { |
| 1812 | //normal enviroments in sane situations |
| 1813 | return setTimeout(fun, 0); |
| 1814 | } |
| 1815 | // if setTimeout wasn't available but was latter defined |
| 1816 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
| 1817 | cachedSetTimeout = setTimeout; |
| 1818 | return setTimeout(fun, 0); |
| 1819 | } |
| 1820 | try { |
| 1821 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 1822 | return cachedSetTimeout(fun, 0); |
| 1823 | } catch(e){ |
| 1824 | try { |
| 1825 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 1826 | return cachedSetTimeout.call(null, fun, 0); |
| 1827 | } catch(e){ |
| 1828 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error |
| 1829 | return cachedSetTimeout.call(this, fun, 0); |
| 1830 | } |
| 1831 | } |
| 1832 | |
| 1833 | |
| 1834 | } |
| 1835 | function runClearTimeout(marker) { |
| 1836 | if (cachedClearTimeout === clearTimeout) { |
| 1837 | //normal enviroments in sane situations |
| 1838 | return clearTimeout(marker); |
| 1839 | } |
| 1840 | // if clearTimeout wasn't available but was latter defined |
| 1841 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
| 1842 | cachedClearTimeout = clearTimeout; |
| 1843 | return clearTimeout(marker); |
| 1844 | } |
| 1845 | try { |
| 1846 | // when when somebody has screwed with setTimeout but no I.E. maddness |
| 1847 | return cachedClearTimeout(marker); |
| 1848 | } catch (e){ |
| 1849 | try { |
| 1850 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
| 1851 | return cachedClearTimeout.call(null, marker); |
| 1852 | } catch (e){ |
| 1853 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. |
| 1854 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout |
| 1855 | return cachedClearTimeout.call(this, marker); |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | |
| 1860 | |
| 1861 | } |
| 1862 | var queue = []; |
| 1863 | var draining = false; |
| 1864 | var currentQueue; |
| 1865 | var queueIndex = -1; |
| 1866 | |
| 1867 | function cleanUpNextTick() { |
| 1868 | if (!draining || !currentQueue) { |
| 1869 | return; |
| 1870 | } |
| 1871 | draining = false; |
| 1872 | if (currentQueue.length) { |
| 1873 | queue = currentQueue.concat(queue); |
| 1874 | } else { |
| 1875 | queueIndex = -1; |
| 1876 | } |
| 1877 | if (queue.length) { |
| 1878 | drainQueue(); |
| 1879 | } |
| 1880 | } |
| 1881 | |
| 1882 | function drainQueue() { |
| 1883 | if (draining) { |
| 1884 | return; |
| 1885 | } |
| 1886 | var timeout = runTimeout(cleanUpNextTick); |
| 1887 | draining = true; |
| 1888 | |
| 1889 | var len = queue.length; |
| 1890 | while(len) { |
| 1891 | currentQueue = queue; |
| 1892 | queue = []; |
| 1893 | while (++queueIndex < len) { |
| 1894 | if (currentQueue) { |
| 1895 | currentQueue[queueIndex].run(); |
| 1896 | } |
| 1897 | } |
| 1898 | queueIndex = -1; |
| 1899 | len = queue.length; |
| 1900 | } |
| 1901 | currentQueue = null; |
| 1902 | draining = false; |
| 1903 | runClearTimeout(timeout); |
| 1904 | } |
| 1905 | |
| 1906 | process.nextTick = function (fun) { |
| 1907 | var args = new Array(arguments.length - 1); |
| 1908 | if (arguments.length > 1) { |
| 1909 | for (var i = 1; i < arguments.length; i++) { |
| 1910 | args[i - 1] = arguments[i]; |
| 1911 | } |
| 1912 | } |
| 1913 | queue.push(new Item(fun, args)); |
| 1914 | if (queue.length === 1 && !draining) { |
| 1915 | runTimeout(drainQueue); |
| 1916 | } |
| 1917 | }; |
| 1918 | |
| 1919 | // v8 likes predictible objects |
| 1920 | function Item(fun, array) { |
| 1921 | this.fun = fun; |
| 1922 | this.array = array; |
| 1923 | } |
| 1924 | Item.prototype.run = function () { |
| 1925 | this.fun.apply(null, this.array); |
| 1926 | }; |
| 1927 | process.title = 'browser'; |
| 1928 | process.browser = true; |
| 1929 | process.env = {}; |
| 1930 | process.argv = []; |
| 1931 | process.version = ''; // empty string to avoid regexp issues |
| 1932 | process.versions = {}; |
| 1933 | |
| 1934 | function noop() {} |
| 1935 | |
| 1936 | process.on = noop; |
| 1937 | process.addListener = noop; |
| 1938 | process.once = noop; |
| 1939 | process.off = noop; |
| 1940 | process.removeListener = noop; |
| 1941 | process.removeAllListeners = noop; |
| 1942 | process.emit = noop; |
| 1943 | process.prependListener = noop; |
| 1944 | process.prependOnceListener = noop; |
| 1945 | |
| 1946 | process.listeners = function (name) { return [] } |
| 1947 | |
| 1948 | process.binding = function (name) { |
| 1949 | throw new Error('process.binding is not supported'); |
| 1950 | }; |
| 1951 | |
| 1952 | process.cwd = function () { return '/' }; |
| 1953 | process.chdir = function (dir) { |
| 1954 | throw new Error('process.chdir is not supported'); |
| 1955 | }; |
| 1956 | process.umask = function() { return 0; }; |
| 1957 | |
| 1958 | },{}],27:[function(require,module,exports){ |
| 2706 | /** |
| 2707 | * Deprecated: An an easy way to express two-way binding with React. |
| 2708 | * See https://facebook.github.io/react/docs/two-way-binding-helpers.html |
| 2709 | * |
| 2710 | * @param {*} value current value of the link |
| 2711 | * @param {function} requestChange callback to request a change |
| 2712 | */ |
| 2713 | function ReactLink(value, requestChange) { |
| 2714 | this.value = value; |
| 2715 | this.requestChange = requestChange; |
| 2716 | } |
| 2717 | |
| 2718 | var ReactStateSetters = { |
| 2719 | /** |
| 2720 | * Returns a function that calls the provided function, and uses the result |
| 2721 | * of that to set the component's state. |
| 2722 | * |
| 2723 | * @param {ReactCompositeComponent} component |
| 2724 | * @param {function} funcReturningState Returned callback uses this to |
| 2725 | * determine how to update state. |
| 2726 | * @return {function} callback that when invoked uses funcReturningState to |
| 2727 | * determined the object literal to setState. |
| 2728 | */ |
| 2729 | createStateSetter: function(component, funcReturningState) { |
| 2730 | return function(a, b, c, d, e, f) { |
| 2731 | var partialState = funcReturningState.call(component, a, b, c, d, e, f); |
| 2732 | if (partialState) { |
| 2733 | component.setState(partialState); |
| 2734 | } |
| 2735 | }; |
| 2736 | }, |
| 2737 | |
| 2738 | /** |
| 2739 | * Returns a single-argument callback that can be used to update a single |
| 2740 | * key in the component's state. |
| 2741 | * |
| 2742 | * Note: this is memoized function, which makes it inexpensive to call. |
| 2743 | * |
| 2744 | * @param {ReactCompositeComponent} component |
| 2745 | * @param {string} key The key in the state that you should update. |
| 2746 | * @return {function} callback of 1 argument which calls setState() with |
| 2747 | * the provided keyName and callback argument. |
| 2748 | */ |
| 2749 | createStateKeySetter: function(component, key) { |
| 2750 | // Memoize the setters. |
| 2751 | var cache = component.__keySetters || (component.__keySetters = {}); |
| 2752 | return cache[key] || (cache[key] = createStateKeySetter(component, key)); |
| 2753 | } |
| 2754 | }; |
| 2755 | |
| 2756 | function createStateKeySetter(component, key) { |
| 2757 | // Partial state is allocated outside of the function closure so it can be |
| 2758 | // reused with every call, avoiding memory allocation when this function |
| 2759 | // is called. |
| 2760 | var partialState = {}; |
| 2761 | return function stateKeySetter(value) { |
| 2762 | partialState[key] = value; |
| 2763 | component.setState(partialState); |
| 2764 | }; |
| 2765 | } |
| 2766 | |
| 2767 | ReactStateSetters.Mixin = { |
| 2768 | /** |
| 2769 | * Returns a function that calls the provided function, and uses the result |
| 2770 | * of that to set the component's state. |
| 2771 | * |
| 2772 | * For example, these statements are equivalent: |
| 2773 | * |
| 2774 | * this.setState({x: 1}); |
| 2775 | * this.createStateSetter(function(xValue) { |
| 2776 | * return {x: xValue}; |
| 2777 | * })(1); |
| 2778 | * |
| 2779 | * @param {function} funcReturningState Returned callback uses this to |
| 2780 | * determine how to update state. |
| 2781 | * @return {function} callback that when invoked uses funcReturningState to |
| 2782 | * determined the object literal to setState. |
| 2783 | */ |
| 2784 | createStateSetter: function(funcReturningState) { |
| 2785 | return ReactStateSetters.createStateSetter(this, funcReturningState); |
| 2786 | }, |
| 2787 | |
| 2788 | /** |
| 2789 | * Returns a single-argument callback that can be used to update a single |
| 2790 | * key in the component's state. |
| 2791 | * |
| 2792 | * For example, these statements are equivalent: |
| 2793 | * |
| 2794 | * this.setState({x: 1}); |
| 2795 | * this.createStateKeySetter('x')(1); |
| 2796 | * |
| 2797 | * Note: this is memoized function, which makes it inexpensive to call. |
| 2798 | * |
| 2799 | * @param {string} key The key in the state that you should update. |
| 2800 | * @return {function} callback of 1 argument which calls setState() with |
| 2801 | * the provided keyName and callback argument. |
| 2802 | */ |
| 2803 | createStateKeySetter: function(key) { |
| 2804 | return ReactStateSetters.createStateKeySetter(this, key); |
| 2805 | } |
| 2806 | }; |
| 2807 | |
| 2808 | /** |
| 2809 | * A simple mixin around ReactLink.forState(). |
| 2810 | * See https://facebook.github.io/react/docs/two-way-binding-helpers.html |
| 2811 | */ |
| 2812 | var LinkedStateMixin = { |
| 2813 | /** |
| 2814 | * Create a ReactLink that's linked to part of this component's state. The |
| 2815 | * ReactLink will have the current value of this.state[key] and will call |
| 2816 | * setState() when a change is requested. |
| 2817 | * |
| 2818 | * @param {string} key state key to update. |
| 2819 | * @return {ReactLink} ReactLink instance linking to the state. |
| 2820 | */ |
| 2821 | linkState: function(key) { |
| 2822 | return new ReactLink( |
| 2823 | this.state[key], |
| 2824 | ReactStateSetters.createStateKeySetter(this, key) |
| 2825 | ); |
| 2826 | } |
| 2827 | }; |
| 2828 | |
| 2829 | module.exports = LinkedStateMixin; |
| 2830 | |
| 2831 | },{}],33:[function(require,module,exports){ |
| 2832 | (function (process){ |
| 2833 | /** @license React v16.0.0 |
| 2834 | * react-dom.development.js |
| 2835 | * |
| 2836 | * Copyright (c) 2013-present, Facebook, Inc. |
| 2837 | * |
| 2838 | * This source code is licensed under the MIT license found in the |
| 2839 | * LICENSE file in the root directory of this source tree. |
| 2840 | */ |
3047 | | var ARIADOMPropertyConfig = { |
3048 | | Properties: { |
3049 | | // Global States and Properties |
3050 | | 'aria-current': 0, // state |
3051 | | 'aria-details': 0, |
3052 | | 'aria-disabled': 0, // state |
3053 | | 'aria-hidden': 0, // state |
3054 | | 'aria-invalid': 0, // state |
3055 | | 'aria-keyshortcuts': 0, |
3056 | | 'aria-label': 0, |
3057 | | 'aria-roledescription': 0, |
3058 | | // Widget Attributes |
3059 | | 'aria-autocomplete': 0, |
3060 | | 'aria-checked': 0, |
3061 | | 'aria-expanded': 0, |
3062 | | 'aria-haspopup': 0, |
3063 | | 'aria-level': 0, |
3064 | | 'aria-modal': 0, |
3065 | | 'aria-multiline': 0, |
3066 | | 'aria-multiselectable': 0, |
3067 | | 'aria-orientation': 0, |
3068 | | 'aria-placeholder': 0, |
3069 | | 'aria-pressed': 0, |
3070 | | 'aria-readonly': 0, |
3071 | | 'aria-required': 0, |
3072 | | 'aria-selected': 0, |
3073 | | 'aria-sort': 0, |
3074 | | 'aria-valuemax': 0, |
3075 | | 'aria-valuemin': 0, |
3076 | | 'aria-valuenow': 0, |
3077 | | 'aria-valuetext': 0, |
3078 | | // Live Region Attributes |
3079 | | 'aria-atomic': 0, |
3080 | | 'aria-busy': 0, |
3081 | | 'aria-live': 0, |
3082 | | 'aria-relevant': 0, |
3083 | | // Drag-and-Drop Attributes |
3084 | | 'aria-dropeffect': 0, |
3085 | | 'aria-grabbed': 0, |
3086 | | // Relationship Attributes |
3087 | | 'aria-activedescendant': 0, |
3088 | | 'aria-colcount': 0, |
3089 | | 'aria-colindex': 0, |
3090 | | 'aria-colspan': 0, |
3091 | | 'aria-controls': 0, |
3092 | | 'aria-describedby': 0, |
3093 | | 'aria-errormessage': 0, |
3094 | | 'aria-flowto': 0, |
3095 | | 'aria-labelledby': 0, |
3096 | | 'aria-owns': 0, |
3097 | | 'aria-posinset': 0, |
3098 | | 'aria-rowcount': 0, |
3099 | | 'aria-rowindex': 0, |
3100 | | 'aria-rowspan': 0, |
3101 | | 'aria-setsize': 0 |
| 2843 | |
| 2844 | if (process.env.NODE_ENV !== "production") { |
| 2845 | (function() { |
| 2846 | |
| 2847 | 'use strict'; |
| 2848 | |
| 2849 | var react = require('react'); |
| 2850 | var invariant = require('fbjs/lib/invariant'); |
| 2851 | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); |
| 2852 | var _assign = require('object-assign'); |
| 2853 | var EventListener = require('fbjs/lib/EventListener'); |
| 2854 | var require$$0 = require('fbjs/lib/warning'); |
| 2855 | var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName'); |
| 2856 | var emptyFunction = require('fbjs/lib/emptyFunction'); |
| 2857 | var camelizeStyleName = require('fbjs/lib/camelizeStyleName'); |
| 2858 | var performanceNow = require('fbjs/lib/performanceNow'); |
| 2859 | var propTypes = require('prop-types'); |
| 2860 | var emptyObject = require('fbjs/lib/emptyObject'); |
| 2861 | var checkPropTypes = require('prop-types/checkPropTypes'); |
| 2862 | var shallowEqual = require('fbjs/lib/shallowEqual'); |
| 2863 | var containsNode = require('fbjs/lib/containsNode'); |
| 2864 | var focusNode = require('fbjs/lib/focusNode'); |
| 2865 | var getActiveElement = require('fbjs/lib/getActiveElement'); |
| 2866 | |
| 2867 | /** |
| 2868 | * Copyright (c) 2013-present, Facebook, Inc. |
| 2869 | * |
| 2870 | * This source code is licensed under the MIT license found in the |
| 2871 | * LICENSE file in the root directory of this source tree. |
| 2872 | * |
| 2873 | * @providesModule reactProdInvariant |
| 2874 | * |
| 2875 | */ |
| 2876 | |
| 2877 | /** |
| 2878 | * Copyright (c) 2013-present, Facebook, Inc. |
| 2879 | * |
| 2880 | * This source code is licensed under the MIT license found in the |
| 2881 | * LICENSE file in the root directory of this source tree. |
| 2882 | * |
| 2883 | * @providesModule checkReact |
| 2884 | * |
| 2885 | */ |
| 2886 | |
| 2887 | |
| 2888 | |
| 2889 | |
| 2890 | !react ? invariant(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0; |
| 2891 | |
| 2892 | /** |
| 2893 | * Copyright (c) 2013-present, Facebook, Inc. |
| 2894 | * |
| 2895 | * This source code is licensed under the MIT license found in the |
| 2896 | * LICENSE file in the root directory of this source tree. |
| 2897 | * |
| 2898 | * @providesModule DOMNamespaces |
| 2899 | */ |
| 2900 | |
| 2901 | var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; |
| 2902 | var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; |
| 2903 | var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; |
| 2904 | |
| 2905 | var Namespaces = { |
| 2906 | html: HTML_NAMESPACE, |
| 2907 | mathml: MATH_NAMESPACE, |
| 2908 | svg: SVG_NAMESPACE |
| 2909 | }; |
| 2910 | |
| 2911 | // Assumes there is no parent namespace. |
| 2912 | function getIntrinsicNamespace(type) { |
| 2913 | switch (type) { |
| 2914 | case 'svg': |
| 2915 | return SVG_NAMESPACE; |
| 2916 | case 'math': |
| 2917 | return MATH_NAMESPACE; |
| 2918 | default: |
| 2919 | return HTML_NAMESPACE; |
| 2920 | } |
| 2921 | } |
| 2922 | |
| 2923 | function getChildNamespace$1(parentNamespace, type) { |
| 2924 | if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { |
| 2925 | // No (or default) parent namespace: potential entry point. |
| 2926 | return getIntrinsicNamespace(type); |
| 2927 | } |
| 2928 | if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { |
| 2929 | // We're leaving SVG. |
| 2930 | return HTML_NAMESPACE; |
| 2931 | } |
| 2932 | // By default, pass namespace below. |
| 2933 | return parentNamespace; |
| 2934 | } |
| 2935 | |
| 2936 | var Namespaces_1 = Namespaces; |
| 2937 | var getIntrinsicNamespace_1 = getIntrinsicNamespace; |
| 2938 | var getChildNamespace_1 = getChildNamespace$1; |
| 2939 | |
| 2940 | var DOMNamespaces = { |
| 2941 | Namespaces: Namespaces_1, |
| 2942 | getIntrinsicNamespace: getIntrinsicNamespace_1, |
| 2943 | getChildNamespace: getChildNamespace_1 |
| 2944 | }; |
| 2945 | |
| 2946 | /** |
| 2947 | * Injectable ordering of event plugins. |
| 2948 | */ |
| 2949 | var eventPluginOrder = null; |
| 2950 | |
| 2951 | /** |
| 2952 | * Injectable mapping from names to event plugin modules. |
| 2953 | */ |
| 2954 | var namesToPlugins = {}; |
| 2955 | |
| 2956 | /** |
| 2957 | * Recomputes the plugin list using the injected plugins and plugin ordering. |
| 2958 | * |
| 2959 | * @private |
| 2960 | */ |
| 2961 | function recomputePluginOrdering() { |
| 2962 | if (!eventPluginOrder) { |
| 2963 | // Wait until an `eventPluginOrder` is injected. |
| 2964 | return; |
| 2965 | } |
| 2966 | for (var pluginName in namesToPlugins) { |
| 2967 | var pluginModule = namesToPlugins[pluginName]; |
| 2968 | var pluginIndex = eventPluginOrder.indexOf(pluginName); |
| 2969 | !(pluginIndex > -1) ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0; |
| 2970 | if (EventPluginRegistry.plugins[pluginIndex]) { |
| 2971 | continue; |
| 2972 | } |
| 2973 | !pluginModule.extractEvents ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0; |
| 2974 | EventPluginRegistry.plugins[pluginIndex] = pluginModule; |
| 2975 | var publishedEvents = pluginModule.eventTypes; |
| 2976 | for (var eventName in publishedEvents) { |
| 2977 | !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0; |
| 2978 | } |
| 2979 | } |
| 2980 | } |
| 2981 | |
| 2982 | /** |
| 2983 | * Publishes an event so that it can be dispatched by the supplied plugin. |
| 2984 | * |
| 2985 | * @param {object} dispatchConfig Dispatch configuration for the event. |
| 2986 | * @param {object} PluginModule Plugin publishing the event. |
| 2987 | * @return {boolean} True if the event was successfully published. |
| 2988 | * @private |
| 2989 | */ |
| 2990 | function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { |
| 2991 | !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0; |
| 2992 | EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig; |
| 2993 | |
| 2994 | var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; |
| 2995 | if (phasedRegistrationNames) { |
| 2996 | for (var phaseName in phasedRegistrationNames) { |
| 2997 | if (phasedRegistrationNames.hasOwnProperty(phaseName)) { |
| 2998 | var phasedRegistrationName = phasedRegistrationNames[phaseName]; |
| 2999 | publishRegistrationName(phasedRegistrationName, pluginModule, eventName); |
| 3000 | } |
| 3001 | } |
| 3002 | return true; |
| 3003 | } else if (dispatchConfig.registrationName) { |
| 3004 | publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); |
| 3005 | return true; |
| 3006 | } |
| 3007 | return false; |
| 3008 | } |
| 3009 | |
| 3010 | /** |
| 3011 | * Publishes a registration name that is used to identify dispatched events. |
| 3012 | * |
| 3013 | * @param {string} registrationName Registration name to add. |
| 3014 | * @param {object} PluginModule Plugin publishing the event. |
| 3015 | * @private |
| 3016 | */ |
| 3017 | function publishRegistrationName(registrationName, pluginModule, eventName) { |
| 3018 | !!EventPluginRegistry.registrationNameModules[registrationName] ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0; |
| 3019 | EventPluginRegistry.registrationNameModules[registrationName] = pluginModule; |
| 3020 | EventPluginRegistry.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; |
| 3021 | |
| 3022 | { |
| 3023 | var lowerCasedName = registrationName.toLowerCase(); |
| 3024 | EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName; |
| 3025 | |
| 3026 | if (registrationName === 'onDoubleClick') { |
| 3027 | EventPluginRegistry.possibleRegistrationNames.ondblclick = registrationName; |
| 3028 | } |
| 3029 | } |
| 3030 | } |
| 3031 | |
| 3032 | /** |
| 3033 | * Registers plugins so that they can extract and dispatch events. |
| 3034 | * |
| 3035 | * @see {EventPluginHub} |
| 3036 | */ |
| 3037 | var EventPluginRegistry = { |
| 3038 | /** |
| 3039 | * Ordered list of injected plugins. |
| 3040 | */ |
| 3041 | plugins: [], |
| 3042 | |
| 3043 | /** |
| 3044 | * Mapping from event name to dispatch config |
| 3045 | */ |
| 3046 | eventNameDispatchConfigs: {}, |
| 3047 | |
| 3048 | /** |
| 3049 | * Mapping from registration name to plugin module |
| 3050 | */ |
| 3051 | registrationNameModules: {}, |
| 3052 | |
| 3053 | /** |
| 3054 | * Mapping from registration name to event name |
| 3055 | */ |
| 3056 | registrationNameDependencies: {}, |
| 3057 | |
| 3058 | /** |
| 3059 | * Mapping from lowercase registration names to the properly cased version, |
| 3060 | * used to warn in the case of missing event handlers. Available |
| 3061 | * only in true. |
| 3062 | * @type {Object} |
| 3063 | */ |
| 3064 | possibleRegistrationNames: {}, |
| 3065 | // Trust the developer to only use possibleRegistrationNames in true |
| 3066 | |
| 3067 | /** |
| 3068 | * Injects an ordering of plugins (by plugin name). This allows the ordering |
| 3069 | * to be decoupled from injection of the actual plugins so that ordering is |
| 3070 | * always deterministic regardless of packaging, on-the-fly injection, etc. |
| 3071 | * |
| 3072 | * @param {array} InjectedEventPluginOrder |
| 3073 | * @internal |
| 3074 | * @see {EventPluginHub.injection.injectEventPluginOrder} |
| 3075 | */ |
| 3076 | injectEventPluginOrder: function (injectedEventPluginOrder) { |
| 3077 | !!eventPluginOrder ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0; |
| 3078 | // Clone the ordering so it cannot be dynamically mutated. |
| 3079 | eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); |
| 3080 | recomputePluginOrdering(); |
3107 | | module.exports = ARIADOMPropertyConfig; |
3108 | | },{}],40:[function(require,module,exports){ |
| 3112 | var EventPluginRegistry_1 = EventPluginRegistry; |
| 3113 | |
| 3114 | // These attributes should be all lowercase to allow for |
| 3115 | // case insensitive checks |
| 3116 | var RESERVED_PROPS = { |
| 3117 | children: true, |
| 3118 | dangerouslySetInnerHTML: true, |
| 3119 | autoFocus: true, |
| 3120 | defaultValue: true, |
| 3121 | defaultChecked: true, |
| 3122 | innerHTML: true, |
| 3123 | suppressContentEditableWarning: true, |
| 3124 | style: true |
| 3125 | }; |
| 3126 | |
| 3127 | function checkMask(value, bitmask) { |
| 3128 | return (value & bitmask) === bitmask; |
| 3129 | } |
| 3130 | |
| 3131 | var DOMPropertyInjection = { |
| 3132 | /** |
| 3133 | * Mapping from normalized, camelcased property names to a configuration that |
| 3134 | * specifies how the associated DOM property should be accessed or rendered. |
| 3135 | */ |
| 3136 | MUST_USE_PROPERTY: 0x1, |
| 3137 | HAS_BOOLEAN_VALUE: 0x4, |
| 3138 | HAS_NUMERIC_VALUE: 0x8, |
| 3139 | HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8, |
| 3140 | HAS_OVERLOADED_BOOLEAN_VALUE: 0x20, |
| 3141 | HAS_STRING_BOOLEAN_VALUE: 0x40, |
| 3142 | |
| 3143 | /** |
| 3144 | * Inject some specialized knowledge about the DOM. This takes a config object |
| 3145 | * with the following properties: |
| 3146 | * |
| 3147 | * Properties: object mapping DOM property name to one of the |
| 3148 | * DOMPropertyInjection constants or null. If your attribute isn't in here, |
| 3149 | * it won't get written to the DOM. |
| 3150 | * |
| 3151 | * DOMAttributeNames: object mapping React attribute name to the DOM |
| 3152 | * attribute name. Attribute names not specified use the **lowercase** |
| 3153 | * normalized name. |
| 3154 | * |
| 3155 | * DOMAttributeNamespaces: object mapping React attribute name to the DOM |
| 3156 | * attribute namespace URL. (Attribute names not specified use no namespace.) |
| 3157 | * |
| 3158 | * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. |
| 3159 | * Property names not specified use the normalized name. |
| 3160 | * |
| 3161 | * DOMMutationMethods: Properties that require special mutation methods. If |
| 3162 | * `value` is undefined, the mutation method should unset the property. |
| 3163 | * |
| 3164 | * @param {object} domPropertyConfig the config as described above. |
| 3165 | */ |
| 3166 | injectDOMPropertyConfig: function (domPropertyConfig) { |
| 3167 | var Injection = DOMPropertyInjection; |
| 3168 | var Properties = domPropertyConfig.Properties || {}; |
| 3169 | var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; |
| 3170 | var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; |
| 3171 | var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; |
| 3172 | |
| 3173 | for (var propName in Properties) { |
| 3174 | !!DOMProperty.properties.hasOwnProperty(propName) ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property \'%s\' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.', propName) : void 0; |
| 3175 | |
| 3176 | var lowerCased = propName.toLowerCase(); |
| 3177 | var propConfig = Properties[propName]; |
| 3178 | |
| 3179 | var propertyInfo = { |
| 3180 | attributeName: lowerCased, |
| 3181 | attributeNamespace: null, |
| 3182 | propertyName: propName, |
| 3183 | mutationMethod: null, |
| 3184 | |
| 3185 | mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), |
| 3186 | hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), |
| 3187 | hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), |
| 3188 | hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), |
| 3189 | hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE), |
| 3190 | hasStringBooleanValue: checkMask(propConfig, Injection.HAS_STRING_BOOLEAN_VALUE) |
| 3191 | }; |
| 3192 | !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s', propName) : void 0; |
| 3193 | |
| 3194 | if (DOMAttributeNames.hasOwnProperty(propName)) { |
| 3195 | var attributeName = DOMAttributeNames[propName]; |
| 3196 | |
| 3197 | propertyInfo.attributeName = attributeName; |
| 3198 | } |
| 3199 | |
| 3200 | if (DOMAttributeNamespaces.hasOwnProperty(propName)) { |
| 3201 | propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; |
| 3202 | } |
| 3203 | |
| 3204 | if (DOMMutationMethods.hasOwnProperty(propName)) { |
| 3205 | propertyInfo.mutationMethod = DOMMutationMethods[propName]; |
| 3206 | } |
| 3207 | |
| 3208 | // Downcase references to whitelist properties to check for membership |
| 3209 | // without case-sensitivity. This allows the whitelist to pick up |
| 3210 | // `allowfullscreen`, which should be written using the property configuration |
| 3211 | // for `allowFullscreen` |
| 3212 | DOMProperty.properties[propName] = propertyInfo; |
| 3213 | } |
| 3214 | } |
| 3215 | }; |
| 3216 | |
| 3217 | /* eslint-disable max-len */ |
| 3218 | var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; |
| 3219 | /* eslint-enable max-len */ |
| 3220 | |
3175 | | function isPresto() { |
3176 | | var opera = window.opera; |
3177 | | return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; |
3178 | | } |
3179 | | |
3180 | | var SPACEBAR_CODE = 32; |
3181 | | var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); |
3182 | | |
3183 | | // Events and their corresponding property names. |
3184 | | var eventTypes = { |
3185 | | beforeInput: { |
3186 | | phasedRegistrationNames: { |
3187 | | bubbled: 'onBeforeInput', |
3188 | | captured: 'onBeforeInputCapture' |
3189 | | }, |
3190 | | dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste'] |
| 3358 | |
| 3359 | var ReactTypeOfWork = { |
| 3360 | IndeterminateComponent: 0, // Before we know whether it is functional or class |
| 3361 | FunctionalComponent: 1, |
| 3362 | ClassComponent: 2, |
| 3363 | HostRoot: 3, // Root of a host tree. Could be nested inside another node. |
| 3364 | HostPortal: 4, // A subtree. Could be an entry point to a different renderer. |
| 3365 | HostComponent: 5, |
| 3366 | HostText: 6, |
| 3367 | CoroutineComponent: 7, |
| 3368 | CoroutineHandlerPhase: 8, |
| 3369 | YieldComponent: 9, |
| 3370 | Fragment: 10 |
| 3371 | }; |
| 3372 | |
| 3373 | /** |
| 3374 | * Copyright (c) 2013-present, Facebook, Inc. |
| 3375 | * |
| 3376 | * This source code is licensed under the MIT license found in the |
| 3377 | * LICENSE file in the root directory of this source tree. |
| 3378 | * |
| 3379 | * @providesModule HTMLNodeType |
| 3380 | */ |
| 3381 | |
| 3382 | /** |
| 3383 | * HTML nodeType values that represent the type of the node |
| 3384 | */ |
| 3385 | |
| 3386 | var HTMLNodeType = { |
| 3387 | ELEMENT_NODE: 1, |
| 3388 | TEXT_NODE: 3, |
| 3389 | COMMENT_NODE: 8, |
| 3390 | DOCUMENT_NODE: 9, |
| 3391 | DOCUMENT_FRAGMENT_NODE: 11 |
| 3392 | }; |
| 3393 | |
| 3394 | var HTMLNodeType_1 = HTMLNodeType; |
| 3395 | |
| 3396 | var HostComponent = ReactTypeOfWork.HostComponent; |
| 3397 | var HostText = ReactTypeOfWork.HostText; |
| 3398 | |
| 3399 | var ELEMENT_NODE$1 = HTMLNodeType_1.ELEMENT_NODE; |
| 3400 | var COMMENT_NODE$1 = HTMLNodeType_1.COMMENT_NODE; |
| 3401 | |
| 3402 | |
| 3403 | |
| 3404 | var ATTR_NAME = DOMProperty_1.ID_ATTRIBUTE_NAME; |
| 3405 | var Flags = ReactDOMComponentFlags_1; |
| 3406 | |
| 3407 | var randomKey = Math.random().toString(36).slice(2); |
| 3408 | |
| 3409 | var internalInstanceKey = '__reactInternalInstance$' + randomKey; |
| 3410 | |
| 3411 | var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; |
| 3412 | |
| 3413 | /** |
| 3414 | * Check if a given node should be cached. |
| 3415 | */ |
| 3416 | function shouldPrecacheNode(node, nodeID) { |
| 3417 | return node.nodeType === ELEMENT_NODE$1 && node.getAttribute(ATTR_NAME) === '' + nodeID || node.nodeType === COMMENT_NODE$1 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === COMMENT_NODE$1 && node.nodeValue === ' react-empty: ' + nodeID + ' '; |
| 3418 | } |
| 3419 | |
| 3420 | /** |
| 3421 | * Drill down (through composites and empty components) until we get a host or |
| 3422 | * host text component. |
| 3423 | * |
| 3424 | * This is pretty polymorphic but unavoidable with the current structure we have |
| 3425 | * for `_renderedChildren`. |
| 3426 | */ |
| 3427 | function getRenderedHostOrTextFromComponent(component) { |
| 3428 | var rendered; |
| 3429 | while (rendered = component._renderedComponent) { |
| 3430 | component = rendered; |
| 3431 | } |
| 3432 | return component; |
| 3433 | } |
| 3434 | |
| 3435 | /** |
| 3436 | * Populate `_hostNode` on the rendered host/text component with the given |
| 3437 | * DOM node. The passed `inst` can be a composite. |
| 3438 | */ |
| 3439 | function precacheNode(inst, node) { |
| 3440 | var hostInst = getRenderedHostOrTextFromComponent(inst); |
| 3441 | hostInst._hostNode = node; |
| 3442 | node[internalInstanceKey] = hostInst; |
| 3443 | } |
| 3444 | |
| 3445 | function precacheFiberNode$1(hostInst, node) { |
| 3446 | node[internalInstanceKey] = hostInst; |
| 3447 | } |
| 3448 | |
| 3449 | function uncacheNode(inst) { |
| 3450 | var node = inst._hostNode; |
| 3451 | if (node) { |
| 3452 | delete node[internalInstanceKey]; |
| 3453 | inst._hostNode = null; |
| 3454 | } |
| 3455 | } |
| 3456 | |
| 3457 | /** |
| 3458 | * Populate `_hostNode` on each child of `inst`, assuming that the children |
| 3459 | * match up with the DOM (element) children of `node`. |
| 3460 | * |
| 3461 | * We cache entire levels at once to avoid an n^2 problem where we access the |
| 3462 | * children of a node sequentially and have to walk from the start to our target |
| 3463 | * node every time. |
| 3464 | * |
| 3465 | * Since we update `_renderedChildren` and the actual DOM at (slightly) |
| 3466 | * different times, we could race here and see a newer `_renderedChildren` than |
| 3467 | * the DOM nodes we see. To avoid this, ReactMultiChild calls |
| 3468 | * `prepareToManageChildren` before we change `_renderedChildren`, at which |
| 3469 | * time the container's child nodes are always cached (until it unmounts). |
| 3470 | */ |
| 3471 | function precacheChildNodes(inst, node) { |
| 3472 | if (inst._flags & Flags.hasCachedChildNodes) { |
| 3473 | return; |
| 3474 | } |
| 3475 | var children = inst._renderedChildren; |
| 3476 | var childNode = node.firstChild; |
| 3477 | outer: for (var name in children) { |
| 3478 | if (!children.hasOwnProperty(name)) { |
| 3479 | continue; |
| 3480 | } |
| 3481 | var childInst = children[name]; |
| 3482 | var childID = getRenderedHostOrTextFromComponent(childInst)._domID; |
| 3483 | if (childID === 0) { |
| 3484 | // We're currently unmounting this child in ReactMultiChild; skip it. |
| 3485 | continue; |
| 3486 | } |
| 3487 | // We assume the child nodes are in the same order as the child instances. |
| 3488 | for (; childNode !== null; childNode = childNode.nextSibling) { |
| 3489 | if (shouldPrecacheNode(childNode, childID)) { |
| 3490 | precacheNode(childInst, childNode); |
| 3491 | continue outer; |
| 3492 | } |
| 3493 | } |
| 3494 | // We reached the end of the DOM children without finding an ID match. |
| 3495 | invariant(false, 'Unable to find element with ID %s.', childID); |
| 3496 | } |
| 3497 | inst._flags |= Flags.hasCachedChildNodes; |
| 3498 | } |
| 3499 | |
| 3500 | /** |
| 3501 | * Given a DOM node, return the closest ReactDOMComponent or |
| 3502 | * ReactDOMTextComponent instance ancestor. |
| 3503 | */ |
| 3504 | function getClosestInstanceFromNode(node) { |
| 3505 | if (node[internalInstanceKey]) { |
| 3506 | return node[internalInstanceKey]; |
| 3507 | } |
| 3508 | |
| 3509 | // Walk up the tree until we find an ancestor whose instance we have cached. |
| 3510 | var parents = []; |
| 3511 | while (!node[internalInstanceKey]) { |
| 3512 | parents.push(node); |
| 3513 | if (node.parentNode) { |
| 3514 | node = node.parentNode; |
| 3515 | } else { |
| 3516 | // Top of the tree. This node must not be part of a React tree (or is |
| 3517 | // unmounted, potentially). |
| 3518 | return null; |
| 3519 | } |
| 3520 | } |
| 3521 | |
| 3522 | var closest; |
| 3523 | var inst = node[internalInstanceKey]; |
| 3524 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 3525 | // In Fiber, this will always be the deepest root. |
| 3526 | return inst; |
| 3527 | } |
| 3528 | for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) { |
| 3529 | closest = inst; |
| 3530 | if (parents.length) { |
| 3531 | precacheChildNodes(inst, node); |
| 3532 | } |
| 3533 | } |
| 3534 | |
| 3535 | return closest; |
| 3536 | } |
| 3537 | |
| 3538 | /** |
| 3539 | * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent |
| 3540 | * instance, or null if the node was not rendered by this React. |
| 3541 | */ |
| 3542 | function getInstanceFromNode(node) { |
| 3543 | var inst = node[internalInstanceKey]; |
| 3544 | if (inst) { |
| 3545 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 3546 | return inst; |
| 3547 | } else if (inst._hostNode === node) { |
| 3548 | return inst; |
| 3549 | } else { |
| 3550 | return null; |
| 3551 | } |
| 3552 | } |
| 3553 | inst = getClosestInstanceFromNode(node); |
| 3554 | if (inst != null && inst._hostNode === node) { |
| 3555 | return inst; |
| 3556 | } else { |
| 3557 | return null; |
| 3558 | } |
| 3559 | } |
| 3560 | |
| 3561 | /** |
| 3562 | * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding |
| 3563 | * DOM node. |
| 3564 | */ |
| 3565 | function getNodeFromInstance(inst) { |
| 3566 | if (inst.tag === HostComponent || inst.tag === HostText) { |
| 3567 | // In Fiber this, is just the state node right now. We assume it will be |
| 3568 | // a host component or host text. |
| 3569 | return inst.stateNode; |
| 3570 | } |
| 3571 | |
| 3572 | // Without this first invariant, passing a non-DOM-component triggers the next |
| 3573 | // invariant for a missing parent, which is super confusing. |
| 3574 | !(inst._hostNode !== undefined) ? invariant(false, 'getNodeFromInstance: Invalid argument.') : void 0; |
| 3575 | |
| 3576 | if (inst._hostNode) { |
| 3577 | return inst._hostNode; |
| 3578 | } |
| 3579 | |
| 3580 | // Walk up the tree until we find an ancestor whose DOM node we have cached. |
| 3581 | var parents = []; |
| 3582 | while (!inst._hostNode) { |
| 3583 | parents.push(inst); |
| 3584 | !inst._hostParent ? invariant(false, 'React DOM tree root should always have a node reference.') : void 0; |
| 3585 | inst = inst._hostParent; |
| 3586 | } |
| 3587 | |
| 3588 | // Now parents contains each ancestor that does *not* have a cached native |
| 3589 | // node, and `inst` is the deepest ancestor that does. |
| 3590 | for (; parents.length; inst = parents.pop()) { |
| 3591 | precacheChildNodes(inst, inst._hostNode); |
| 3592 | } |
| 3593 | |
| 3594 | return inst._hostNode; |
| 3595 | } |
| 3596 | |
| 3597 | function getFiberCurrentPropsFromNode(node) { |
| 3598 | return node[internalEventHandlersKey] || null; |
| 3599 | } |
| 3600 | |
| 3601 | function updateFiberProps$1(node, props) { |
| 3602 | node[internalEventHandlersKey] = props; |
| 3603 | } |
| 3604 | |
| 3605 | var ReactDOMComponentTree = { |
| 3606 | getClosestInstanceFromNode: getClosestInstanceFromNode, |
| 3607 | getInstanceFromNode: getInstanceFromNode, |
| 3608 | getNodeFromInstance: getNodeFromInstance, |
| 3609 | precacheChildNodes: precacheChildNodes, |
| 3610 | precacheNode: precacheNode, |
| 3611 | uncacheNode: uncacheNode, |
| 3612 | precacheFiberNode: precacheFiberNode$1, |
| 3613 | getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode, |
| 3614 | updateFiberProps: updateFiberProps$1 |
| 3615 | }; |
| 3616 | |
| 3617 | var ReactDOMComponentTree_1 = ReactDOMComponentTree; |
| 3618 | |
| 3619 | /** |
| 3620 | * Copyright (c) 2013-present, Facebook, Inc. |
| 3621 | * |
| 3622 | * This source code is licensed under the MIT license found in the |
| 3623 | * LICENSE file in the root directory of this source tree. |
| 3624 | * |
| 3625 | * @providesModule ReactInstanceMap |
| 3626 | */ |
| 3627 | |
| 3628 | /** |
| 3629 | * `ReactInstanceMap` maintains a mapping from a public facing stateful |
| 3630 | * instance (key) and the internal representation (value). This allows public |
| 3631 | * methods to accept the user facing instance as an argument and map them back |
| 3632 | * to internal methods. |
| 3633 | */ |
| 3634 | |
| 3635 | // TODO: Replace this with ES6: var ReactInstanceMap = new Map(); |
| 3636 | |
| 3637 | var ReactInstanceMap = { |
| 3638 | /** |
| 3639 | * This API should be called `delete` but we'd have to make sure to always |
| 3640 | * transform these to strings for IE support. When this transform is fully |
| 3641 | * supported we can rename it. |
| 3642 | */ |
| 3643 | remove: function (key) { |
| 3644 | key._reactInternalFiber = undefined; |
3235 | | function getCompositionEventType(topLevelType) { |
3236 | | switch (topLevelType) { |
3237 | | case 'topCompositionStart': |
3238 | | return eventTypes.compositionStart; |
3239 | | case 'topCompositionEnd': |
3240 | | return eventTypes.compositionEnd; |
3241 | | case 'topCompositionUpdate': |
3242 | | return eventTypes.compositionUpdate; |
3243 | | } |
| 3719 | |
| 3720 | var ReactTypeOfSideEffect = { |
| 3721 | // Don't change these two values: |
| 3722 | NoEffect: 0, // 0b00000000 |
| 3723 | PerformedWork: 1, // 0b00000001 |
| 3724 | // You can change the rest (and add more). |
| 3725 | Placement: 2, // 0b00000010 |
| 3726 | Update: 4, // 0b00000100 |
| 3727 | PlacementAndUpdate: 6, // 0b00000110 |
| 3728 | Deletion: 8, // 0b00001000 |
| 3729 | ContentReset: 16, // 0b00010000 |
| 3730 | Callback: 32, // 0b00100000 |
| 3731 | Err: 64, // 0b01000000 |
| 3732 | Ref: 128 }; |
| 3733 | |
| 3734 | var ReactCurrentOwner = ReactGlobalSharedState_1.ReactCurrentOwner; |
| 3735 | |
| 3736 | |
| 3737 | |
| 3738 | |
| 3739 | { |
| 3740 | var warning$1 = require$$0; |
| 3741 | } |
| 3742 | |
| 3743 | var ClassComponent = ReactTypeOfWork.ClassComponent; |
| 3744 | var HostComponent$1 = ReactTypeOfWork.HostComponent; |
| 3745 | var HostRoot$1 = ReactTypeOfWork.HostRoot; |
| 3746 | var HostPortal = ReactTypeOfWork.HostPortal; |
| 3747 | var HostText$1 = ReactTypeOfWork.HostText; |
| 3748 | |
| 3749 | var NoEffect = ReactTypeOfSideEffect.NoEffect; |
| 3750 | var Placement = ReactTypeOfSideEffect.Placement; |
| 3751 | |
| 3752 | var MOUNTING = 1; |
| 3753 | var MOUNTED = 2; |
| 3754 | var UNMOUNTED = 3; |
| 3755 | |
| 3756 | function isFiberMountedImpl(fiber) { |
| 3757 | var node = fiber; |
| 3758 | if (!fiber.alternate) { |
| 3759 | // If there is no alternate, this might be a new tree that isn't inserted |
| 3760 | // yet. If it is, then it will have a pending insertion effect on it. |
| 3761 | if ((node.effectTag & Placement) !== NoEffect) { |
| 3762 | return MOUNTING; |
| 3763 | } |
| 3764 | while (node['return']) { |
| 3765 | node = node['return']; |
| 3766 | if ((node.effectTag & Placement) !== NoEffect) { |
| 3767 | return MOUNTING; |
| 3768 | } |
| 3769 | } |
| 3770 | } else { |
| 3771 | while (node['return']) { |
| 3772 | node = node['return']; |
| 3773 | } |
| 3774 | } |
| 3775 | if (node.tag === HostRoot$1) { |
| 3776 | // TODO: Check if this was a nested HostRoot when used with |
| 3777 | // renderContainerIntoSubtree. |
| 3778 | return MOUNTED; |
| 3779 | } |
| 3780 | // If we didn't hit the root, that means that we're in an disconnected tree |
| 3781 | // that has been unmounted. |
| 3782 | return UNMOUNTED; |
| 3783 | } |
| 3784 | var isFiberMounted = function (fiber) { |
| 3785 | return isFiberMountedImpl(fiber) === MOUNTED; |
| 3786 | }; |
| 3787 | |
| 3788 | var isMounted = function (component) { |
| 3789 | { |
| 3790 | var owner = ReactCurrentOwner.current; |
| 3791 | if (owner !== null && owner.tag === ClassComponent) { |
| 3792 | var ownerFiber = owner; |
| 3793 | var instance = ownerFiber.stateNode; |
| 3794 | warning$1(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName_1(ownerFiber) || 'A component'); |
| 3795 | instance._warnedAboutRefsInRender = true; |
| 3796 | } |
| 3797 | } |
| 3798 | |
| 3799 | var fiber = ReactInstanceMap_1.get(component); |
| 3800 | if (!fiber) { |
| 3801 | return false; |
| 3802 | } |
| 3803 | return isFiberMountedImpl(fiber) === MOUNTED; |
| 3804 | }; |
| 3805 | |
| 3806 | function assertIsMounted(fiber) { |
| 3807 | !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; |
| 3808 | } |
| 3809 | |
| 3810 | function findCurrentFiberUsingSlowPath(fiber) { |
| 3811 | var alternate = fiber.alternate; |
| 3812 | if (!alternate) { |
| 3813 | // If there is no alternate, then we only need to check if it is mounted. |
| 3814 | var state = isFiberMountedImpl(fiber); |
| 3815 | !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; |
| 3816 | if (state === MOUNTING) { |
| 3817 | return null; |
| 3818 | } |
| 3819 | return fiber; |
| 3820 | } |
| 3821 | // If we have two possible branches, we'll walk backwards up to the root |
| 3822 | // to see what path the root points to. On the way we may hit one of the |
| 3823 | // special cases and we'll deal with them. |
| 3824 | var a = fiber; |
| 3825 | var b = alternate; |
| 3826 | while (true) { |
| 3827 | var parentA = a['return']; |
| 3828 | var parentB = parentA ? parentA.alternate : null; |
| 3829 | if (!parentA || !parentB) { |
| 3830 | // We're at the root. |
| 3831 | break; |
| 3832 | } |
| 3833 | |
| 3834 | // If both copies of the parent fiber point to the same child, we can |
| 3835 | // assume that the child is current. This happens when we bailout on low |
| 3836 | // priority: the bailed out fiber's child reuses the current child. |
| 3837 | if (parentA.child === parentB.child) { |
| 3838 | var child = parentA.child; |
| 3839 | while (child) { |
| 3840 | if (child === a) { |
| 3841 | // We've determined that A is the current branch. |
| 3842 | assertIsMounted(parentA); |
| 3843 | return fiber; |
| 3844 | } |
| 3845 | if (child === b) { |
| 3846 | // We've determined that B is the current branch. |
| 3847 | assertIsMounted(parentA); |
| 3848 | return alternate; |
| 3849 | } |
| 3850 | child = child.sibling; |
| 3851 | } |
| 3852 | // We should never have an alternate for any mounting node. So the only |
| 3853 | // way this could possibly happen is if this was unmounted, if at all. |
| 3854 | invariant(false, 'Unable to find node on an unmounted component.'); |
| 3855 | } |
| 3856 | |
| 3857 | if (a['return'] !== b['return']) { |
| 3858 | // The return pointer of A and the return pointer of B point to different |
| 3859 | // fibers. We assume that return pointers never criss-cross, so A must |
| 3860 | // belong to the child set of A.return, and B must belong to the child |
| 3861 | // set of B.return. |
| 3862 | a = parentA; |
| 3863 | b = parentB; |
| 3864 | } else { |
| 3865 | // The return pointers point to the same fiber. We'll have to use the |
| 3866 | // default, slow path: scan the child sets of each parent alternate to see |
| 3867 | // which child belongs to which set. |
| 3868 | // |
| 3869 | // Search parent A's child set |
| 3870 | var didFindChild = false; |
| 3871 | var _child = parentA.child; |
| 3872 | while (_child) { |
| 3873 | if (_child === a) { |
| 3874 | didFindChild = true; |
| 3875 | a = parentA; |
| 3876 | b = parentB; |
| 3877 | break; |
| 3878 | } |
| 3879 | if (_child === b) { |
| 3880 | didFindChild = true; |
| 3881 | b = parentA; |
| 3882 | a = parentB; |
| 3883 | break; |
| 3884 | } |
| 3885 | _child = _child.sibling; |
| 3886 | } |
| 3887 | if (!didFindChild) { |
| 3888 | // Search parent B's child set |
| 3889 | _child = parentB.child; |
| 3890 | while (_child) { |
| 3891 | if (_child === a) { |
| 3892 | didFindChild = true; |
| 3893 | a = parentB; |
| 3894 | b = parentA; |
| 3895 | break; |
| 3896 | } |
| 3897 | if (_child === b) { |
| 3898 | didFindChild = true; |
| 3899 | b = parentB; |
| 3900 | a = parentA; |
| 3901 | break; |
| 3902 | } |
| 3903 | _child = _child.sibling; |
| 3904 | } |
| 3905 | !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0; |
| 3906 | } |
| 3907 | } |
| 3908 | |
| 3909 | !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0; |
| 3910 | } |
| 3911 | // If the root is not a host container, we're in a disconnected tree. I.e. |
| 3912 | // unmounted. |
| 3913 | !(a.tag === HostRoot$1) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; |
| 3914 | if (a.stateNode.current === a) { |
| 3915 | // We've determined that A is the current branch. |
| 3916 | return fiber; |
| 3917 | } |
| 3918 | // Otherwise B has to be current branch. |
| 3919 | return alternate; |
| 3920 | } |
| 3921 | var findCurrentFiberUsingSlowPath_1 = findCurrentFiberUsingSlowPath; |
| 3922 | |
| 3923 | var findCurrentHostFiber = function (parent) { |
| 3924 | var currentParent = findCurrentFiberUsingSlowPath(parent); |
| 3925 | if (!currentParent) { |
| 3926 | return null; |
| 3927 | } |
| 3928 | |
| 3929 | // Next we'll drill down this component to find the first HostComponent/Text. |
| 3930 | var node = currentParent; |
| 3931 | while (true) { |
| 3932 | if (node.tag === HostComponent$1 || node.tag === HostText$1) { |
| 3933 | return node; |
| 3934 | } else if (node.child) { |
| 3935 | node.child['return'] = node; |
| 3936 | node = node.child; |
| 3937 | continue; |
| 3938 | } |
| 3939 | if (node === currentParent) { |
| 3940 | return null; |
| 3941 | } |
| 3942 | while (!node.sibling) { |
| 3943 | if (!node['return'] || node['return'] === currentParent) { |
| 3944 | return null; |
| 3945 | } |
| 3946 | node = node['return']; |
| 3947 | } |
| 3948 | node.sibling['return'] = node['return']; |
| 3949 | node = node.sibling; |
| 3950 | } |
| 3951 | // Flow needs the return null here, but ESLint complains about it. |
| 3952 | // eslint-disable-next-line no-unreachable |
| 3953 | return null; |
| 3954 | }; |
| 3955 | |
| 3956 | var findCurrentHostFiberWithNoPortals = function (parent) { |
| 3957 | var currentParent = findCurrentFiberUsingSlowPath(parent); |
| 3958 | if (!currentParent) { |
| 3959 | return null; |
| 3960 | } |
| 3961 | |
| 3962 | // Next we'll drill down this component to find the first HostComponent/Text. |
| 3963 | var node = currentParent; |
| 3964 | while (true) { |
| 3965 | if (node.tag === HostComponent$1 || node.tag === HostText$1) { |
| 3966 | return node; |
| 3967 | } else if (node.child && node.tag !== HostPortal) { |
| 3968 | node.child['return'] = node; |
| 3969 | node = node.child; |
| 3970 | continue; |
| 3971 | } |
| 3972 | if (node === currentParent) { |
| 3973 | return null; |
| 3974 | } |
| 3975 | while (!node.sibling) { |
| 3976 | if (!node['return'] || node['return'] === currentParent) { |
| 3977 | return null; |
| 3978 | } |
| 3979 | node = node['return']; |
| 3980 | } |
| 3981 | node.sibling['return'] = node['return']; |
| 3982 | node = node.sibling; |
| 3983 | } |
| 3984 | // Flow needs the return null here, but ESLint complains about it. |
| 3985 | // eslint-disable-next-line no-unreachable |
| 3986 | return null; |
| 3987 | }; |
| 3988 | |
| 3989 | var ReactFiberTreeReflection = { |
| 3990 | isFiberMounted: isFiberMounted, |
| 3991 | isMounted: isMounted, |
| 3992 | findCurrentFiberUsingSlowPath: findCurrentFiberUsingSlowPath_1, |
| 3993 | findCurrentHostFiber: findCurrentHostFiber, |
| 3994 | findCurrentHostFiberWithNoPortals: findCurrentHostFiberWithNoPortals |
| 3995 | }; |
| 3996 | |
| 3997 | var ReactErrorUtils = { |
| 3998 | // Used by Fiber to simulate a try-catch. |
| 3999 | _caughtError: null, |
| 4000 | _hasCaughtError: false, |
| 4001 | |
| 4002 | // Used by event system to capture/rethrow the first error. |
| 4003 | _rethrowError: null, |
| 4004 | _hasRethrowError: false, |
| 4005 | |
| 4006 | injection: { |
| 4007 | injectErrorUtils: function (injectedErrorUtils) { |
| 4008 | !(typeof injectedErrorUtils.invokeGuardedCallback === 'function') ? invariant(false, 'Injected invokeGuardedCallback() must be a function.') : void 0; |
| 4009 | invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback; |
| 4010 | } |
| 4011 | }, |
| 4012 | |
| 4013 | /** |
| 4014 | * Call a function while guarding against errors that happens within it. |
| 4015 | * Returns an error if it throws, otherwise null. |
| 4016 | * |
| 4017 | * In production, this is implemented using a try-catch. The reason we don't |
| 4018 | * use a try-catch directly is so that we can swap out a different |
| 4019 | * implementation in DEV mode. |
| 4020 | * |
| 4021 | * @param {String} name of the guard to use for logging or debugging |
| 4022 | * @param {Function} func The function to invoke |
| 4023 | * @param {*} context The context to use when calling the function |
| 4024 | * @param {...*} args Arguments for function |
| 4025 | */ |
| 4026 | invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) { |
| 4027 | invokeGuardedCallback.apply(ReactErrorUtils, arguments); |
| 4028 | }, |
| 4029 | |
| 4030 | /** |
| 4031 | * Same as invokeGuardedCallback, but instead of returning an error, it stores |
| 4032 | * it in a global so it can be rethrown by `rethrowCaughtError` later. |
| 4033 | * TODO: See if _caughtError and _rethrowError can be unified. |
| 4034 | * |
| 4035 | * @param {String} name of the guard to use for logging or debugging |
| 4036 | * @param {Function} func The function to invoke |
| 4037 | * @param {*} context The context to use when calling the function |
| 4038 | * @param {...*} args Arguments for function |
| 4039 | */ |
| 4040 | invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) { |
| 4041 | ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); |
| 4042 | if (ReactErrorUtils.hasCaughtError()) { |
| 4043 | var error = ReactErrorUtils.clearCaughtError(); |
| 4044 | if (!ReactErrorUtils._hasRethrowError) { |
| 4045 | ReactErrorUtils._hasRethrowError = true; |
| 4046 | ReactErrorUtils._rethrowError = error; |
| 4047 | } |
| 4048 | } |
| 4049 | }, |
| 4050 | |
| 4051 | /** |
| 4052 | * During execution of guarded functions we will capture the first error which |
| 4053 | * we will rethrow to be handled by the top level error handler. |
| 4054 | */ |
| 4055 | rethrowCaughtError: function () { |
| 4056 | return rethrowCaughtError.apply(ReactErrorUtils, arguments); |
| 4057 | }, |
| 4058 | |
| 4059 | hasCaughtError: function () { |
| 4060 | return ReactErrorUtils._hasCaughtError; |
| 4061 | }, |
| 4062 | |
| 4063 | clearCaughtError: function () { |
| 4064 | if (ReactErrorUtils._hasCaughtError) { |
| 4065 | var error = ReactErrorUtils._caughtError; |
| 4066 | ReactErrorUtils._caughtError = null; |
| 4067 | ReactErrorUtils._hasCaughtError = false; |
| 4068 | return error; |
| 4069 | } else { |
| 4070 | invariant(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.'); |
| 4071 | } |
| 4072 | } |
| 4073 | }; |
| 4074 | |
| 4075 | var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) { |
| 4076 | ReactErrorUtils._hasCaughtError = false; |
| 4077 | ReactErrorUtils._caughtError = null; |
| 4078 | var funcArgs = Array.prototype.slice.call(arguments, 3); |
| 4079 | try { |
| 4080 | func.apply(context, funcArgs); |
| 4081 | } catch (error) { |
| 4082 | ReactErrorUtils._caughtError = error; |
| 4083 | ReactErrorUtils._hasCaughtError = true; |
| 4084 | } |
| 4085 | }; |
| 4086 | |
| 4087 | { |
| 4088 | // In DEV mode, we swap out invokeGuardedCallback for a special version |
| 4089 | // that plays more nicely with the browser's DevTools. The idea is to preserve |
| 4090 | // "Pause on exceptions" behavior. Because React wraps all user-provided |
| 4091 | // functions in invokeGuardedCallback, and the production version of |
| 4092 | // invokeGuardedCallback uses a try-catch, all user exceptions are treated |
| 4093 | // like caught exceptions, and the DevTools won't pause unless the developer |
| 4094 | // takes the extra step of enabling pause on caught exceptions. This is |
| 4095 | // untintuitive, though, because even though React has caught the error, from |
| 4096 | // the developer's perspective, the error is uncaught. |
| 4097 | // |
| 4098 | // To preserve the expected "Pause on exceptions" behavior, we don't use a |
| 4099 | // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake |
| 4100 | // DOM node, and call the user-provided callback from inside an event handler |
| 4101 | // for that fake event. If the callback throws, the error is "captured" using |
| 4102 | // a global event handler. But because the error happens in a different |
| 4103 | // event loop context, it does not interrupt the normal program flow. |
| 4104 | // Effectively, this gives us try-catch behavior without actually using |
| 4105 | // try-catch. Neat! |
| 4106 | |
| 4107 | // Check that the browser supports the APIs we need to implement our special |
| 4108 | // DEV version of invokeGuardedCallback |
| 4109 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { |
| 4110 | var fakeNode = document.createElement('react'); |
| 4111 | |
| 4112 | var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { |
| 4113 | // Keeps track of whether the user-provided callback threw an error. We |
| 4114 | // set this to true at the beginning, then set it to false right after |
| 4115 | // calling the function. If the function errors, `didError` will never be |
| 4116 | // set to false. This strategy works even if the browser is flaky and |
| 4117 | // fails to call our global error handler, because it doesn't rely on |
| 4118 | // the error event at all. |
| 4119 | var didError = true; |
| 4120 | |
| 4121 | // Create an event handler for our fake event. We will synchronously |
| 4122 | // dispatch our fake event using `dispatchEvent`. Inside the handler, we |
| 4123 | // call the user-provided callback. |
| 4124 | var funcArgs = Array.prototype.slice.call(arguments, 3); |
| 4125 | function callCallback() { |
| 4126 | // We immediately remove the callback from event listeners so that |
| 4127 | // nested `invokeGuardedCallback` calls do not clash. Otherwise, a |
| 4128 | // nested call would trigger the fake event handlers of any call higher |
| 4129 | // in the stack. |
| 4130 | fakeNode.removeEventListener(evtType, callCallback, false); |
| 4131 | func.apply(context, funcArgs); |
| 4132 | didError = false; |
| 4133 | } |
| 4134 | |
| 4135 | // Create a global error event handler. We use this to capture the value |
| 4136 | // that was thrown. It's possible that this error handler will fire more |
| 4137 | // than once; for example, if non-React code also calls `dispatchEvent` |
| 4138 | // and a handler for that event throws. We should be resilient to most of |
| 4139 | // those cases. Even if our error event handler fires more than once, the |
| 4140 | // last error event is always used. If the callback actually does error, |
| 4141 | // we know that the last error event is the correct one, because it's not |
| 4142 | // possible for anything else to have happened in between our callback |
| 4143 | // erroring and the code that follows the `dispatchEvent` call below. If |
| 4144 | // the callback doesn't error, but the error event was fired, we know to |
| 4145 | // ignore it because `didError` will be false, as described above. |
| 4146 | var error = void 0; |
| 4147 | // Use this to track whether the error event is ever called. |
| 4148 | var didSetError = false; |
| 4149 | var isCrossOriginError = false; |
| 4150 | |
| 4151 | function onError(event) { |
| 4152 | error = event.error; |
| 4153 | didSetError = true; |
| 4154 | if (error === null && event.colno === 0 && event.lineno === 0) { |
| 4155 | isCrossOriginError = true; |
| 4156 | } |
| 4157 | } |
| 4158 | |
| 4159 | // Create a fake event type. |
| 4160 | var evtType = 'react-' + (name ? name : 'invokeguardedcallback'); |
| 4161 | |
| 4162 | // Attach our event handlers |
| 4163 | window.addEventListener('error', onError); |
| 4164 | fakeNode.addEventListener(evtType, callCallback, false); |
| 4165 | |
| 4166 | // Synchronously dispatch our fake event. If the user-provided function |
| 4167 | // errors, it will trigger our global error handler. |
| 4168 | var evt = document.createEvent('Event'); |
| 4169 | evt.initEvent(evtType, false, false); |
| 4170 | fakeNode.dispatchEvent(evt); |
| 4171 | |
| 4172 | if (didError) { |
| 4173 | if (!didSetError) { |
| 4174 | // The callback errored, but the error event never fired. |
| 4175 | 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.'); |
| 4176 | } else if (isCrossOriginError) { |
| 4177 | 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.'); |
| 4178 | } |
| 4179 | ReactErrorUtils._hasCaughtError = true; |
| 4180 | ReactErrorUtils._caughtError = error; |
| 4181 | } else { |
| 4182 | ReactErrorUtils._hasCaughtError = false; |
| 4183 | ReactErrorUtils._caughtError = null; |
| 4184 | } |
| 4185 | |
| 4186 | // Remove our event listeners |
| 4187 | window.removeEventListener('error', onError); |
| 4188 | }; |
| 4189 | |
| 4190 | invokeGuardedCallback = invokeGuardedCallbackDev; |
| 4191 | } |
| 4192 | } |
| 4193 | |
| 4194 | var rethrowCaughtError = function () { |
| 4195 | if (ReactErrorUtils._hasRethrowError) { |
| 4196 | var error = ReactErrorUtils._rethrowError; |
| 4197 | ReactErrorUtils._rethrowError = null; |
| 4198 | ReactErrorUtils._hasRethrowError = false; |
| 4199 | throw error; |
| 4200 | } |
| 4201 | }; |
| 4202 | |
| 4203 | var ReactErrorUtils_1 = ReactErrorUtils; |
| 4204 | |
| 4205 | { |
| 4206 | var warning$2 = require$$0; |
3265 | | function isFallbackCompositionEnd(topLevelType, nativeEvent) { |
3266 | | switch (topLevelType) { |
3267 | | case 'topKeyUp': |
3268 | | // Command keys insert or clear IME input. |
3269 | | return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; |
3270 | | case 'topKeyDown': |
3271 | | // Expect IME keyCode on each keydown. If we get any other |
3272 | | // code we must have exited earlier. |
3273 | | return nativeEvent.keyCode !== START_KEYCODE; |
3274 | | case 'topKeyPress': |
3275 | | case 'topMouseDown': |
3276 | | case 'topBlur': |
3277 | | // Events are not possible without cancelling IME. |
3278 | | return true; |
| 4217 | var ComponentTree; |
| 4218 | var injection = { |
| 4219 | injectComponentTree: function (Injected) { |
| 4220 | ComponentTree = Injected; |
| 4221 | { |
| 4222 | warning$2(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); |
| 4223 | } |
| 4224 | } |
| 4225 | }; |
| 4226 | |
| 4227 | function isEndish(topLevelType) { |
| 4228 | return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel'; |
| 4229 | } |
| 4230 | |
| 4231 | function isMoveish(topLevelType) { |
| 4232 | return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove'; |
| 4233 | } |
| 4234 | function isStartish(topLevelType) { |
| 4235 | return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart'; |
| 4236 | } |
| 4237 | |
| 4238 | var validateEventDispatches; |
| 4239 | { |
| 4240 | validateEventDispatches = function (event) { |
| 4241 | var dispatchListeners = event._dispatchListeners; |
| 4242 | var dispatchInstances = event._dispatchInstances; |
| 4243 | |
| 4244 | var listenersIsArr = Array.isArray(dispatchListeners); |
| 4245 | var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; |
| 4246 | |
| 4247 | var instancesIsArr = Array.isArray(dispatchInstances); |
| 4248 | var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; |
| 4249 | |
| 4250 | warning$2(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.'); |
| 4251 | }; |
| 4252 | } |
| 4253 | |
| 4254 | /** |
| 4255 | * Dispatch the event to the listener. |
| 4256 | * @param {SyntheticEvent} event SyntheticEvent to handle |
| 4257 | * @param {boolean} simulated If the event is simulated (changes exn behavior) |
| 4258 | * @param {function} listener Application-level callback |
| 4259 | * @param {*} inst Internal component instance |
| 4260 | */ |
| 4261 | function executeDispatch(event, simulated, listener, inst) { |
| 4262 | var type = event.type || 'unknown-event'; |
| 4263 | event.currentTarget = EventPluginUtils.getNodeFromInstance(inst); |
| 4264 | ReactErrorUtils_1.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); |
| 4265 | event.currentTarget = null; |
| 4266 | } |
| 4267 | |
| 4268 | /** |
| 4269 | * Standard/simple iteration through an event's collected dispatches. |
| 4270 | */ |
| 4271 | function executeDispatchesInOrder(event, simulated) { |
| 4272 | var dispatchListeners = event._dispatchListeners; |
| 4273 | var dispatchInstances = event._dispatchInstances; |
| 4274 | { |
| 4275 | validateEventDispatches(event); |
| 4276 | } |
| 4277 | if (Array.isArray(dispatchListeners)) { |
| 4278 | for (var i = 0; i < dispatchListeners.length; i++) { |
| 4279 | if (event.isPropagationStopped()) { |
| 4280 | break; |
| 4281 | } |
| 4282 | // Listeners and Instances are two parallel arrays that are always in sync. |
| 4283 | executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]); |
| 4284 | } |
| 4285 | } else if (dispatchListeners) { |
| 4286 | executeDispatch(event, simulated, dispatchListeners, dispatchInstances); |
| 4287 | } |
| 4288 | event._dispatchListeners = null; |
| 4289 | event._dispatchInstances = null; |
| 4290 | } |
| 4291 | |
| 4292 | /** |
| 4293 | * Standard/simple iteration through an event's collected dispatches, but stops |
| 4294 | * at the first dispatch execution returning true, and returns that id. |
| 4295 | * |
| 4296 | * @return {?string} id of the first dispatch execution who's listener returns |
| 4297 | * true, or null if no listener returned true. |
| 4298 | */ |
| 4299 | function executeDispatchesInOrderStopAtTrueImpl(event) { |
| 4300 | var dispatchListeners = event._dispatchListeners; |
| 4301 | var dispatchInstances = event._dispatchInstances; |
| 4302 | { |
| 4303 | validateEventDispatches(event); |
| 4304 | } |
| 4305 | if (Array.isArray(dispatchListeners)) { |
| 4306 | for (var i = 0; i < dispatchListeners.length; i++) { |
| 4307 | if (event.isPropagationStopped()) { |
| 4308 | break; |
| 4309 | } |
| 4310 | // Listeners and Instances are two parallel arrays that are always in sync. |
| 4311 | if (dispatchListeners[i](event, dispatchInstances[i])) { |
| 4312 | return dispatchInstances[i]; |
| 4313 | } |
| 4314 | } |
| 4315 | } else if (dispatchListeners) { |
| 4316 | if (dispatchListeners(event, dispatchInstances)) { |
| 4317 | return dispatchInstances; |
| 4318 | } |
| 4319 | } |
| 4320 | return null; |
| 4321 | } |
| 4322 | |
| 4323 | /** |
| 4324 | * @see executeDispatchesInOrderStopAtTrueImpl |
| 4325 | */ |
| 4326 | function executeDispatchesInOrderStopAtTrue(event) { |
| 4327 | var ret = executeDispatchesInOrderStopAtTrueImpl(event); |
| 4328 | event._dispatchInstances = null; |
| 4329 | event._dispatchListeners = null; |
| 4330 | return ret; |
| 4331 | } |
| 4332 | |
| 4333 | /** |
| 4334 | * Execution of a "direct" dispatch - there must be at most one dispatch |
| 4335 | * accumulated on the event or it is considered an error. It doesn't really make |
| 4336 | * sense for an event with multiple dispatches (bubbled) to keep track of the |
| 4337 | * return values at each dispatch execution, but it does tend to make sense when |
| 4338 | * dealing with "direct" dispatches. |
| 4339 | * |
| 4340 | * @return {*} The return value of executing the single dispatch. |
| 4341 | */ |
| 4342 | function executeDirectDispatch(event) { |
| 4343 | { |
| 4344 | validateEventDispatches(event); |
| 4345 | } |
| 4346 | var dispatchListener = event._dispatchListeners; |
| 4347 | var dispatchInstance = event._dispatchInstances; |
| 4348 | !!Array.isArray(dispatchListener) ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : void 0; |
| 4349 | event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null; |
| 4350 | var res = dispatchListener ? dispatchListener(event) : null; |
| 4351 | event.currentTarget = null; |
| 4352 | event._dispatchListeners = null; |
| 4353 | event._dispatchInstances = null; |
| 4354 | return res; |
| 4355 | } |
| 4356 | |
| 4357 | /** |
| 4358 | * @param {SyntheticEvent} event |
| 4359 | * @return {boolean} True iff number of dispatches accumulated is greater than 0. |
| 4360 | */ |
| 4361 | function hasDispatches(event) { |
| 4362 | return !!event._dispatchListeners; |
| 4363 | } |
| 4364 | |
| 4365 | /** |
| 4366 | * General utilities that are useful in creating custom Event Plugins. |
| 4367 | */ |
| 4368 | var EventPluginUtils = { |
| 4369 | isEndish: isEndish, |
| 4370 | isMoveish: isMoveish, |
| 4371 | isStartish: isStartish, |
| 4372 | |
| 4373 | executeDirectDispatch: executeDirectDispatch, |
| 4374 | executeDispatchesInOrder: executeDispatchesInOrder, |
| 4375 | executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue, |
| 4376 | hasDispatches: hasDispatches, |
| 4377 | |
| 4378 | getFiberCurrentPropsFromNode: function (node) { |
| 4379 | return ComponentTree.getFiberCurrentPropsFromNode(node); |
| 4380 | }, |
| 4381 | getInstanceFromNode: function (node) { |
| 4382 | return ComponentTree.getInstanceFromNode(node); |
| 4383 | }, |
| 4384 | getNodeFromInstance: function (node) { |
| 4385 | return ComponentTree.getNodeFromInstance(node); |
| 4386 | }, |
| 4387 | |
| 4388 | injection: injection |
| 4389 | }; |
| 4390 | |
| 4391 | var EventPluginUtils_1 = EventPluginUtils; |
| 4392 | |
| 4393 | // Use to restore controlled state after a change event has fired. |
| 4394 | |
| 4395 | var fiberHostComponent = null; |
| 4396 | |
| 4397 | var ReactControlledComponentInjection = { |
| 4398 | injectFiberControlledHostComponent: function (hostComponentImpl) { |
| 4399 | // The fiber implementation doesn't use dynamic dispatch so we need to |
| 4400 | // inject the implementation. |
| 4401 | fiberHostComponent = hostComponentImpl; |
| 4402 | } |
| 4403 | }; |
| 4404 | |
| 4405 | var restoreTarget = null; |
| 4406 | var restoreQueue = null; |
| 4407 | |
| 4408 | function restoreStateOfTarget(target) { |
| 4409 | // We perform this translation at the end of the event loop so that we |
| 4410 | // always receive the correct fiber here |
| 4411 | var internalInstance = EventPluginUtils_1.getInstanceFromNode(target); |
| 4412 | if (!internalInstance) { |
| 4413 | // Unmounted |
| 4414 | return; |
| 4415 | } |
| 4416 | if (typeof internalInstance.tag === 'number') { |
| 4417 | !(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function') ? invariant(false, 'Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue.') : void 0; |
| 4418 | var props = EventPluginUtils_1.getFiberCurrentPropsFromNode(internalInstance.stateNode); |
| 4419 | fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props); |
| 4420 | return; |
| 4421 | } |
| 4422 | !(typeof internalInstance.restoreControlledState === 'function') ? invariant(false, 'The internal instance must be a React host component. This error is likely caused by a bug in React. Please file an issue.') : void 0; |
| 4423 | // If it is not a Fiber, we can just use dynamic dispatch. |
| 4424 | internalInstance.restoreControlledState(); |
| 4425 | } |
| 4426 | |
| 4427 | var ReactControlledComponent = { |
| 4428 | injection: ReactControlledComponentInjection, |
| 4429 | |
| 4430 | enqueueStateRestore: function (target) { |
| 4431 | if (restoreTarget) { |
| 4432 | if (restoreQueue) { |
| 4433 | restoreQueue.push(target); |
| 4434 | } else { |
| 4435 | restoreQueue = [target]; |
| 4436 | } |
| 4437 | } else { |
| 4438 | restoreTarget = target; |
| 4439 | } |
| 4440 | }, |
| 4441 | restoreStateIfNeeded: function () { |
| 4442 | if (!restoreTarget) { |
| 4443 | return; |
| 4444 | } |
| 4445 | var target = restoreTarget; |
| 4446 | var queuedTargets = restoreQueue; |
| 4447 | restoreTarget = null; |
| 4448 | restoreQueue = null; |
| 4449 | |
| 4450 | restoreStateOfTarget(target); |
| 4451 | if (queuedTargets) { |
| 4452 | for (var i = 0; i < queuedTargets.length; i++) { |
| 4453 | restoreStateOfTarget(queuedTargets[i]); |
| 4454 | } |
| 4455 | } |
| 4456 | } |
| 4457 | }; |
| 4458 | |
| 4459 | var ReactControlledComponent_1 = ReactControlledComponent; |
| 4460 | |
| 4461 | // Used as a way to call batchedUpdates when we don't know if we're in a Fiber |
| 4462 | // or Stack context. Such as when we're dispatching events or if third party |
| 4463 | // libraries need to call batchedUpdates. Eventually, this API will go away when |
| 4464 | // everything is batched by default. We'll then have a similar API to opt-out of |
| 4465 | // scheduled work and instead do synchronous work. |
| 4466 | |
| 4467 | // Defaults |
| 4468 | var stackBatchedUpdates = function (fn, a, b, c, d, e) { |
| 4469 | return fn(a, b, c, d, e); |
| 4470 | }; |
| 4471 | var fiberBatchedUpdates = function (fn, bookkeeping) { |
| 4472 | return fn(bookkeeping); |
| 4473 | }; |
| 4474 | |
| 4475 | function performFiberBatchedUpdates(fn, bookkeeping) { |
| 4476 | // If we have Fiber loaded, we need to wrap this in a batching call so that |
| 4477 | // Fiber can apply its default priority for this call. |
| 4478 | return fiberBatchedUpdates(fn, bookkeeping); |
| 4479 | } |
| 4480 | function batchedUpdates(fn, bookkeeping) { |
| 4481 | // We first perform work with the stack batching strategy, by passing our |
| 4482 | // indirection to it. |
| 4483 | return stackBatchedUpdates(performFiberBatchedUpdates, fn, bookkeeping); |
| 4484 | } |
| 4485 | |
| 4486 | var isNestingBatched = false; |
| 4487 | function batchedUpdatesWithControlledComponents(fn, bookkeeping) { |
| 4488 | if (isNestingBatched) { |
| 4489 | // If we are currently inside another batch, we need to wait until it |
| 4490 | // fully completes before restoring state. Therefore, we add the target to |
| 4491 | // a queue of work. |
| 4492 | return batchedUpdates(fn, bookkeeping); |
| 4493 | } |
| 4494 | isNestingBatched = true; |
| 4495 | try { |
| 4496 | return batchedUpdates(fn, bookkeeping); |
| 4497 | } finally { |
| 4498 | // Here we wait until all updates have propagated, which is important |
| 4499 | // when using controlled components within layers: |
| 4500 | // https://github.com/facebook/react/issues/1698 |
| 4501 | // Then we restore state of any controlled component. |
| 4502 | isNestingBatched = false; |
| 4503 | ReactControlledComponent_1.restoreStateIfNeeded(); |
| 4504 | } |
| 4505 | } |
| 4506 | |
| 4507 | var ReactGenericBatchingInjection = { |
| 4508 | injectStackBatchedUpdates: function (_batchedUpdates) { |
| 4509 | stackBatchedUpdates = _batchedUpdates; |
| 4510 | }, |
| 4511 | injectFiberBatchedUpdates: function (_batchedUpdates) { |
| 4512 | fiberBatchedUpdates = _batchedUpdates; |
| 4513 | } |
| 4514 | }; |
| 4515 | |
| 4516 | var ReactGenericBatching = { |
| 4517 | batchedUpdates: batchedUpdatesWithControlledComponents, |
| 4518 | injection: ReactGenericBatchingInjection |
| 4519 | }; |
| 4520 | |
| 4521 | var ReactGenericBatching_1 = ReactGenericBatching; |
| 4522 | |
| 4523 | var TEXT_NODE$1 = HTMLNodeType_1.TEXT_NODE; |
| 4524 | |
| 4525 | /** |
| 4526 | * Gets the target node from a native browser event by accounting for |
| 4527 | * inconsistencies in browser DOM APIs. |
| 4528 | * |
| 4529 | * @param {object} nativeEvent Native browser event. |
| 4530 | * @return {DOMEventTarget} Target node. |
| 4531 | */ |
| 4532 | |
| 4533 | |
| 4534 | function getEventTarget(nativeEvent) { |
| 4535 | var target = nativeEvent.target || nativeEvent.srcElement || window; |
| 4536 | |
| 4537 | // Normalize SVG <use> element events #4963 |
| 4538 | if (target.correspondingUseElement) { |
| 4539 | target = target.correspondingUseElement; |
| 4540 | } |
| 4541 | |
| 4542 | // Safari may fire events on text nodes (Node.TEXT_NODE is 3). |
| 4543 | // @see http://www.quirksmode.org/js/events_properties.html |
| 4544 | return target.nodeType === TEXT_NODE$1 ? target.parentNode : target; |
| 4545 | } |
| 4546 | |
| 4547 | var getEventTarget_1 = getEventTarget; |
| 4548 | |
| 4549 | var HostRoot = ReactTypeOfWork.HostRoot; |
| 4550 | |
| 4551 | |
| 4552 | var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; |
| 4553 | var callbackBookkeepingPool = []; |
| 4554 | |
| 4555 | /** |
| 4556 | * Find the deepest React component completely containing the root of the |
| 4557 | * passed-in instance (for use when entire React trees are nested within each |
| 4558 | * other). If React trees are not nested, returns null. |
| 4559 | */ |
| 4560 | function findRootContainerNode(inst) { |
| 4561 | // TODO: It may be a good idea to cache this to prevent unnecessary DOM |
| 4562 | // traversal, but caching is difficult to do correctly without using a |
| 4563 | // mutation observer to listen for all DOM changes. |
| 4564 | if (typeof inst.tag === 'number') { |
| 4565 | while (inst['return']) { |
| 4566 | inst = inst['return']; |
| 4567 | } |
| 4568 | if (inst.tag !== HostRoot) { |
| 4569 | // This can happen if we're in a detached tree. |
| 4570 | return null; |
| 4571 | } |
| 4572 | return inst.stateNode.containerInfo; |
| 4573 | } else { |
| 4574 | while (inst._hostParent) { |
| 4575 | inst = inst._hostParent; |
| 4576 | } |
| 4577 | var rootNode = ReactDOMComponentTree_1.getNodeFromInstance(inst); |
| 4578 | return rootNode.parentNode; |
| 4579 | } |
| 4580 | } |
| 4581 | |
| 4582 | // Used to store ancestor hierarchy in top level callback |
| 4583 | function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { |
| 4584 | if (callbackBookkeepingPool.length) { |
| 4585 | var instance = callbackBookkeepingPool.pop(); |
| 4586 | instance.topLevelType = topLevelType; |
| 4587 | instance.nativeEvent = nativeEvent; |
| 4588 | instance.targetInst = targetInst; |
| 4589 | return instance; |
| 4590 | } |
| 4591 | return { |
| 4592 | topLevelType: topLevelType, |
| 4593 | nativeEvent: nativeEvent, |
| 4594 | targetInst: targetInst, |
| 4595 | ancestors: [] |
| 4596 | }; |
| 4597 | } |
| 4598 | |
| 4599 | function releaseTopLevelCallbackBookKeeping(instance) { |
| 4600 | instance.topLevelType = null; |
| 4601 | instance.nativeEvent = null; |
| 4602 | instance.targetInst = null; |
| 4603 | instance.ancestors.length = 0; |
| 4604 | if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { |
| 4605 | callbackBookkeepingPool.push(instance); |
| 4606 | } |
| 4607 | } |
| 4608 | |
| 4609 | function handleTopLevelImpl(bookKeeping) { |
| 4610 | var targetInst = bookKeeping.targetInst; |
| 4611 | |
| 4612 | // Loop through the hierarchy, in case there's any nested components. |
| 4613 | // It's important that we build the array of ancestors before calling any |
| 4614 | // event handlers, because event handlers can modify the DOM, leading to |
| 4615 | // inconsistencies with ReactMount's node cache. See #1105. |
| 4616 | var ancestor = targetInst; |
| 4617 | do { |
| 4618 | if (!ancestor) { |
| 4619 | bookKeeping.ancestors.push(ancestor); |
| 4620 | break; |
| 4621 | } |
| 4622 | var root = findRootContainerNode(ancestor); |
| 4623 | if (!root) { |
| 4624 | break; |
| 4625 | } |
| 4626 | bookKeeping.ancestors.push(ancestor); |
| 4627 | ancestor = ReactDOMComponentTree_1.getClosestInstanceFromNode(root); |
| 4628 | } while (ancestor); |
| 4629 | |
| 4630 | for (var i = 0; i < bookKeeping.ancestors.length; i++) { |
| 4631 | targetInst = bookKeeping.ancestors[i]; |
| 4632 | ReactDOMEventListener._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget_1(bookKeeping.nativeEvent)); |
| 4633 | } |
| 4634 | } |
| 4635 | |
| 4636 | var ReactDOMEventListener = { |
| 4637 | _enabled: true, |
| 4638 | _handleTopLevel: null, |
| 4639 | |
| 4640 | setHandleTopLevel: function (handleTopLevel) { |
| 4641 | ReactDOMEventListener._handleTopLevel = handleTopLevel; |
| 4642 | }, |
| 4643 | |
| 4644 | setEnabled: function (enabled) { |
| 4645 | ReactDOMEventListener._enabled = !!enabled; |
| 4646 | }, |
| 4647 | |
| 4648 | isEnabled: function () { |
| 4649 | return ReactDOMEventListener._enabled; |
| 4650 | }, |
| 4651 | |
| 4652 | /** |
| 4653 | * Traps top-level events by using event bubbling. |
| 4654 | * |
| 4655 | * @param {string} topLevelType Record from `BrowserEventConstants`. |
| 4656 | * @param {string} handlerBaseName Event name (e.g. "click"). |
| 4657 | * @param {object} element Element on which to attach listener. |
| 4658 | * @return {?object} An object with a remove function which will forcefully |
| 4659 | * remove the listener. |
| 4660 | * @internal |
| 4661 | */ |
| 4662 | trapBubbledEvent: function (topLevelType, handlerBaseName, element) { |
| 4663 | if (!element) { |
| 4664 | return null; |
| 4665 | } |
| 4666 | return EventListener.listen(element, handlerBaseName, ReactDOMEventListener.dispatchEvent.bind(null, topLevelType)); |
| 4667 | }, |
| 4668 | |
| 4669 | /** |
| 4670 | * Traps a top-level event by using event capturing. |
| 4671 | * |
| 4672 | * @param {string} topLevelType Record from `BrowserEventConstants`. |
| 4673 | * @param {string} handlerBaseName Event name (e.g. "click"). |
| 4674 | * @param {object} element Element on which to attach listener. |
| 4675 | * @return {?object} An object with a remove function which will forcefully |
| 4676 | * remove the listener. |
| 4677 | * @internal |
| 4678 | */ |
| 4679 | trapCapturedEvent: function (topLevelType, handlerBaseName, element) { |
| 4680 | if (!element) { |
| 4681 | return null; |
| 4682 | } |
| 4683 | return EventListener.capture(element, handlerBaseName, ReactDOMEventListener.dispatchEvent.bind(null, topLevelType)); |
| 4684 | }, |
| 4685 | |
| 4686 | dispatchEvent: function (topLevelType, nativeEvent) { |
| 4687 | if (!ReactDOMEventListener._enabled) { |
| 4688 | return; |
| 4689 | } |
| 4690 | |
| 4691 | var nativeEventTarget = getEventTarget_1(nativeEvent); |
| 4692 | var targetInst = ReactDOMComponentTree_1.getClosestInstanceFromNode(nativeEventTarget); |
| 4693 | if (targetInst !== null && typeof targetInst.tag === 'number' && !ReactFiberTreeReflection.isFiberMounted(targetInst)) { |
| 4694 | // If we get an event (ex: img onload) before committing that |
| 4695 | // component's mount, ignore it for now (that is, treat it as if it was an |
| 4696 | // event on a non-React tree). We might also consider queueing events and |
| 4697 | // dispatching them after the mount. |
| 4698 | targetInst = null; |
| 4699 | } |
| 4700 | |
| 4701 | var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst); |
| 4702 | |
| 4703 | try { |
| 4704 | // Event queue being processed in the same cycle allows |
| 4705 | // `preventDefault`. |
| 4706 | ReactGenericBatching_1.batchedUpdates(handleTopLevelImpl, bookKeeping); |
| 4707 | } finally { |
| 4708 | releaseTopLevelCallbackBookKeeping(bookKeeping); |
| 4709 | } |
| 4710 | } |
| 4711 | }; |
| 4712 | |
| 4713 | var ReactDOMEventListener_1 = ReactDOMEventListener; |
| 4714 | |
| 4715 | /** |
| 4716 | * Accumulates items that must not be null or undefined into the first one. This |
| 4717 | * is used to conserve memory by avoiding array allocations, and thus sacrifices |
| 4718 | * API cleanness. Since `current` can be null before being passed in and not |
| 4719 | * null after this function, make sure to assign it back to `current`: |
| 4720 | * |
| 4721 | * `a = accumulateInto(a, b);` |
| 4722 | * |
| 4723 | * This API should be sparingly used. Try `accumulate` for something cleaner. |
| 4724 | * |
| 4725 | * @return {*|array<*>} An accumulation of items. |
| 4726 | */ |
| 4727 | |
| 4728 | function accumulateInto(current, next) { |
| 4729 | !(next != null) ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0; |
| 4730 | |
| 4731 | if (current == null) { |
| 4732 | return next; |
| 4733 | } |
| 4734 | |
| 4735 | // Both are not empty. Warning: Never call x.concat(y) when you are not |
| 4736 | // certain that x is an Array (x could be a string with concat method). |
| 4737 | if (Array.isArray(current)) { |
| 4738 | if (Array.isArray(next)) { |
| 4739 | current.push.apply(current, next); |
| 4740 | return current; |
| 4741 | } |
| 4742 | current.push(next); |
| 4743 | return current; |
| 4744 | } |
| 4745 | |
| 4746 | if (Array.isArray(next)) { |
| 4747 | // A bit too dangerous to mutate `next`. |
| 4748 | return [current].concat(next); |
| 4749 | } |
| 4750 | |
| 4751 | return [current, next]; |
| 4752 | } |
| 4753 | |
| 4754 | var accumulateInto_1 = accumulateInto; |
| 4755 | |
| 4756 | /** |
| 4757 | * Copyright (c) 2013-present, Facebook, Inc. |
| 4758 | * |
| 4759 | * This source code is licensed under the MIT license found in the |
| 4760 | * LICENSE file in the root directory of this source tree. |
| 4761 | * |
| 4762 | * @providesModule forEachAccumulated |
| 4763 | * |
| 4764 | */ |
| 4765 | |
| 4766 | /** |
| 4767 | * @param {array} arr an "accumulation" of items which is either an Array or |
| 4768 | * a single item. Useful when paired with the `accumulate` module. This is a |
| 4769 | * simple utility that allows us to reason about a collection of items, but |
| 4770 | * handling the case when there is exactly one item (and we do not need to |
| 4771 | * allocate an array). |
| 4772 | * @param {function} cb Callback invoked with each element or a collection. |
| 4773 | * @param {?} [scope] Scope used as `this` in a callback. |
| 4774 | */ |
| 4775 | |
| 4776 | function forEachAccumulated(arr, cb, scope) { |
| 4777 | if (Array.isArray(arr)) { |
| 4778 | arr.forEach(cb, scope); |
| 4779 | } else if (arr) { |
| 4780 | cb.call(scope, arr); |
| 4781 | } |
| 4782 | } |
| 4783 | |
| 4784 | var forEachAccumulated_1 = forEachAccumulated; |
| 4785 | |
| 4786 | /** |
| 4787 | * Internal queue of events that have accumulated their dispatches and are |
| 4788 | * waiting to have their dispatches executed. |
| 4789 | */ |
| 4790 | var eventQueue = null; |
| 4791 | |
| 4792 | /** |
| 4793 | * Dispatches an event and releases it back into the pool, unless persistent. |
| 4794 | * |
| 4795 | * @param {?object} event Synthetic event to be dispatched. |
| 4796 | * @param {boolean} simulated If the event is simulated (changes exn behavior) |
| 4797 | * @private |
| 4798 | */ |
| 4799 | var executeDispatchesAndRelease = function (event, simulated) { |
| 4800 | if (event) { |
| 4801 | EventPluginUtils_1.executeDispatchesInOrder(event, simulated); |
| 4802 | |
| 4803 | if (!event.isPersistent()) { |
| 4804 | event.constructor.release(event); |
| 4805 | } |
| 4806 | } |
| 4807 | }; |
| 4808 | var executeDispatchesAndReleaseSimulated = function (e) { |
| 4809 | return executeDispatchesAndRelease(e, true); |
| 4810 | }; |
| 4811 | var executeDispatchesAndReleaseTopLevel = function (e) { |
| 4812 | return executeDispatchesAndRelease(e, false); |
| 4813 | }; |
| 4814 | |
| 4815 | function isInteractive(tag) { |
| 4816 | return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; |
| 4817 | } |
| 4818 | |
| 4819 | function shouldPreventMouseEvent(name, type, props) { |
| 4820 | switch (name) { |
| 4821 | case 'onClick': |
| 4822 | case 'onClickCapture': |
| 4823 | case 'onDoubleClick': |
| 4824 | case 'onDoubleClickCapture': |
| 4825 | case 'onMouseDown': |
| 4826 | case 'onMouseDownCapture': |
| 4827 | case 'onMouseMove': |
| 4828 | case 'onMouseMoveCapture': |
| 4829 | case 'onMouseUp': |
| 4830 | case 'onMouseUpCapture': |
| 4831 | return !!(props.disabled && isInteractive(type)); |
3293 | | function getDataFromCustomEvent(nativeEvent) { |
3294 | | var detail = nativeEvent.detail; |
3295 | | if (typeof detail === 'object' && 'data' in detail) { |
3296 | | return detail.data; |
3297 | | } |
3298 | | return null; |
3299 | | } |
3300 | | |
3301 | | // Track the current IME composition fallback object, if any. |
3302 | | var currentComposition = null; |
| 4859 | var EventPluginHub = { |
| 4860 | /** |
| 4861 | * Methods for injecting dependencies. |
| 4862 | */ |
| 4863 | injection: { |
| 4864 | /** |
| 4865 | * @param {array} InjectedEventPluginOrder |
| 4866 | * @public |
| 4867 | */ |
| 4868 | injectEventPluginOrder: EventPluginRegistry_1.injectEventPluginOrder, |
| 4869 | |
| 4870 | /** |
| 4871 | * @param {object} injectedNamesToPlugins Map from names to plugin modules. |
| 4872 | */ |
| 4873 | injectEventPluginsByName: EventPluginRegistry_1.injectEventPluginsByName |
| 4874 | }, |
| 4875 | |
| 4876 | /** |
| 4877 | * @param {object} inst The instance, which is the source of events. |
| 4878 | * @param {string} registrationName Name of listener (e.g. `onClick`). |
| 4879 | * @return {?function} The stored callback. |
| 4880 | */ |
| 4881 | getListener: function (inst, registrationName) { |
| 4882 | var listener; |
| 4883 | |
| 4884 | // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not |
| 4885 | // live here; needs to be moved to a better place soon |
| 4886 | if (typeof inst.tag === 'number') { |
| 4887 | var stateNode = inst.stateNode; |
| 4888 | if (!stateNode) { |
| 4889 | // Work in progress (ex: onload events in incremental mode). |
| 4890 | return null; |
| 4891 | } |
| 4892 | var props = EventPluginUtils_1.getFiberCurrentPropsFromNode(stateNode); |
| 4893 | if (!props) { |
| 4894 | // Work in progress. |
| 4895 | return null; |
| 4896 | } |
| 4897 | listener = props[registrationName]; |
| 4898 | if (shouldPreventMouseEvent(registrationName, inst.type, props)) { |
| 4899 | return null; |
| 4900 | } |
| 4901 | } else { |
| 4902 | var currentElement = inst._currentElement; |
| 4903 | if (typeof currentElement === 'string' || typeof currentElement === 'number') { |
| 4904 | // Text node, let it bubble through. |
| 4905 | return null; |
| 4906 | } |
| 4907 | if (!inst._rootNodeID) { |
| 4908 | // If the instance is already unmounted, we have no listeners. |
| 4909 | return null; |
| 4910 | } |
| 4911 | var _props = currentElement.props; |
| 4912 | listener = _props[registrationName]; |
| 4913 | if (shouldPreventMouseEvent(registrationName, currentElement.type, _props)) { |
| 4914 | return null; |
| 4915 | } |
| 4916 | } |
| 4917 | |
| 4918 | !(!listener || typeof listener === 'function') ? invariant(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0; |
| 4919 | return listener; |
| 4920 | }, |
| 4921 | |
| 4922 | /** |
| 4923 | * Allows registered plugins an opportunity to extract events from top-level |
| 4924 | * native browser events. |
| 4925 | * |
| 4926 | * @return {*} An accumulation of synthetic events. |
| 4927 | * @internal |
| 4928 | */ |
| 4929 | extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
| 4930 | var events; |
| 4931 | var plugins = EventPluginRegistry_1.plugins; |
| 4932 | for (var i = 0; i < plugins.length; i++) { |
| 4933 | // Not every plugin in the ordering may be loaded at runtime. |
| 4934 | var possiblePlugin = plugins[i]; |
| 4935 | if (possiblePlugin) { |
| 4936 | var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); |
| 4937 | if (extractedEvents) { |
| 4938 | events = accumulateInto_1(events, extractedEvents); |
| 4939 | } |
| 4940 | } |
| 4941 | } |
| 4942 | return events; |
| 4943 | }, |
| 4944 | |
| 4945 | /** |
| 4946 | * Enqueues a synthetic event that should be dispatched when |
| 4947 | * `processEventQueue` is invoked. |
| 4948 | * |
| 4949 | * @param {*} events An accumulation of synthetic events. |
| 4950 | * @internal |
| 4951 | */ |
| 4952 | enqueueEvents: function (events) { |
| 4953 | if (events) { |
| 4954 | eventQueue = accumulateInto_1(eventQueue, events); |
| 4955 | } |
| 4956 | }, |
| 4957 | |
| 4958 | /** |
| 4959 | * Dispatches all synthetic events on the event queue. |
| 4960 | * |
| 4961 | * @internal |
| 4962 | */ |
| 4963 | processEventQueue: function (simulated) { |
| 4964 | // Set `eventQueue` to null before processing it so that we can tell if more |
| 4965 | // events get enqueued while processing. |
| 4966 | var processingEventQueue = eventQueue; |
| 4967 | eventQueue = null; |
| 4968 | if (simulated) { |
| 4969 | forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseSimulated); |
| 4970 | } else { |
| 4971 | forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseTopLevel); |
| 4972 | } |
| 4973 | !!eventQueue ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0; |
| 4974 | // This would be a good time to rethrow if any of the event handlers threw. |
| 4975 | ReactErrorUtils_1.rethrowCaughtError(); |
| 4976 | } |
| 4977 | }; |
| 4978 | |
| 4979 | var EventPluginHub_1 = EventPluginHub; |
| 4980 | |
| 4981 | function runEventQueueInBatch(events) { |
| 4982 | EventPluginHub_1.enqueueEvents(events); |
| 4983 | EventPluginHub_1.processEventQueue(false); |
| 4984 | } |
| 4985 | |
| 4986 | var ReactEventEmitterMixin = { |
| 4987 | /** |
| 4988 | * Streams a fired top-level event to `EventPluginHub` where plugins have the |
| 4989 | * opportunity to create `ReactEvent`s to be dispatched. |
| 4990 | */ |
| 4991 | handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
| 4992 | var events = EventPluginHub_1.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); |
| 4993 | runEventQueueInBatch(events); |
| 4994 | } |
| 4995 | }; |
| 4996 | |
| 4997 | var ReactEventEmitterMixin_1 = ReactEventEmitterMixin; |
| 4998 | |
| 4999 | var useHasFeature; |
| 5000 | if (ExecutionEnvironment.canUseDOM) { |
| 5001 | useHasFeature = document.implementation && document.implementation.hasFeature && |
| 5002 | // always returns true in newer browsers as per the standard. |
| 5003 | // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature |
| 5004 | document.implementation.hasFeature('', '') !== true; |
| 5005 | } |
3507 | | var BeforeInputEventPlugin = { |
3508 | | eventTypes: eventTypes, |
3509 | | |
3510 | | extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
3511 | | return [extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget)]; |
3512 | | } |
| 5082 | var style = {}; |
| 5083 | |
| 5084 | /** |
| 5085 | * Bootstrap if a DOM exists. |
| 5086 | */ |
| 5087 | if (ExecutionEnvironment.canUseDOM) { |
| 5088 | style = document.createElement('div').style; |
| 5089 | |
| 5090 | // On some platforms, in particular some releases of Android 4.x, |
| 5091 | // the un-prefixed "animation" and "transition" properties are defined on the |
| 5092 | // style object but the events that fire will still be prefixed, so we need |
| 5093 | // to check if the un-prefixed events are usable, and if not remove them from the map. |
| 5094 | if (!('AnimationEvent' in window)) { |
| 5095 | delete vendorPrefixes.animationend.animation; |
| 5096 | delete vendorPrefixes.animationiteration.animation; |
| 5097 | delete vendorPrefixes.animationstart.animation; |
| 5098 | } |
| 5099 | |
| 5100 | // Same as above |
| 5101 | if (!('TransitionEvent' in window)) { |
| 5102 | delete vendorPrefixes.transitionend.transition; |
| 5103 | } |
| 5104 | } |
| 5105 | |
| 5106 | /** |
| 5107 | * Attempts to determine the correct vendor prefixed event name. |
| 5108 | * |
| 5109 | * @param {string} eventName |
| 5110 | * @returns {string} |
| 5111 | */ |
| 5112 | function getVendorPrefixedEventName(eventName) { |
| 5113 | if (prefixedEventNames[eventName]) { |
| 5114 | return prefixedEventNames[eventName]; |
| 5115 | } else if (!vendorPrefixes[eventName]) { |
| 5116 | return eventName; |
| 5117 | } |
| 5118 | |
| 5119 | var prefixMap = vendorPrefixes[eventName]; |
| 5120 | |
| 5121 | for (var styleProp in prefixMap) { |
| 5122 | if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { |
| 5123 | return prefixedEventNames[eventName] = prefixMap[styleProp]; |
| 5124 | } |
| 5125 | } |
| 5126 | |
| 5127 | return ''; |
| 5128 | } |
| 5129 | |
| 5130 | var getVendorPrefixedEventName_1 = getVendorPrefixedEventName; |
| 5131 | |
| 5132 | /** |
| 5133 | * Types of raw signals from the browser caught at the top level. |
| 5134 | * |
| 5135 | * For events like 'submit' which don't consistently bubble (which we |
| 5136 | * trap at a lower node than `document`), binding at `document` would |
| 5137 | * cause duplicate events so we don't include them here. |
| 5138 | */ |
| 5139 | var topLevelTypes$1 = { |
| 5140 | topAbort: 'abort', |
| 5141 | topAnimationEnd: getVendorPrefixedEventName_1('animationend') || 'animationend', |
| 5142 | topAnimationIteration: getVendorPrefixedEventName_1('animationiteration') || 'animationiteration', |
| 5143 | topAnimationStart: getVendorPrefixedEventName_1('animationstart') || 'animationstart', |
| 5144 | topBlur: 'blur', |
| 5145 | topCancel: 'cancel', |
| 5146 | topCanPlay: 'canplay', |
| 5147 | topCanPlayThrough: 'canplaythrough', |
| 5148 | topChange: 'change', |
| 5149 | topClick: 'click', |
| 5150 | topClose: 'close', |
| 5151 | topCompositionEnd: 'compositionend', |
| 5152 | topCompositionStart: 'compositionstart', |
| 5153 | topCompositionUpdate: 'compositionupdate', |
| 5154 | topContextMenu: 'contextmenu', |
| 5155 | topCopy: 'copy', |
| 5156 | topCut: 'cut', |
| 5157 | topDoubleClick: 'dblclick', |
| 5158 | topDrag: 'drag', |
| 5159 | topDragEnd: 'dragend', |
| 5160 | topDragEnter: 'dragenter', |
| 5161 | topDragExit: 'dragexit', |
| 5162 | topDragLeave: 'dragleave', |
| 5163 | topDragOver: 'dragover', |
| 5164 | topDragStart: 'dragstart', |
| 5165 | topDrop: 'drop', |
| 5166 | topDurationChange: 'durationchange', |
| 5167 | topEmptied: 'emptied', |
| 5168 | topEncrypted: 'encrypted', |
| 5169 | topEnded: 'ended', |
| 5170 | topError: 'error', |
| 5171 | topFocus: 'focus', |
| 5172 | topInput: 'input', |
| 5173 | topKeyDown: 'keydown', |
| 5174 | topKeyPress: 'keypress', |
| 5175 | topKeyUp: 'keyup', |
| 5176 | topLoadedData: 'loadeddata', |
| 5177 | topLoad: 'load', |
| 5178 | topLoadedMetadata: 'loadedmetadata', |
| 5179 | topLoadStart: 'loadstart', |
| 5180 | topMouseDown: 'mousedown', |
| 5181 | topMouseMove: 'mousemove', |
| 5182 | topMouseOut: 'mouseout', |
| 5183 | topMouseOver: 'mouseover', |
| 5184 | topMouseUp: 'mouseup', |
| 5185 | topPaste: 'paste', |
| 5186 | topPause: 'pause', |
| 5187 | topPlay: 'play', |
| 5188 | topPlaying: 'playing', |
| 5189 | topProgress: 'progress', |
| 5190 | topRateChange: 'ratechange', |
| 5191 | topScroll: 'scroll', |
| 5192 | topSeeked: 'seeked', |
| 5193 | topSeeking: 'seeking', |
| 5194 | topSelectionChange: 'selectionchange', |
| 5195 | topStalled: 'stalled', |
| 5196 | topSuspend: 'suspend', |
| 5197 | topTextInput: 'textInput', |
| 5198 | topTimeUpdate: 'timeupdate', |
| 5199 | topToggle: 'toggle', |
| 5200 | topTouchCancel: 'touchcancel', |
| 5201 | topTouchEnd: 'touchend', |
| 5202 | topTouchMove: 'touchmove', |
| 5203 | topTouchStart: 'touchstart', |
| 5204 | topTransitionEnd: getVendorPrefixedEventName_1('transitionend') || 'transitionend', |
| 5205 | topVolumeChange: 'volumechange', |
| 5206 | topWaiting: 'waiting', |
| 5207 | topWheel: 'wheel' |
3527 | | 'use strict'; |
| 5274 | var alreadyListeningTo = {}; |
| 5275 | var reactTopListenersCounter = 0; |
| 5276 | |
| 5277 | /** |
| 5278 | * To ensure no conflicts with other potential React instances on the page |
| 5279 | */ |
| 5280 | var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); |
| 5281 | |
| 5282 | function getListeningForDocument(mountAt) { |
| 5283 | // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` |
| 5284 | // directly. |
| 5285 | if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { |
| 5286 | mountAt[topListenersIDKey] = reactTopListenersCounter++; |
| 5287 | alreadyListeningTo[mountAt[topListenersIDKey]] = {}; |
| 5288 | } |
| 5289 | return alreadyListeningTo[mountAt[topListenersIDKey]]; |
| 5290 | } |
| 5291 | |
| 5292 | var ReactBrowserEventEmitter = _assign({}, ReactEventEmitterMixin_1, { |
| 5293 | /** |
| 5294 | * Sets whether or not any created callbacks should be enabled. |
| 5295 | * |
| 5296 | * @param {boolean} enabled True if callbacks should be enabled. |
| 5297 | */ |
| 5298 | setEnabled: function (enabled) { |
| 5299 | if (ReactDOMEventListener_1) { |
| 5300 | ReactDOMEventListener_1.setEnabled(enabled); |
| 5301 | } |
| 5302 | }, |
| 5303 | |
| 5304 | /** |
| 5305 | * @return {boolean} True if callbacks are enabled. |
| 5306 | */ |
| 5307 | isEnabled: function () { |
| 5308 | return !!(ReactDOMEventListener_1 && ReactDOMEventListener_1.isEnabled()); |
| 5309 | }, |
| 5310 | |
| 5311 | /** |
| 5312 | * We listen for bubbled touch events on the document object. |
| 5313 | * |
| 5314 | * Firefox v8.01 (and possibly others) exhibited strange behavior when |
| 5315 | * mounting `onmousemove` events at some node that was not the document |
| 5316 | * element. The symptoms were that if your mouse is not moving over something |
| 5317 | * contained within that mount point (for example on the background) the |
| 5318 | * top-level listeners for `onmousemove` won't be called. However, if you |
| 5319 | * register the `mousemove` on the document object, then it will of course |
| 5320 | * catch all `mousemove`s. This along with iOS quirks, justifies restricting |
| 5321 | * top-level listeners to the document object only, at least for these |
| 5322 | * movement types of events and possibly all events. |
| 5323 | * |
| 5324 | * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html |
| 5325 | * |
| 5326 | * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but |
| 5327 | * they bubble to document. |
| 5328 | * |
| 5329 | * @param {string} registrationName Name of listener (e.g. `onClick`). |
| 5330 | * @param {object} contentDocumentHandle Document which owns the container |
| 5331 | */ |
| 5332 | listenTo: function (registrationName, contentDocumentHandle) { |
| 5333 | var mountAt = contentDocumentHandle; |
| 5334 | var isListening = getListeningForDocument(mountAt); |
| 5335 | var dependencies = EventPluginRegistry_1.registrationNameDependencies[registrationName]; |
| 5336 | |
| 5337 | for (var i = 0; i < dependencies.length; i++) { |
| 5338 | var dependency = dependencies[i]; |
| 5339 | if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { |
| 5340 | if (dependency === 'topWheel') { |
| 5341 | if (isEventSupported_1('wheel')) { |
| 5342 | ReactDOMEventListener_1.trapBubbledEvent('topWheel', 'wheel', mountAt); |
| 5343 | } else if (isEventSupported_1('mousewheel')) { |
| 5344 | ReactDOMEventListener_1.trapBubbledEvent('topWheel', 'mousewheel', mountAt); |
| 5345 | } else { |
| 5346 | // Firefox needs to capture a different mouse scroll event. |
| 5347 | // @see http://www.quirksmode.org/dom/events/tests/scroll.html |
| 5348 | ReactDOMEventListener_1.trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt); |
| 5349 | } |
| 5350 | } else if (dependency === 'topScroll') { |
| 5351 | ReactDOMEventListener_1.trapCapturedEvent('topScroll', 'scroll', mountAt); |
| 5352 | } else if (dependency === 'topFocus' || dependency === 'topBlur') { |
| 5353 | ReactDOMEventListener_1.trapCapturedEvent('topFocus', 'focus', mountAt); |
| 5354 | ReactDOMEventListener_1.trapCapturedEvent('topBlur', 'blur', mountAt); |
| 5355 | |
| 5356 | // to make sure blur and focus event listeners are only attached once |
| 5357 | isListening.topBlur = true; |
| 5358 | isListening.topFocus = true; |
| 5359 | } else if (dependency === 'topCancel') { |
| 5360 | if (isEventSupported_1('cancel', true)) { |
| 5361 | ReactDOMEventListener_1.trapCapturedEvent('topCancel', 'cancel', mountAt); |
| 5362 | } |
| 5363 | isListening.topCancel = true; |
| 5364 | } else if (dependency === 'topClose') { |
| 5365 | if (isEventSupported_1('close', true)) { |
| 5366 | ReactDOMEventListener_1.trapCapturedEvent('topClose', 'close', mountAt); |
| 5367 | } |
| 5368 | isListening.topClose = true; |
| 5369 | } else if (topLevelTypes.hasOwnProperty(dependency)) { |
| 5370 | ReactDOMEventListener_1.trapBubbledEvent(dependency, topLevelTypes[dependency], mountAt); |
| 5371 | } |
| 5372 | |
| 5373 | isListening[dependency] = true; |
| 5374 | } |
| 5375 | } |
| 5376 | }, |
| 5377 | |
| 5378 | isListeningToAllDependencies: function (registrationName, mountAt) { |
| 5379 | var isListening = getListeningForDocument(mountAt); |
| 5380 | var dependencies = EventPluginRegistry_1.registrationNameDependencies[registrationName]; |
| 5381 | for (var i = 0; i < dependencies.length; i++) { |
| 5382 | var dependency = dependencies[i]; |
| 5383 | if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { |
| 5384 | return false; |
| 5385 | } |
| 5386 | } |
| 5387 | return true; |
| 5388 | }, |
| 5389 | |
| 5390 | trapBubbledEvent: function (topLevelType, handlerBaseName, handle) { |
| 5391 | return ReactDOMEventListener_1.trapBubbledEvent(topLevelType, handlerBaseName, handle); |
| 5392 | }, |
| 5393 | |
| 5394 | trapCapturedEvent: function (topLevelType, handlerBaseName, handle) { |
| 5395 | return ReactDOMEventListener_1.trapCapturedEvent(topLevelType, handlerBaseName, handle); |
| 5396 | } |
| 5397 | }); |
| 5398 | |
| 5399 | var ReactBrowserEventEmitter_1 = ReactBrowserEventEmitter; |
| 5400 | |
| 5401 | /** |
| 5402 | * Copyright (c) 2013-present, Facebook, Inc. |
| 5403 | * |
| 5404 | * This source code is licensed under the MIT license found in the |
| 5405 | * LICENSE file in the root directory of this source tree. |
| 5406 | * |
| 5407 | * @providesModule ReactDOMFeatureFlags |
| 5408 | */ |
| 5409 | |
| 5410 | var ReactDOMFeatureFlags = { |
| 5411 | fiberAsyncScheduling: false, |
| 5412 | useFiber: true |
| 5413 | }; |
| 5414 | |
| 5415 | var ReactDOMFeatureFlags_1 = ReactDOMFeatureFlags; |
| 5416 | |
| 5417 | /** |
| 5418 | * Copyright (c) 2013-present, Facebook, Inc. |
| 5419 | * |
| 5420 | * This source code is licensed under the MIT license found in the |
| 5421 | * LICENSE file in the root directory of this source tree. |
| 5422 | * |
| 5423 | * @providesModule CSSProperty |
| 5424 | */ |
3681 | | |
3682 | | 'use strict'; |
3683 | | |
3684 | | var CSSProperty = require('./CSSProperty'); |
3685 | | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); |
3686 | | var ReactInstrumentation = require('./ReactInstrumentation'); |
3687 | | |
3688 | | var camelizeStyleName = require('fbjs/lib/camelizeStyleName'); |
3689 | | var dangerousStyleValue = require('./dangerousStyleValue'); |
3690 | | var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName'); |
3691 | | var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly'); |
3692 | | var warning = require('fbjs/lib/warning'); |
3693 | | |
3694 | | var processStyleName = memoizeStringOnly(function (styleName) { |
3695 | | return hyphenateStyleName(styleName); |
3696 | | }); |
| 5580 | function dangerousStyleValue(name, value, isCustomProperty) { |
| 5581 | // Note that we've removed escapeTextForBrowser() calls here since the |
| 5582 | // whole string will be escaped when the attribute is injected into |
| 5583 | // the markup. If you provide unsafe user data here they can inject |
| 5584 | // arbitrary CSS which may be problematic (I couldn't repro this): |
| 5585 | // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
| 5586 | // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ |
| 5587 | // This is not an XSS hole but instead a potential CSS injection issue |
| 5588 | // which has lead to a greater discussion about how we're going to |
| 5589 | // trust URLs moving forward. See #2115901 |
| 5590 | |
| 5591 | var isEmpty = value == null || typeof value === 'boolean' || value === ''; |
| 5592 | if (isEmpty) { |
| 5593 | return ''; |
| 5594 | } |
| 5595 | |
| 5596 | if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber$1.hasOwnProperty(name) && isUnitlessNumber$1[name])) { |
| 5597 | return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers |
| 5598 | } |
| 5599 | |
| 5600 | return ('' + value).trim(); |
| 5601 | } |
| 5602 | |
| 5603 | var dangerousStyleValue_1 = dangerousStyleValue; |
| 5604 | |
| 5605 | /** |
| 5606 | * Copyright (c) 2016-present, Facebook, Inc. |
| 5607 | * |
| 5608 | * This source code is licensed under the MIT license found in the |
| 5609 | * LICENSE file in the root directory of this source tree. |
| 5610 | * |
| 5611 | * |
| 5612 | * @providesModule describeComponentFrame |
| 5613 | */ |
| 5614 | |
| 5615 | var describeComponentFrame = function (name, source, ownerName) { |
| 5616 | return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); |
| 5617 | }; |
| 5618 | |
| 5619 | var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent; |
| 5620 | var FunctionalComponent = ReactTypeOfWork.FunctionalComponent; |
| 5621 | var ClassComponent$1 = ReactTypeOfWork.ClassComponent; |
| 5622 | var HostComponent$2 = ReactTypeOfWork.HostComponent; |
| 5623 | |
| 5624 | |
| 5625 | |
| 5626 | |
| 5627 | function describeFiber(fiber) { |
| 5628 | switch (fiber.tag) { |
| 5629 | case IndeterminateComponent: |
| 5630 | case FunctionalComponent: |
| 5631 | case ClassComponent$1: |
| 5632 | case HostComponent$2: |
| 5633 | var owner = fiber._debugOwner; |
| 5634 | var source = fiber._debugSource; |
| 5635 | var name = getComponentName_1(fiber); |
| 5636 | var ownerName = null; |
| 5637 | if (owner) { |
| 5638 | ownerName = getComponentName_1(owner); |
| 5639 | } |
| 5640 | return describeComponentFrame(name, source, ownerName); |
| 5641 | default: |
| 5642 | return ''; |
| 5643 | } |
| 5644 | } |
| 5645 | |
| 5646 | // This function can only be called with a work-in-progress fiber and |
| 5647 | // only during begin or complete phase. Do not call it under any other |
| 5648 | // circumstances. |
| 5649 | function getStackAddendumByWorkInProgressFiber$1(workInProgress) { |
| 5650 | var info = ''; |
| 5651 | var node = workInProgress; |
| 5652 | do { |
| 5653 | info += describeFiber(node); |
| 5654 | // Otherwise this return pointer might point to the wrong tree: |
| 5655 | node = node['return']; |
| 5656 | } while (node); |
| 5657 | return info; |
| 5658 | } |
| 5659 | |
| 5660 | var ReactFiberComponentTreeHook = { |
| 5661 | getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1 |
| 5662 | }; |
| 5663 | |
| 5664 | var ReactDebugCurrentFrame = ReactGlobalSharedState_1.ReactDebugCurrentFrame; |
| 5665 | |
| 5666 | { |
| 5667 | var getComponentName$3 = getComponentName_1; |
| 5668 | |
| 5669 | var _require2$2 = ReactFiberComponentTreeHook, |
| 5670 | getStackAddendumByWorkInProgressFiber = _require2$2.getStackAddendumByWorkInProgressFiber; |
| 5671 | } |
| 5672 | |
| 5673 | function getCurrentFiberOwnerName$2() { |
| 5674 | { |
| 5675 | var fiber = ReactDebugCurrentFiber.current; |
| 5676 | if (fiber === null) { |
| 5677 | return null; |
| 5678 | } |
| 5679 | if (fiber._debugOwner != null) { |
| 5680 | return getComponentName$3(fiber._debugOwner); |
| 5681 | } |
| 5682 | } |
| 5683 | return null; |
| 5684 | } |
| 5685 | |
| 5686 | function getCurrentFiberStackAddendum$1() { |
| 5687 | { |
| 5688 | var fiber = ReactDebugCurrentFiber.current; |
| 5689 | if (fiber === null) { |
| 5690 | return null; |
| 5691 | } |
| 5692 | // Safe because if current fiber exists, we are reconciling, |
| 5693 | // and it is guaranteed to be the work-in-progress version. |
| 5694 | return getStackAddendumByWorkInProgressFiber(fiber); |
| 5695 | } |
| 5696 | return null; |
| 5697 | } |
| 5698 | |
| 5699 | function resetCurrentFiber() { |
| 5700 | ReactDebugCurrentFrame.getCurrentStack = null; |
| 5701 | ReactDebugCurrentFiber.current = null; |
| 5702 | ReactDebugCurrentFiber.phase = null; |
| 5703 | } |
| 5704 | |
| 5705 | function setCurrentFiber(fiber, phase) { |
| 5706 | ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackAddendum$1; |
| 5707 | ReactDebugCurrentFiber.current = fiber; |
| 5708 | ReactDebugCurrentFiber.phase = phase; |
| 5709 | } |
| 5710 | |
| 5711 | var ReactDebugCurrentFiber = { |
| 5712 | current: null, |
| 5713 | phase: null, |
| 5714 | resetCurrentFiber: resetCurrentFiber, |
| 5715 | setCurrentFiber: setCurrentFiber, |
| 5716 | getCurrentFiberOwnerName: getCurrentFiberOwnerName$2, |
| 5717 | getCurrentFiberStackAddendum: getCurrentFiberStackAddendum$1 |
| 5718 | }; |
| 5719 | |
| 5720 | var ReactDebugCurrentFiber_1 = ReactDebugCurrentFiber; |
| 5721 | |
| 5722 | var warnValidStyle$1 = emptyFunction; |
| 5723 | |
| 5724 | { |
| 5725 | var camelizeStyleName$1 = camelizeStyleName; |
| 5726 | var getComponentName$2 = getComponentName_1; |
| 5727 | var warning$4 = require$$0; |
| 5728 | |
| 5729 | var _require$3 = ReactDebugCurrentFiber_1, |
| 5730 | getCurrentFiberOwnerName$1 = _require$3.getCurrentFiberOwnerName; |
| 5731 | |
| 5732 | // 'msTransform' is correct, but the other prefixes should be capitalized |
| 5733 | |
| 5734 | |
| 5735 | var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; |
| 5736 | |
| 5737 | // style values shouldn't contain a semicolon |
| 5738 | var badStyleValueWithSemicolonPattern = /;\s*$/; |
| 5739 | |
| 5740 | var warnedStyleNames = {}; |
| 5741 | var warnedStyleValues = {}; |
| 5742 | var warnedForNaNValue = false; |
| 5743 | var warnedForInfinityValue = false; |
| 5744 | |
| 5745 | var warnHyphenatedStyleName = function (name, owner) { |
| 5746 | if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { |
| 5747 | return; |
| 5748 | } |
| 5749 | |
| 5750 | warnedStyleNames[name] = true; |
| 5751 | warning$4(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName$1(name), checkRenderMessage(owner)); |
| 5752 | }; |
| 5753 | |
| 5754 | var warnBadVendoredStyleName = function (name, owner) { |
| 5755 | if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { |
| 5756 | return; |
| 5757 | } |
| 5758 | |
| 5759 | warnedStyleNames[name] = true; |
| 5760 | warning$4(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)); |
| 5761 | }; |
| 5762 | |
| 5763 | var warnStyleValueWithSemicolon = function (name, value, owner) { |
| 5764 | if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { |
| 5765 | return; |
| 5766 | } |
| 5767 | |
| 5768 | warnedStyleValues[value] = true; |
| 5769 | warning$4(false, "Style property values shouldn't contain a semicolon.%s " + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')); |
| 5770 | }; |
| 5771 | |
| 5772 | var warnStyleValueIsNaN = function (name, value, owner) { |
| 5773 | if (warnedForNaNValue) { |
| 5774 | return; |
| 5775 | } |
| 5776 | |
| 5777 | warnedForNaNValue = true; |
| 5778 | warning$4(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)); |
| 5779 | }; |
| 5780 | |
| 5781 | var warnStyleValueIsInfinity = function (name, value, owner) { |
| 5782 | if (warnedForInfinityValue) { |
| 5783 | return; |
| 5784 | } |
| 5785 | |
| 5786 | warnedForInfinityValue = true; |
| 5787 | warning$4(false, '`Infinity` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)); |
| 5788 | }; |
| 5789 | |
| 5790 | var checkRenderMessage = function (owner) { |
| 5791 | var ownerName; |
| 5792 | if (owner != null) { |
| 5793 | // Stack passes the owner manually all the way to CSSPropertyOperations. |
| 5794 | ownerName = getComponentName$2(owner); |
| 5795 | } else { |
| 5796 | // Fiber doesn't pass it but uses ReactDebugCurrentFiber to track it. |
| 5797 | // It is only enabled in development and tracks host components too. |
| 5798 | ownerName = getCurrentFiberOwnerName$1(); |
| 5799 | // TODO: also report the stack. |
| 5800 | } |
| 5801 | if (ownerName) { |
| 5802 | return '\n\nCheck the render method of `' + ownerName + '`.'; |
| 5803 | } |
| 5804 | return ''; |
| 5805 | }; |
| 5806 | |
| 5807 | warnValidStyle$1 = function (name, value, component) { |
| 5808 | var owner; |
| 5809 | if (component) { |
| 5810 | // TODO: this only works with Stack. Seems like we need to add unit tests? |
| 5811 | owner = component._currentElement._owner; |
| 5812 | } |
| 5813 | if (name.indexOf('-') > -1) { |
| 5814 | warnHyphenatedStyleName(name, owner); |
| 5815 | } else if (badVendoredStyleNamePattern.test(name)) { |
| 5816 | warnBadVendoredStyleName(name, owner); |
| 5817 | } else if (badStyleValueWithSemicolonPattern.test(value)) { |
| 5818 | warnStyleValueWithSemicolon(name, value, owner); |
| 5819 | } |
| 5820 | |
| 5821 | if (typeof value === 'number') { |
| 5822 | if (isNaN(value)) { |
| 5823 | warnStyleValueIsNaN(name, value, owner); |
| 5824 | } else if (!isFinite(value)) { |
| 5825 | warnStyleValueIsInfinity(name, value, owner); |
| 5826 | } |
| 5827 | } |
| 5828 | }; |
| 5829 | } |
| 5830 | |
| 5831 | var warnValidStyle_1 = warnValidStyle$1; |
| 5832 | |
| 5833 | { |
| 5834 | var hyphenateStyleName$1 = hyphenateStyleName; |
| 5835 | var warnValidStyle = warnValidStyle_1; |
| 5836 | } |
4003 | | return CallbackQueue; |
4004 | | }(); |
4005 | | |
4006 | | module.exports = PooledClass.addPoolingTo(CallbackQueue); |
4007 | | }).call(this,require('_process')) |
4008 | | },{"./PooledClass":62,"./reactProdInvariant":158,"_process":1,"fbjs/lib/invariant":23}],45:[function(require,module,exports){ |
4009 | | /** |
4010 | | * Copyright 2013-present, Facebook, Inc. |
4011 | | * All rights reserved. |
4012 | | * |
4013 | | * This source code is licensed under the BSD-style license found in the |
4014 | | * LICENSE file in the root directory of this source tree. An additional grant |
4015 | | * of patent rights can be found in the PATENTS file in the same directory. |
4016 | | * |
4017 | | */ |
4018 | | |
4019 | | 'use strict'; |
4020 | | |
4021 | | var EventPluginHub = require('./EventPluginHub'); |
4022 | | var EventPropagators = require('./EventPropagators'); |
4023 | | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); |
4024 | | var ReactDOMComponentTree = require('./ReactDOMComponentTree'); |
4025 | | var ReactUpdates = require('./ReactUpdates'); |
4026 | | var SyntheticEvent = require('./SyntheticEvent'); |
4027 | | |
4028 | | var inputValueTracking = require('./inputValueTracking'); |
4029 | | var getEventTarget = require('./getEventTarget'); |
4030 | | var isEventSupported = require('./isEventSupported'); |
4031 | | var isTextInputElement = require('./isTextInputElement'); |
4032 | | |
4033 | | var eventTypes = { |
4034 | | change: { |
4035 | | phasedRegistrationNames: { |
4036 | | bubbled: 'onChange', |
4037 | | captured: 'onChangeCapture' |
| 6083 | var checkDebugID = function (debugID) { |
| 6084 | var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
| 6085 | |
| 6086 | if (allowRoot && debugID === 0) { |
| 6087 | return; |
| 6088 | } |
| 6089 | if (!debugID) { |
| 6090 | warning$6(false, 'ReactDebugTool: debugID may not be empty.'); |
| 6091 | } |
| 6092 | }; |
| 6093 | |
| 6094 | var beginLifeCycleTimer = function (debugID, timerType) { |
| 6095 | if (currentFlushNesting === 0) { |
| 6096 | return; |
| 6097 | } |
| 6098 | if (currentTimerType && !lifeCycleTimerHasWarned) { |
| 6099 | warning$6(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); |
| 6100 | lifeCycleTimerHasWarned = true; |
| 6101 | } |
| 6102 | currentTimerStartTime = performanceNow(); |
| 6103 | currentTimerNestedFlushDuration = 0; |
| 6104 | currentTimerDebugID = debugID; |
| 6105 | currentTimerType = timerType; |
| 6106 | }; |
| 6107 | |
| 6108 | var endLifeCycleTimer = function (debugID, timerType) { |
| 6109 | if (currentFlushNesting === 0) { |
| 6110 | return; |
| 6111 | } |
| 6112 | if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) { |
| 6113 | warning$6(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); |
| 6114 | lifeCycleTimerHasWarned = true; |
| 6115 | } |
| 6116 | if (isProfiling) { |
| 6117 | currentFlushMeasurements.push({ |
| 6118 | timerType: timerType, |
| 6119 | instanceID: debugID, |
| 6120 | duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration |
| 6121 | }); |
| 6122 | } |
| 6123 | currentTimerStartTime = 0; |
| 6124 | currentTimerNestedFlushDuration = 0; |
| 6125 | currentTimerDebugID = null; |
| 6126 | currentTimerType = null; |
| 6127 | }; |
| 6128 | |
| 6129 | var pauseCurrentLifeCycleTimer = function () { |
| 6130 | var currentTimer = { |
| 6131 | startTime: currentTimerStartTime, |
| 6132 | nestedFlushStartTime: performanceNow(), |
| 6133 | debugID: currentTimerDebugID, |
| 6134 | timerType: currentTimerType |
| 6135 | }; |
| 6136 | lifeCycleTimerStack.push(currentTimer); |
| 6137 | currentTimerStartTime = 0; |
| 6138 | currentTimerNestedFlushDuration = 0; |
| 6139 | currentTimerDebugID = null; |
| 6140 | currentTimerType = null; |
| 6141 | }; |
| 6142 | |
| 6143 | var resumeCurrentLifeCycleTimer = function () { |
| 6144 | var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(), |
| 6145 | startTime = _lifeCycleTimerStack$.startTime, |
| 6146 | nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime, |
| 6147 | debugID = _lifeCycleTimerStack$.debugID, |
| 6148 | timerType = _lifeCycleTimerStack$.timerType; |
| 6149 | |
| 6150 | var nestedFlushDuration = performanceNow() - nestedFlushStartTime; |
| 6151 | currentTimerStartTime = startTime; |
| 6152 | currentTimerNestedFlushDuration += nestedFlushDuration; |
| 6153 | currentTimerDebugID = debugID; |
| 6154 | currentTimerType = timerType; |
| 6155 | }; |
| 6156 | |
| 6157 | var lastMarkTimeStamp = 0; |
| 6158 | var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; |
| 6159 | |
| 6160 | var shouldMark = function (debugID) { |
| 6161 | if (!isProfiling || !canUsePerformanceMeasure) { |
| 6162 | return false; |
| 6163 | } |
| 6164 | var element = ReactComponentTreeHook.getElement(debugID); |
| 6165 | if (element == null || typeof element !== 'object') { |
| 6166 | return false; |
| 6167 | } |
| 6168 | var isHostElement = typeof element.type === 'string'; |
| 6169 | if (isHostElement) { |
| 6170 | return false; |
| 6171 | } |
| 6172 | return true; |
| 6173 | }; |
| 6174 | |
| 6175 | var markBegin = function (debugID, markType) { |
| 6176 | if (!shouldMark(debugID)) { |
| 6177 | return; |
| 6178 | } |
| 6179 | |
| 6180 | var markName = debugID + '::' + markType; |
| 6181 | lastMarkTimeStamp = performanceNow(); |
| 6182 | performance.mark(markName); |
| 6183 | }; |
| 6184 | |
| 6185 | var markEnd = function (debugID, markType) { |
| 6186 | if (!shouldMark(debugID)) { |
| 6187 | return; |
| 6188 | } |
| 6189 | |
| 6190 | var markName = debugID + '::' + markType; |
| 6191 | var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown'; |
| 6192 | |
| 6193 | // Chrome has an issue of dropping markers recorded too fast: |
| 6194 | // https://bugs.chromium.org/p/chromium/issues/detail?id=640652 |
| 6195 | // To work around this, we will not report very small measurements. |
| 6196 | // I determined the magic number by tweaking it back and forth. |
| 6197 | // 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe. |
| 6198 | // When the bug is fixed, we can `measure()` unconditionally if we want to. |
| 6199 | var timeStamp = performanceNow(); |
| 6200 | if (timeStamp - lastMarkTimeStamp > 0.1) { |
| 6201 | var measurementName = displayName + ' [' + markType + ']'; |
| 6202 | performance.measure(measurementName, markName); |
| 6203 | } |
| 6204 | |
| 6205 | performance.clearMarks(markName); |
| 6206 | if (measurementName) { |
| 6207 | performance.clearMeasures(measurementName); |
| 6208 | } |
| 6209 | }; |
| 6210 | |
| 6211 | ReactDebugTool$1 = { |
| 6212 | addHook: function (hook) { |
| 6213 | hooks.push(hook); |
4039 | | dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange'] |
4040 | | } |
4041 | | }; |
4042 | | |
4043 | | function createAndAccumulateChangeEvent(inst, nativeEvent, target) { |
4044 | | var event = SyntheticEvent.getPooled(eventTypes.change, inst, nativeEvent, target); |
4045 | | event.type = 'change'; |
4046 | | EventPropagators.accumulateTwoPhaseDispatches(event); |
4047 | | return event; |
4048 | | } |
4049 | | /** |
4050 | | * For IE shims |
4051 | | */ |
4052 | | var activeElement = null; |
4053 | | var activeElementInst = null; |
4054 | | |
4055 | | /** |
4056 | | * SECTION: handle `change` event |
4057 | | */ |
4058 | | function shouldUseChangeEvent(elem) { |
4059 | | var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); |
4060 | | return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; |
4061 | | } |
4062 | | |
4063 | | var doesChangeEventBubble = false; |
4064 | | if (ExecutionEnvironment.canUseDOM) { |
4065 | | // See `handleChange` comment below |
4066 | | doesChangeEventBubble = isEventSupported('change') && (!document.documentMode || document.documentMode > 8); |
4067 | | } |
4068 | | |
4069 | | function manualDispatchChangeEvent(nativeEvent) { |
4070 | | var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); |
4071 | | |
4072 | | // If change and propertychange bubbled, we'd just bind to it like all the |
4073 | | // other events and have it go through ReactBrowserEventEmitter. Since it |
4074 | | // doesn't, we manually listen for the events and so we have to enqueue and |
4075 | | // process the abstract event manually. |
4076 | | // |
4077 | | // Batching is necessary here in order to ensure that all event handlers run |
4078 | | // before the next rerender (including event handlers attached to ancestor |
4079 | | // elements instead of directly on the input). Without this, controlled |
4080 | | // components don't work properly in conjunction with event bubbling because |
4081 | | // the component is rerendered and the value reverted before all the event |
4082 | | // handlers can run. See https://github.com/facebook/react/issues/708. |
4083 | | ReactUpdates.batchedUpdates(runEventInBatch, event); |
4084 | | } |
4085 | | |
4086 | | function runEventInBatch(event) { |
4087 | | EventPluginHub.enqueueEvents(event); |
4088 | | EventPluginHub.processEventQueue(false); |
4089 | | } |
4090 | | |
4091 | | function startWatchingForChangeEventIE8(target, targetInst) { |
4092 | | activeElement = target; |
4093 | | activeElementInst = targetInst; |
4094 | | activeElement.attachEvent('onchange', manualDispatchChangeEvent); |
4095 | | } |
4096 | | |
4097 | | function stopWatchingForChangeEventIE8() { |
4098 | | if (!activeElement) { |
4099 | | return; |
4100 | | } |
4101 | | activeElement.detachEvent('onchange', manualDispatchChangeEvent); |
4102 | | activeElement = null; |
4103 | | activeElementInst = null; |
4104 | | } |
4105 | | |
4106 | | function getInstIfValueChanged(targetInst, nativeEvent) { |
4107 | | var updated = inputValueTracking.updateValueIfChanged(targetInst); |
4108 | | var simulated = nativeEvent.simulated === true && ChangeEventPlugin._allowSimulatedPassThrough; |
4109 | | |
4110 | | if (updated || simulated) { |
4111 | | return targetInst; |
4112 | | } |
4113 | | } |
4114 | | |
4115 | | function getTargetInstForChangeEvent(topLevelType, targetInst) { |
4116 | | if (topLevelType === 'topChange') { |
4117 | | return targetInst; |
4118 | | } |
4119 | | } |
4120 | | |
4121 | | function handleEventsForChangeEventIE8(topLevelType, target, targetInst) { |
4122 | | if (topLevelType === 'topFocus') { |
4123 | | // stopWatching() should be a noop here but we call it just in case we |
4124 | | // missed a blur event somehow. |
4125 | | stopWatchingForChangeEventIE8(); |
4126 | | startWatchingForChangeEventIE8(target, targetInst); |
4127 | | } else if (topLevelType === 'topBlur') { |
4128 | | stopWatchingForChangeEventIE8(); |
4129 | | } |
4130 | | } |
4131 | | |
4132 | | /** |
4133 | | * SECTION: handle `input` event |
4134 | | */ |
4135 | | var isInputEventSupported = false; |
4136 | | if (ExecutionEnvironment.canUseDOM) { |
4137 | | // IE9 claims to support the input event but fails to trigger it when |
4138 | | // deleting text, so we ignore its input events. |
4139 | | |
4140 | | isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9); |
4141 | | } |
4142 | | |
4143 | | /** |
4144 | | * (For IE <=9) Starts tracking propertychange events on the passed-in element |
4145 | | * and override the value property so that we can distinguish user events from |
4146 | | * value changes in JS. |
4147 | | */ |
4148 | | function startWatchingForValueChange(target, targetInst) { |
4149 | | activeElement = target; |
4150 | | activeElementInst = targetInst; |
4151 | | activeElement.attachEvent('onpropertychange', handlePropertyChange); |
4152 | | } |
4153 | | |
4154 | | /** |
4155 | | * (For IE <=9) Removes the event listeners from the currently-tracked element, |
4156 | | * if any exists. |
4157 | | */ |
4158 | | function stopWatchingForValueChange() { |
4159 | | if (!activeElement) { |
4160 | | return; |
4161 | | } |
4162 | | activeElement.detachEvent('onpropertychange', handlePropertyChange); |
4163 | | |
4164 | | activeElement = null; |
4165 | | activeElementInst = null; |
4166 | | } |
4167 | | |
4168 | | /** |
4169 | | * (For IE <=9) Handles a propertychange event, sending a `change` event if |
4170 | | * the value of the active element has changed. |
4171 | | */ |
4172 | | function handlePropertyChange(nativeEvent) { |
4173 | | if (nativeEvent.propertyName !== 'value') { |
4174 | | return; |
4175 | | } |
4176 | | if (getInstIfValueChanged(activeElementInst, nativeEvent)) { |
4177 | | manualDispatchChangeEvent(nativeEvent); |
4178 | | } |
4179 | | } |
4180 | | |
4181 | | function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { |
4182 | | if (topLevelType === 'topFocus') { |
4183 | | // In IE8, we can capture almost all .value changes by adding a |
4184 | | // propertychange handler and looking for events with propertyName |
4185 | | // equal to 'value' |
4186 | | // In IE9, propertychange fires for most input events but is buggy and |
4187 | | // doesn't fire when text is deleted, but conveniently, selectionchange |
4188 | | // appears to fire in all of the remaining cases so we catch those and |
4189 | | // forward the event if the value has changed |
4190 | | // In either case, we don't want to call the event handler if the value |
4191 | | // is changed from JS so we redefine a setter for `.value` that updates |
4192 | | // our activeElementValue variable, allowing us to ignore those changes |
4193 | | // |
4194 | | // stopWatching() should be a noop here but we call it just in case we |
4195 | | // missed a blur event somehow. |
4196 | | stopWatchingForValueChange(); |
4197 | | startWatchingForValueChange(target, targetInst); |
4198 | | } else if (topLevelType === 'topBlur') { |
4199 | | stopWatchingForValueChange(); |
4200 | | } |
4201 | | } |
4202 | | |
4203 | | // For IE8 and IE9. |
4204 | | function getTargetInstForInputEventPolyfill(topLevelType, targetInst, nativeEvent) { |
4205 | | if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') { |
4206 | | // On the selectionchange event, the target is just document which isn't |
4207 | | // helpful for us so just check activeElement instead. |
4208 | | // |
4209 | | // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire |
4210 | | // propertychange on the first input event after setting `value` from a |
4211 | | // script and fires only keydown, keypress, keyup. Catching keyup usually |
4212 | | // gets it and catching keydown lets us fire an event for the first |
4213 | | // keystroke if user does a key repeat (it'll be a little delayed: right |
4214 | | // before the second keystroke). Other input methods (e.g., paste) seem to |
4215 | | // fire selectionchange normally. |
4216 | | return getInstIfValueChanged(activeElementInst, nativeEvent); |
4217 | | } |
4218 | | } |
4219 | | |
4220 | | /** |
4221 | | * SECTION: handle `click` event |
4222 | | */ |
4223 | | function shouldUseClickEvent(elem) { |
4224 | | // Use the `click` event to detect changes to checkbox and radio inputs. |
4225 | | // This approach works across all browsers, whereas `change` does not fire |
4226 | | // until `blur` in IE8. |
4227 | | var nodeName = elem.nodeName; |
4228 | | return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); |
4229 | | } |
4230 | | |
4231 | | function getTargetInstForClickEvent(topLevelType, targetInst, nativeEvent) { |
4232 | | if (topLevelType === 'topClick') { |
4233 | | return getInstIfValueChanged(targetInst, nativeEvent); |
4234 | | } |
4235 | | } |
4236 | | |
4237 | | function getTargetInstForInputOrChangeEvent(topLevelType, targetInst, nativeEvent) { |
4238 | | if (topLevelType === 'topInput' || topLevelType === 'topChange') { |
4239 | | return getInstIfValueChanged(targetInst, nativeEvent); |
4240 | | } |
4241 | | } |
4242 | | |
4243 | | function handleControlledInputBlur(inst, node) { |
4244 | | // TODO: In IE, inst is occasionally null. Why? |
4245 | | if (inst == null) { |
4246 | | return; |
4247 | | } |
4248 | | |
4249 | | // Fiber and ReactDOM keep wrapper state in separate places |
4250 | | var state = inst._wrapperState || node._wrapperState; |
4251 | | |
4252 | | if (!state || !state.controlled || node.type !== 'number') { |
4253 | | return; |
4254 | | } |
4255 | | |
4256 | | // If controlled, assign the value attribute to the current value on blur |
4257 | | var value = '' + node.value; |
4258 | | if (node.getAttribute('value') !== value) { |
4259 | | node.setAttribute('value', value); |
4260 | | } |
4261 | | } |
4262 | | |
4263 | | /** |
4264 | | * This plugin creates an `onChange` event that normalizes change events |
4265 | | * across form elements. This event fires at a time when it's possible to |
4266 | | * change the element's value without seeing a flicker. |
4267 | | * |
4268 | | * Supported elements are: |
4269 | | * - input (see `isTextInputElement`) |
4270 | | * - textarea |
4271 | | * - select |
4272 | | */ |
4273 | | var ChangeEventPlugin = { |
4274 | | eventTypes: eventTypes, |
4275 | | |
4276 | | _allowSimulatedPassThrough: true, |
4277 | | _isInputEventSupported: isInputEventSupported, |
4278 | | |
4279 | | extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
4280 | | var targetNode = targetInst ? ReactDOMComponentTree.getNodeFromInstance(targetInst) : window; |
4281 | | |
4282 | | var getTargetInstFunc, handleEventFunc; |
4283 | | if (shouldUseChangeEvent(targetNode)) { |
4284 | | if (doesChangeEventBubble) { |
4285 | | getTargetInstFunc = getTargetInstForChangeEvent; |
4286 | | } else { |
4287 | | handleEventFunc = handleEventsForChangeEventIE8; |
4288 | | } |
4289 | | } else if (isTextInputElement(targetNode)) { |
4290 | | if (isInputEventSupported) { |
4291 | | getTargetInstFunc = getTargetInstForInputOrChangeEvent; |
4292 | | } else { |
4293 | | getTargetInstFunc = getTargetInstForInputEventPolyfill; |
4294 | | handleEventFunc = handleEventsForInputEventPolyfill; |
4295 | | } |
4296 | | } else if (shouldUseClickEvent(targetNode)) { |
4297 | | getTargetInstFunc = getTargetInstForClickEvent; |
4298 | | } |
4299 | | |
4300 | | if (getTargetInstFunc) { |
4301 | | var inst = getTargetInstFunc(topLevelType, targetInst, nativeEvent); |
4302 | | if (inst) { |
4303 | | var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); |
4304 | | return event; |
4305 | | } |
4306 | | } |
4307 | | |
4308 | | if (handleEventFunc) { |
4309 | | handleEventFunc(topLevelType, targetNode, targetInst); |
4310 | | } |
4311 | | |
4312 | | // When blurring, set the value attribute for number inputs |
4313 | | if (topLevelType === 'topBlur') { |
4314 | | handleControlledInputBlur(targetInst, targetNode); |
4315 | | } |
4316 | | } |
4317 | | }; |
4318 | | |
4319 | | module.exports = ChangeEventPlugin; |
4320 | | },{"./EventPluginHub":54,"./EventPropagators":57,"./ReactDOMComponentTree":71,"./ReactUpdates":115,"./SyntheticEvent":124,"./getEventTarget":147,"./inputValueTracking":153,"./isEventSupported":155,"./isTextInputElement":156,"fbjs/lib/ExecutionEnvironment":9}],46:[function(require,module,exports){ |
4321 | | (function (process){ |
4322 | | /** |
4323 | | * Copyright 2013-present, Facebook, Inc. |
4324 | | * All rights reserved. |
4325 | | * |
4326 | | * This source code is licensed under the BSD-style license found in the |
4327 | | * LICENSE file in the root directory of this source tree. An additional grant |
4328 | | * of patent rights can be found in the PATENTS file in the same directory. |
4329 | | * |
4330 | | */ |
4331 | | |
4332 | | 'use strict'; |
4333 | | |
4334 | | var DOMLazyTree = require('./DOMLazyTree'); |
4335 | | var Danger = require('./Danger'); |
4336 | | var ReactDOMComponentTree = require('./ReactDOMComponentTree'); |
4337 | | var ReactInstrumentation = require('./ReactInstrumentation'); |
4338 | | |
4339 | | var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction'); |
4340 | | var setInnerHTML = require('./setInnerHTML'); |
4341 | | var setTextContent = require('./setTextContent'); |
4342 | | |
4343 | | function getNodeAfter(parentNode, node) { |
4344 | | // Special case for text components, which return [open, close] comments |
4345 | | // from getHostNode. |
4346 | | if (Array.isArray(node)) { |
4347 | | node = node[1]; |
4348 | | } |
4349 | | return node ? node.nextSibling : parentNode.firstChild; |
4350 | | } |
4351 | | |
4352 | | /** |
4353 | | * Inserts `childNode` as a child of `parentNode` at the `index`. |
4354 | | * |
4355 | | * @param {DOMElement} parentNode Parent node in which to insert. |
4356 | | * @param {DOMElement} childNode Child node to insert. |
4357 | | * @param {number} index Index at which to insert the child. |
4358 | | * @internal |
4359 | | */ |
4360 | | var insertChildAt = createMicrosoftUnsafeLocalFunction(function (parentNode, childNode, referenceNode) { |
4361 | | // We rely exclusively on `insertBefore(node, null)` instead of also using |
4362 | | // `appendChild(node)`. (Using `undefined` is not allowed by all browsers so |
4363 | | // we are careful to use `null`.) |
4364 | | parentNode.insertBefore(childNode, referenceNode); |
4365 | | }); |
4366 | | |
4367 | | function insertLazyTreeChildAt(parentNode, childTree, referenceNode) { |
4368 | | DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode); |
4369 | | } |
4370 | | |
4371 | | function moveChild(parentNode, childNode, referenceNode) { |
4372 | | if (Array.isArray(childNode)) { |
4373 | | moveDelimitedText(parentNode, childNode[0], childNode[1], referenceNode); |
4374 | | } else { |
4375 | | insertChildAt(parentNode, childNode, referenceNode); |
4376 | | } |
4377 | | } |
4378 | | |
4379 | | function removeChild(parentNode, childNode) { |
4380 | | if (Array.isArray(childNode)) { |
4381 | | var closingComment = childNode[1]; |
4382 | | childNode = childNode[0]; |
4383 | | removeDelimitedText(parentNode, childNode, closingComment); |
4384 | | parentNode.removeChild(closingComment); |
4385 | | } |
4386 | | parentNode.removeChild(childNode); |
4387 | | } |
4388 | | |
4389 | | function moveDelimitedText(parentNode, openingComment, closingComment, referenceNode) { |
4390 | | var node = openingComment; |
4391 | | while (true) { |
4392 | | var nextNode = node.nextSibling; |
4393 | | insertChildAt(parentNode, node, referenceNode); |
4394 | | if (node === closingComment) { |
4395 | | break; |
4396 | | } |
4397 | | node = nextNode; |
4398 | | } |
4399 | | } |
4400 | | |
4401 | | function removeDelimitedText(parentNode, startNode, closingComment) { |
4402 | | while (true) { |
4403 | | var node = startNode.nextSibling; |
4404 | | if (node === closingComment) { |
4405 | | // The closing comment is removed by ReactMultiChild. |
4406 | | break; |
4407 | | } else { |
4408 | | parentNode.removeChild(node); |
4409 | | } |
4410 | | } |
4411 | | } |
4412 | | |
4413 | | function replaceDelimitedText(openingComment, closingComment, stringText) { |
4414 | | var parentNode = openingComment.parentNode; |
4415 | | var nodeAfterComment = openingComment.nextSibling; |
4416 | | if (nodeAfterComment === closingComment) { |
4417 | | // There are no text nodes between the opening and closing comments; insert |
4418 | | // a new one if stringText isn't empty. |
4419 | | if (stringText) { |
4420 | | insertChildAt(parentNode, document.createTextNode(stringText), nodeAfterComment); |
4421 | | } |
4422 | | } else { |
4423 | | if (stringText) { |
4424 | | // Set the text content of the first node after the opening comment, and |
4425 | | // remove all following nodes up until the closing comment. |
4426 | | setTextContent(nodeAfterComment, stringText); |
4427 | | removeDelimitedText(parentNode, nodeAfterComment, closingComment); |
4428 | | } else { |
4429 | | removeDelimitedText(parentNode, openingComment, closingComment); |
4430 | | } |
4431 | | } |
4432 | | |
4433 | | if (process.env.NODE_ENV !== 'production') { |
4434 | | ReactInstrumentation.debugTool.onHostOperation({ |
4435 | | instanceID: ReactDOMComponentTree.getInstanceFromNode(openingComment)._debugID, |
4436 | | type: 'replace text', |
4437 | | payload: stringText |
4438 | | }); |
4439 | | } |
4440 | | } |
4441 | | |
4442 | | var dangerouslyReplaceNodeWithMarkup = Danger.dangerouslyReplaceNodeWithMarkup; |
4443 | | if (process.env.NODE_ENV !== 'production') { |
4444 | | dangerouslyReplaceNodeWithMarkup = function (oldChild, markup, prevInstance) { |
4445 | | Danger.dangerouslyReplaceNodeWithMarkup(oldChild, markup); |
4446 | | if (prevInstance._debugID !== 0) { |
4447 | | ReactInstrumentation.debugTool.onHostOperation({ |
4448 | | instanceID: prevInstance._debugID, |
4449 | | type: 'replace with', |
4450 | | payload: markup.toString() |
4451 | | }); |
4452 | | } else { |
4453 | | var nextInstance = ReactDOMComponentTree.getInstanceFromNode(markup.node); |
4454 | | if (nextInstance._debugID !== 0) { |
4455 | | ReactInstrumentation.debugTool.onHostOperation({ |
4456 | | instanceID: nextInstance._debugID, |
4457 | | type: 'mount', |
4458 | | payload: markup.toString() |
4459 | | }); |
4460 | | } |
| 6215 | removeHook: function (hook) { |
| 6216 | for (var i = 0; i < hooks.length; i++) { |
| 6217 | if (hooks[i] === hook) { |
| 6218 | hooks.splice(i, 1); |
| 6219 | i--; |
| 6220 | } |
| 6221 | } |
| 6222 | }, |
| 6223 | isProfiling: function () { |
| 6224 | return isProfiling; |
| 6225 | }, |
| 6226 | beginProfiling: function () { |
| 6227 | if (isProfiling) { |
| 6228 | return; |
| 6229 | } |
| 6230 | |
| 6231 | isProfiling = true; |
| 6232 | flushHistory.length = 0; |
| 6233 | resetMeasurements(); |
| 6234 | ReactDebugTool$1.addHook(ReactHostOperationHistoryHook_1); |
| 6235 | }, |
| 6236 | endProfiling: function () { |
| 6237 | if (!isProfiling) { |
| 6238 | return; |
| 6239 | } |
| 6240 | |
| 6241 | isProfiling = false; |
| 6242 | resetMeasurements(); |
| 6243 | ReactDebugTool$1.removeHook(ReactHostOperationHistoryHook_1); |
| 6244 | }, |
| 6245 | getFlushHistory: function () { |
| 6246 | return flushHistory; |
| 6247 | }, |
| 6248 | onBeginFlush: function () { |
| 6249 | currentFlushNesting++; |
| 6250 | resetMeasurements(); |
| 6251 | pauseCurrentLifeCycleTimer(); |
| 6252 | emitEvent('onBeginFlush'); |
| 6253 | }, |
| 6254 | onEndFlush: function () { |
| 6255 | resetMeasurements(); |
| 6256 | currentFlushNesting--; |
| 6257 | resumeCurrentLifeCycleTimer(); |
| 6258 | emitEvent('onEndFlush'); |
| 6259 | }, |
| 6260 | onBeginLifeCycleTimer: function (debugID, timerType) { |
| 6261 | checkDebugID(debugID); |
| 6262 | emitEvent('onBeginLifeCycleTimer', debugID, timerType); |
| 6263 | markBegin(debugID, timerType); |
| 6264 | beginLifeCycleTimer(debugID, timerType); |
| 6265 | }, |
| 6266 | onEndLifeCycleTimer: function (debugID, timerType) { |
| 6267 | checkDebugID(debugID); |
| 6268 | endLifeCycleTimer(debugID, timerType); |
| 6269 | markEnd(debugID, timerType); |
| 6270 | emitEvent('onEndLifeCycleTimer', debugID, timerType); |
| 6271 | }, |
| 6272 | onBeginProcessingChildContext: function () { |
| 6273 | emitEvent('onBeginProcessingChildContext'); |
| 6274 | }, |
| 6275 | onEndProcessingChildContext: function () { |
| 6276 | emitEvent('onEndProcessingChildContext'); |
| 6277 | }, |
| 6278 | onHostOperation: function (operation) { |
| 6279 | checkDebugID(operation.instanceID); |
| 6280 | emitEvent('onHostOperation', operation); |
| 6281 | }, |
| 6282 | onSetState: function () { |
| 6283 | emitEvent('onSetState'); |
| 6284 | }, |
| 6285 | onSetChildren: function (debugID, childDebugIDs) { |
| 6286 | checkDebugID(debugID); |
| 6287 | childDebugIDs.forEach(checkDebugID); |
| 6288 | emitEvent('onSetChildren', debugID, childDebugIDs); |
| 6289 | }, |
| 6290 | onBeforeMountComponent: function (debugID, element, parentDebugID) { |
| 6291 | checkDebugID(debugID); |
| 6292 | checkDebugID(parentDebugID, true); |
| 6293 | emitEvent('onBeforeMountComponent', debugID, element, parentDebugID); |
| 6294 | markBegin(debugID, 'mount'); |
| 6295 | }, |
| 6296 | onMountComponent: function (debugID) { |
| 6297 | checkDebugID(debugID); |
| 6298 | markEnd(debugID, 'mount'); |
| 6299 | emitEvent('onMountComponent', debugID); |
| 6300 | }, |
| 6301 | onBeforeUpdateComponent: function (debugID, element) { |
| 6302 | checkDebugID(debugID); |
| 6303 | emitEvent('onBeforeUpdateComponent', debugID, element); |
| 6304 | markBegin(debugID, 'update'); |
| 6305 | }, |
| 6306 | onUpdateComponent: function (debugID) { |
| 6307 | checkDebugID(debugID); |
| 6308 | markEnd(debugID, 'update'); |
| 6309 | emitEvent('onUpdateComponent', debugID); |
| 6310 | }, |
| 6311 | onBeforeUnmountComponent: function (debugID) { |
| 6312 | checkDebugID(debugID); |
| 6313 | emitEvent('onBeforeUnmountComponent', debugID); |
| 6314 | markBegin(debugID, 'unmount'); |
| 6315 | }, |
| 6316 | onUnmountComponent: function (debugID) { |
| 6317 | checkDebugID(debugID); |
| 6318 | markEnd(debugID, 'unmount'); |
| 6319 | emitEvent('onUnmountComponent', debugID); |
| 6320 | }, |
| 6321 | onTestEvent: function () { |
| 6322 | emitEvent('onTestEvent'); |
4463 | | } |
4464 | | |
4465 | | /** |
4466 | | * Operations for updating with DOM children. |
4467 | | */ |
4468 | | var DOMChildrenOperations = { |
4469 | | dangerouslyReplaceNodeWithMarkup: dangerouslyReplaceNodeWithMarkup, |
4470 | | |
4471 | | replaceDelimitedText: replaceDelimitedText, |
4472 | | |
4473 | | /** |
4474 | | * Updates a component's children by processing a series of updates. The |
4475 | | * update configurations are each expected to have a `parentNode` property. |
4476 | | * |
4477 | | * @param {array<object>} updates List of update configurations. |
4478 | | * @internal |
4479 | | */ |
4480 | | processUpdates: function (parentNode, updates) { |
4481 | | if (process.env.NODE_ENV !== 'production') { |
4482 | | var parentNodeDebugID = ReactDOMComponentTree.getInstanceFromNode(parentNode)._debugID; |
4483 | | } |
4484 | | |
4485 | | for (var k = 0; k < updates.length; k++) { |
4486 | | var update = updates[k]; |
4487 | | switch (update.type) { |
4488 | | case 'INSERT_MARKUP': |
4489 | | insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode)); |
4490 | | if (process.env.NODE_ENV !== 'production') { |
4491 | | ReactInstrumentation.debugTool.onHostOperation({ |
4492 | | instanceID: parentNodeDebugID, |
4493 | | type: 'insert child', |
4494 | | payload: { |
4495 | | toIndex: update.toIndex, |
4496 | | content: update.content.toString() |
4497 | | } |
4498 | | }); |
4499 | | } |
4500 | | break; |
4501 | | case 'MOVE_EXISTING': |
4502 | | moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode)); |
4503 | | if (process.env.NODE_ENV !== 'production') { |
4504 | | ReactInstrumentation.debugTool.onHostOperation({ |
4505 | | instanceID: parentNodeDebugID, |
4506 | | type: 'move child', |
4507 | | payload: { fromIndex: update.fromIndex, toIndex: update.toIndex } |
4508 | | }); |
4509 | | } |
4510 | | break; |
4511 | | case 'SET_MARKUP': |
4512 | | setInnerHTML(parentNode, update.content); |
4513 | | if (process.env.NODE_ENV !== 'production') { |
4514 | | ReactInstrumentation.debugTool.onHostOperation({ |
4515 | | instanceID: parentNodeDebugID, |
4516 | | type: 'replace children', |
4517 | | payload: update.content.toString() |
4518 | | }); |
4519 | | } |
4520 | | break; |
4521 | | case 'TEXT_CONTENT': |
4522 | | setTextContent(parentNode, update.content); |
4523 | | if (process.env.NODE_ENV !== 'production') { |
4524 | | ReactInstrumentation.debugTool.onHostOperation({ |
4525 | | instanceID: parentNodeDebugID, |
4526 | | type: 'replace text', |
4527 | | payload: update.content.toString() |
4528 | | }); |
4529 | | } |
4530 | | break; |
4531 | | case 'REMOVE_NODE': |
4532 | | removeChild(parentNode, update.fromNode); |
4533 | | if (process.env.NODE_ENV !== 'production') { |
4534 | | ReactInstrumentation.debugTool.onHostOperation({ |
4535 | | instanceID: parentNodeDebugID, |
4536 | | type: 'remove child', |
4537 | | payload: { fromIndex: update.fromIndex } |
4538 | | }); |
4539 | | } |
4540 | | break; |
4541 | | } |
4542 | | } |
4543 | | } |
4544 | | }; |
4545 | | |
4546 | | module.exports = DOMChildrenOperations; |
4547 | | }).call(this,require('_process')) |
4548 | | },{"./DOMLazyTree":47,"./Danger":51,"./ReactDOMComponentTree":71,"./ReactInstrumentation":100,"./createMicrosoftUnsafeLocalFunction":138,"./setInnerHTML":160,"./setTextContent":161,"_process":1}],47:[function(require,module,exports){ |
4549 | | /** |
4550 | | * Copyright 2015-present, Facebook, Inc. |
4551 | | * All rights reserved. |
4552 | | * |
4553 | | * This source code is licensed under the BSD-style license found in the |
4554 | | * LICENSE file in the root directory of this source tree. An additional grant |
4555 | | * of patent rights can be found in the PATENTS file in the same directory. |
4556 | | * |
4557 | | */ |
4558 | | |
4559 | | 'use strict'; |
4560 | | |
4561 | | var DOMNamespaces = require('./DOMNamespaces'); |
4562 | | var setInnerHTML = require('./setInnerHTML'); |
4563 | | |
4564 | | var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction'); |
4565 | | var setTextContent = require('./setTextContent'); |
4566 | | |
4567 | | var ELEMENT_NODE_TYPE = 1; |
4568 | | var DOCUMENT_FRAGMENT_NODE_TYPE = 11; |
4569 | | |
4570 | | /** |
4571 | | * In IE (8-11) and Edge, appending nodes with no children is dramatically |
4572 | | * faster than appending a full subtree, so we essentially queue up the |
4573 | | * .appendChild calls here and apply them so each node is added to its parent |
4574 | | * before any children are added. |
4575 | | * |
4576 | | * In other browsers, doing so is slower or neutral compared to the other order |
4577 | | * (in Firefox, twice as slow) so we only do this inversion in IE. |
4578 | | * |
4579 | | * See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode. |
4580 | | */ |
4581 | | var enableLazy = typeof document !== 'undefined' && typeof document.documentMode === 'number' || typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && /\bEdge\/\d/.test(navigator.userAgent); |
4582 | | |
4583 | | function insertTreeChildren(tree) { |
4584 | | if (!enableLazy) { |
4585 | | return; |
4586 | | } |
4587 | | var node = tree.node; |
4588 | | var children = tree.children; |
4589 | | if (children.length) { |
4590 | | for (var i = 0; i < children.length; i++) { |
4591 | | insertTreeBefore(node, children[i], null); |
4592 | | } |
4593 | | } else if (tree.html != null) { |
4594 | | setInnerHTML(node, tree.html); |
4595 | | } else if (tree.text != null) { |
4596 | | setTextContent(node, tree.text); |
4597 | | } |
4598 | | } |
4599 | | |
4600 | | var insertTreeBefore = createMicrosoftUnsafeLocalFunction(function (parentNode, tree, referenceNode) { |
4601 | | // DocumentFragments aren't actually part of the DOM after insertion so |
4602 | | // appending children won't update the DOM. We need to ensure the fragment |
4603 | | // is properly populated first, breaking out of our lazy approach for just |
4604 | | // this level. Also, some <object> plugins (like Flash Player) will read |
4605 | | // <param> nodes immediately upon insertion into the DOM, so <object> |
4606 | | // must also be populated prior to insertion into the DOM. |
4607 | | if (tree.node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE || tree.node.nodeType === ELEMENT_NODE_TYPE && tree.node.nodeName.toLowerCase() === 'object' && (tree.node.namespaceURI == null || tree.node.namespaceURI === DOMNamespaces.html)) { |
4608 | | insertTreeChildren(tree); |
4609 | | parentNode.insertBefore(tree.node, referenceNode); |
4610 | | } else { |
4611 | | parentNode.insertBefore(tree.node, referenceNode); |
4612 | | insertTreeChildren(tree); |
4613 | | } |
4614 | | }); |
4615 | | |
4616 | | function replaceChildWithTree(oldNode, newTree) { |
4617 | | oldNode.parentNode.replaceChild(newTree.node, oldNode); |
4618 | | insertTreeChildren(newTree); |
4619 | | } |
4620 | | |
4621 | | function queueChild(parentTree, childTree) { |
4622 | | if (enableLazy) { |
4623 | | parentTree.children.push(childTree); |
4624 | | } else { |
4625 | | parentTree.node.appendChild(childTree.node); |
4626 | | } |
4627 | | } |
4628 | | |
4629 | | function queueHTML(tree, html) { |
4630 | | if (enableLazy) { |
4631 | | tree.html = html; |
4632 | | } else { |
4633 | | setInnerHTML(tree.node, html); |
4634 | | } |
4635 | | } |
4636 | | |
4637 | | function queueText(tree, text) { |
4638 | | if (enableLazy) { |
4639 | | tree.text = text; |
4640 | | } else { |
4641 | | setTextContent(tree.node, text); |
4642 | | } |
4643 | | } |
4644 | | |
4645 | | function toString() { |
4646 | | return this.node.nodeName; |
4647 | | } |
4648 | | |
4649 | | function DOMLazyTree(node) { |
4650 | | return { |
4651 | | node: node, |
4652 | | children: [], |
4653 | | html: null, |
4654 | | text: null, |
4655 | | toString: toString |
4656 | | }; |
4657 | | } |
4658 | | |
4659 | | DOMLazyTree.insertTreeBefore = insertTreeBefore; |
4660 | | DOMLazyTree.replaceChildWithTree = replaceChildWithTree; |
4661 | | DOMLazyTree.queueChild = queueChild; |
4662 | | DOMLazyTree.queueHTML = queueHTML; |
4663 | | DOMLazyTree.queueText = queueText; |
4664 | | |
4665 | | module.exports = DOMLazyTree; |
4666 | | },{"./DOMNamespaces":48,"./createMicrosoftUnsafeLocalFunction":138,"./setInnerHTML":160,"./setTextContent":161}],48:[function(require,module,exports){ |
4667 | | /** |
4668 | | * Copyright 2013-present, Facebook, Inc. |
4669 | | * All rights reserved. |
4670 | | * |
4671 | | * This source code is licensed under the BSD-style license found in the |
4672 | | * LICENSE file in the root directory of this source tree. An additional grant |
4673 | | * of patent rights can be found in the PATENTS file in the same directory. |
4674 | | * |
4675 | | */ |
4676 | | |
4677 | | 'use strict'; |
4678 | | |
4679 | | var DOMNamespaces = { |
4680 | | html: 'http://www.w3.org/1999/xhtml', |
4681 | | mathml: 'http://www.w3.org/1998/Math/MathML', |
4682 | | svg: 'http://www.w3.org/2000/svg' |
4683 | | }; |
4684 | | |
4685 | | module.exports = DOMNamespaces; |
4686 | | },{}],49:[function(require,module,exports){ |
4687 | | (function (process){ |
4688 | | /** |
4689 | | * Copyright 2013-present, Facebook, Inc. |
4690 | | * All rights reserved. |
4691 | | * |
4692 | | * This source code is licensed under the BSD-style license found in the |
4693 | | * LICENSE file in the root directory of this source tree. An additional grant |
4694 | | * of patent rights can be found in the PATENTS file in the same directory. |
4695 | | * |
4696 | | */ |
4697 | | |
4698 | | 'use strict'; |
4699 | | |
4700 | | var _prodInvariant = require('./reactProdInvariant'); |
4701 | | |
4702 | | var invariant = require('fbjs/lib/invariant'); |
4703 | | |
4704 | | function checkMask(value, bitmask) { |
4705 | | return (value & bitmask) === bitmask; |
4706 | | } |
4707 | | |
4708 | | var DOMPropertyInjection = { |
4709 | | /** |
4710 | | * Mapping from normalized, camelcased property names to a configuration that |
4711 | | * specifies how the associated DOM property should be accessed or rendered. |
4712 | | */ |
4713 | | MUST_USE_PROPERTY: 0x1, |
4714 | | HAS_BOOLEAN_VALUE: 0x4, |
4715 | | HAS_NUMERIC_VALUE: 0x8, |
4716 | | HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8, |
4717 | | HAS_OVERLOADED_BOOLEAN_VALUE: 0x20, |
4718 | | |
4719 | | /** |
4720 | | * Inject some specialized knowledge about the DOM. This takes a config object |
4721 | | * with the following properties: |
4722 | | * |
4723 | | * isCustomAttribute: function that given an attribute name will return true |
4724 | | * if it can be inserted into the DOM verbatim. Useful for data-* or aria-* |
4725 | | * attributes where it's impossible to enumerate all of the possible |
4726 | | * attribute names, |
4727 | | * |
4728 | | * Properties: object mapping DOM property name to one of the |
4729 | | * DOMPropertyInjection constants or null. If your attribute isn't in here, |
4730 | | * it won't get written to the DOM. |
4731 | | * |
4732 | | * DOMAttributeNames: object mapping React attribute name to the DOM |
4733 | | * attribute name. Attribute names not specified use the **lowercase** |
4734 | | * normalized name. |
4735 | | * |
4736 | | * DOMAttributeNamespaces: object mapping React attribute name to the DOM |
4737 | | * attribute namespace URL. (Attribute names not specified use no namespace.) |
4738 | | * |
4739 | | * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. |
4740 | | * Property names not specified use the normalized name. |
4741 | | * |
4742 | | * DOMMutationMethods: Properties that require special mutation methods. If |
4743 | | * `value` is undefined, the mutation method should unset the property. |
4744 | | * |
4745 | | * @param {object} domPropertyConfig the config as described above. |
4746 | | */ |
4747 | | injectDOMPropertyConfig: function (domPropertyConfig) { |
4748 | | var Injection = DOMPropertyInjection; |
4749 | | var Properties = domPropertyConfig.Properties || {}; |
4750 | | var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; |
4751 | | var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; |
4752 | | var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {}; |
4753 | | var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; |
4754 | | |
4755 | | if (domPropertyConfig.isCustomAttribute) { |
4756 | | DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute); |
4757 | | } |
4758 | | |
4759 | | for (var propName in Properties) { |
4760 | | !!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property \'%s\' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.', propName) : _prodInvariant('48', propName) : void 0; |
4761 | | |
4762 | | var lowerCased = propName.toLowerCase(); |
4763 | | var propConfig = Properties[propName]; |
4764 | | |
4765 | | var propertyInfo = { |
4766 | | attributeName: lowerCased, |
4767 | | attributeNamespace: null, |
4768 | | propertyName: propName, |
4769 | | mutationMethod: null, |
4770 | | |
4771 | | mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), |
4772 | | hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), |
4773 | | hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), |
4774 | | hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), |
4775 | | hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE) |
4776 | | }; |
4777 | | !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s', propName) : _prodInvariant('50', propName) : void 0; |
4778 | | |
4779 | | if (process.env.NODE_ENV !== 'production') { |
4780 | | DOMProperty.getPossibleStandardName[lowerCased] = propName; |
4781 | | } |
4782 | | |
4783 | | if (DOMAttributeNames.hasOwnProperty(propName)) { |
4784 | | var attributeName = DOMAttributeNames[propName]; |
4785 | | propertyInfo.attributeName = attributeName; |
4786 | | if (process.env.NODE_ENV !== 'production') { |
4787 | | DOMProperty.getPossibleStandardName[attributeName] = propName; |
4788 | | } |
4789 | | } |
4790 | | |
4791 | | if (DOMAttributeNamespaces.hasOwnProperty(propName)) { |
4792 | | propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; |
4793 | | } |
4794 | | |
4795 | | if (DOMPropertyNames.hasOwnProperty(propName)) { |
4796 | | propertyInfo.propertyName = DOMPropertyNames[propName]; |
4797 | | } |
4798 | | |
4799 | | if (DOMMutationMethods.hasOwnProperty(propName)) { |
4800 | | propertyInfo.mutationMethod = DOMMutationMethods[propName]; |
4801 | | } |
4802 | | |
4803 | | DOMProperty.properties[propName] = propertyInfo; |
4804 | | } |
4805 | | } |
4806 | | }; |
4807 | | |
4808 | | /* eslint-disable max-len */ |
4809 | | var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; |
4810 | | /* eslint-enable max-len */ |
4811 | | |
4812 | | /** |
4813 | | * DOMProperty exports lookup objects that can be used like functions: |
4814 | | * |
4815 | | * > DOMProperty.isValid['id'] |
4816 | | * true |
4817 | | * > DOMProperty.isValid['foobar'] |
4818 | | * undefined |
4819 | | * |
4820 | | * Although this may be confusing, it performs better in general. |
4821 | | * |
4822 | | * @see http://jsperf.com/key-exists |
4823 | | * @see http://jsperf.com/key-missing |
4824 | | */ |
4825 | | var DOMProperty = { |
4826 | | ID_ATTRIBUTE_NAME: 'data-reactid', |
4827 | | ROOT_ATTRIBUTE_NAME: 'data-reactroot', |
4828 | | |
4829 | | ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR, |
4830 | | ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040', |
4831 | | |
4832 | | /** |
4833 | | * Map from property "standard name" to an object with info about how to set |
4834 | | * the property in the DOM. Each object contains: |
4835 | | * |
4836 | | * attributeName: |
4837 | | * Used when rendering markup or with `*Attribute()`. |
4838 | | * attributeNamespace |
4839 | | * propertyName: |
4840 | | * Used on DOM node instances. (This includes properties that mutate due to |
4841 | | * external factors.) |
4842 | | * mutationMethod: |
4843 | | * If non-null, used instead of the property or `setAttribute()` after |
4844 | | * initial render. |
4845 | | * mustUseProperty: |
4846 | | * Whether the property must be accessed and mutated as an object property. |
4847 | | * hasBooleanValue: |
4848 | | * Whether the property should be removed when set to a falsey value. |
4849 | | * hasNumericValue: |
4850 | | * Whether the property must be numeric or parse as a numeric and should be |
4851 | | * removed when set to a falsey value. |
4852 | | * hasPositiveNumericValue: |
4853 | | * Whether the property must be positive numeric or parse as a positive |
4854 | | * numeric and should be removed when set to a falsey value. |
4855 | | * hasOverloadedBooleanValue: |
4856 | | * Whether the property can be used as a flag as well as with a value. |
4857 | | * Removed when strictly equal to false; present without a value when |
4858 | | * strictly equal to true; present with a value otherwise. |
4859 | | */ |
4860 | | properties: {}, |
4861 | | |
4862 | | /** |
4863 | | * Mapping from lowercase property names to the properly cased version, used |
4864 | | * to warn in the case of missing properties. Available only in __DEV__. |
4865 | | * |
4866 | | * autofocus is predefined, because adding it to the property whitelist |
4867 | | * causes unintended side effects. |
4868 |