1 | /**
|
2 | * Copyright 2014-2015, Facebook, Inc.
|
3 | * All rights reserved.
|
4 | *
|
5 | * This source code is licensed under the BSD-style license found in the
|
6 | * LICENSE file in the root directory of this source tree. An additional grant
|
7 | * of patent rights can be found in the PATENTS file in the same directory.
|
8 | *
|
9 | */
|
10 |
|
11 | ;
|
12 |
|
13 | /**
|
14 | * Forked from fbjs/warning:
|
15 | * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
16 | *
|
17 | * Only change is we use console.warn instead of console.error,
|
18 | * and do nothing when 'console' is not supported.
|
19 | * This really simplifies the code.
|
20 | * ---
|
21 | * Similar to invariant but only logs a warning if the condition is not met.
|
22 | * This can be used to log issues in development environments in critical
|
23 | * paths. Removing the logging code for production environments will keep the
|
24 | * same logic and follow the same code paths.
|
25 | */
|
26 |
|
27 | var lowPriorityWarning = function () {};
|
28 |
|
29 | if (process.env.NODE_ENV !== 'production') {
|
30 | var printWarning = function (format) {
|
31 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
32 | args[_key - 1] = arguments[_key];
|
33 | }
|
34 |
|
35 | var argIndex = 0;
|
36 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
37 | return args[argIndex++];
|
38 | });
|
39 | if (typeof console !== 'undefined') {
|
40 | console.warn(message);
|
41 | }
|
42 | try {
|
43 | // --- Welcome to debugging React ---
|
44 | // This error was thrown as a convenience so that you can use this stack
|
45 | // to find the callsite that caused this warning to fire.
|
46 | throw new Error(message);
|
47 | } catch (x) {}
|
48 | };
|
49 |
|
50 | lowPriorityWarning = function (condition, format) {
|
51 | if (format === undefined) {
|
52 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
53 | }
|
54 | if (!condition) {
|
55 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
56 | args[_key2 - 2] = arguments[_key2];
|
57 | }
|
58 |
|
59 | printWarning.apply(undefined, [format].concat(args));
|
60 | }
|
61 | };
|
62 | }
|
63 |
|
64 | module.exports = lowPriorityWarning; |
\ | No newline at end of file |