Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

95 řádky
3.8 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getDOMNode = exports.isReactDOMSupported = undefined;
  6. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (c) 2016 - 2017 Uber Technologies, Inc.
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights
  11. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. // copies of the Software, and to permit persons to whom the Software is
  13. // furnished to do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in
  16. // all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. // THE SOFTWARE.
  25. exports.warning = warning;
  26. exports.warnOnce = warnOnce;
  27. var _react = require('react');
  28. var _react2 = _interopRequireDefault(_react);
  29. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30. var _React$version$split = _react2.default.version.split('.'),
  31. _React$version$split2 = _slicedToArray(_React$version$split, 2),
  32. major = _React$version$split2[0],
  33. minor = _React$version$split2[1];
  34. var versionHigherThanThirteen = Number(minor) > 13 || Number(major) > 13;
  35. var isReactDOMSupported = exports.isReactDOMSupported = function isReactDOMSupported() {
  36. return versionHigherThanThirteen;
  37. };
  38. /**
  39. * Support React 0.13 and greater where refs are React components, not DOM
  40. * nodes.
  41. * @param {*} ref React's ref.
  42. * @returns {Element} DOM element.
  43. */
  44. var getDOMNode = exports.getDOMNode = function getDOMNode(ref) {
  45. if (!isReactDOMSupported()) {
  46. return ref && ref.getDOMNode();
  47. }
  48. return ref;
  49. };
  50. var USED_MESSAGES = {};
  51. var HIDDEN_PROCESSES = {
  52. test: true,
  53. production: true
  54. };
  55. /**
  56. * Warn the user about something
  57. * @param {String} message - the message to be shown
  58. * @param {Boolean} onlyShowMessageOnce - whether or not we allow the
  59. - message to be show multiple times
  60. */
  61. function warning(message) {
  62. var onlyShowMessageOnce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  63. /* eslint-disable no-undef, no-process-env */
  64. if (global.process && HIDDEN_PROCESSES[process.env.NODE_ENV]) {
  65. return;
  66. }
  67. /* eslint-enable no-undef, no-process-env */
  68. if (!onlyShowMessageOnce || !USED_MESSAGES[message]) {
  69. /* eslint-disable no-console */
  70. console.warn(message);
  71. /* eslint-enable no-console */
  72. USED_MESSAGES[message] = true;
  73. }
  74. }
  75. /**
  76. * Convience wrapper for warning
  77. * @param {String} message - the message to be shown
  78. */
  79. function warnOnce(message) {
  80. warning(message, true);
  81. }