@samitouri / QOS-React-2 / commits / 1b2646a403

Fix warning without stack for ie9 (#13620)

* Fix warning without stack for ie9 Where console methods like log, error etc. don't have 'apply' method. Because of the lot of tests already expect that exactly console['method'] will be called - had to reapply references for console.error method https://github.com/facebook/react/issues/13610 * pass parameters explicitly to avoid using .apply which is not supported for console methods in ie9 * Minor tweaks

Aliaksandr Manzhula committed Sep 12, 2018 at 16:09 UTC 1b2646a403a23556084189f055d75d68da2a6cd4
1 file changed +44 -2
packages/shared/warningWithoutStack.js
+44 -2
@@ -22,12 +22,54 @@ if (__DEV__) {
22 'message argument',
23 );
24 }
25 + if (args.length > 8) {
26 + // Check before the condition to catch violations early.
27 + throw new Error(
28 + 'warningWithoutStack() currently supports at most 8 arguments.',
29 + );
30 + }
31 if (condition) {
32 return;
33 }
34 if (typeof console !== 'undefined') {
29 - const stringArgs = args.map(item => '' + item);
30 - console.error('Warning: ' + format, ...stringArgs);
35 + const [a, b, c, d, e, f, g, h] = args.map(item => '' + item);
36 + const message = 'Warning: ' + format;
37 +
38 + // We intentionally don't use spread (or .apply) because it breaks IE11:
39 + // https://github.com/facebook/react/issues/13610
40 + switch (args.length) {
41 + case 0:
42 + console.error(message);
43 + break;
44 + case 1:
45 + console.error(message, a);
46 + break;
47 + case 2:
48 + console.error(message, a, b);
49 + break;
50 + case 3:
51 + console.error(message, a, b, c);
52 + break;
53 + case 4:
54 + console.error(message, a, b, c, d);
55 + break;
56 + case 5:
57 + console.error(message, a, b, c, d, e);
58 + break;
59 + case 6:
60 + console.error(message, a, b, c, d, e, f);
61 + break;
62 + case 7:
63 + console.error(message, a, b, c, d, e, f, g);
64 + break;
65 + case 8:
66 + console.error(message, a, b, c, d, e, f, g, h);
67 + break;
68 + default:
69 + throw new Error(
70 + 'warningWithoutStack() currently supports at most 8 arguments.',
71 + );
72 + }
73 }
74 try {
75 // --- Welcome to debugging React ---