|
@@ -6,33 +6,6 @@ import 'react-native-url-polyfill/auto'; // Complete URL polyfill.
|
6
|
6
|
|
7
|
7
|
import Storage from './Storage';
|
8
|
8
|
|
9
|
|
-/**
|
10
|
|
- * Gets the first common prototype of two specified Objects (treating the
|
11
|
|
- * objects themselves as prototypes as well).
|
12
|
|
- *
|
13
|
|
- * @param {Object} a - The first prototype chain to climb in search of a common
|
14
|
|
- * prototype.
|
15
|
|
- * @param {Object} b - The second prototype chain to climb in search of a common
|
16
|
|
- * prototype.
|
17
|
|
- * @returns {Object|undefined} - The first common prototype of a and b.
|
18
|
|
- */
|
19
|
|
-function _getCommonPrototype(a, b) {
|
20
|
|
- // Allow the arguments to be prototypes themselves.
|
21
|
|
- if (a === b) {
|
22
|
|
- return a;
|
23
|
|
- }
|
24
|
|
-
|
25
|
|
- let p;
|
26
|
|
-
|
27
|
|
- if (((p = Object.getPrototypeOf(a)) && (p = _getCommonPrototype(b, p)))
|
28
|
|
- || ((p = Object.getPrototypeOf(b))
|
29
|
|
- && (p = _getCommonPrototype(a, p)))) {
|
30
|
|
- return p;
|
31
|
|
- }
|
32
|
|
-
|
33
|
|
- return undefined;
|
34
|
|
-}
|
35
|
|
-
|
36
|
9
|
/**
|
37
|
10
|
* Implements an absolute minimum of the common logic of
|
38
|
11
|
* {@code Document.querySelector} and {@code Element.querySelector}. Implements
|
|
@@ -264,79 +237,6 @@ function _visitNode(node, callback) {
|
264
|
237
|
}
|
265
|
238
|
}
|
266
|
239
|
|
267
|
|
- // FIXME There is a weird infinite loop related to console.log and
|
268
|
|
- // Document and/or Element at the time of this writing. Work around it
|
269
|
|
- // by patching Node and/or overriding console.log.
|
270
|
|
- const documentPrototype = Object.getPrototypeOf(document);
|
271
|
|
- const nodePrototype
|
272
|
|
- = _getCommonPrototype(documentPrototype, elementPrototype);
|
273
|
|
-
|
274
|
|
- if (nodePrototype
|
275
|
|
-
|
276
|
|
- // XXX The intention was to find Node from which Document and
|
277
|
|
- // Element extend. If for whatever reason we've reached Object,
|
278
|
|
- // then it doesn't sound like what expected.
|
279
|
|
- && nodePrototype !== Object.getPrototypeOf({})) {
|
280
|
|
- // Override console.log.
|
281
|
|
- const { console } = global;
|
282
|
|
-
|
283
|
|
- if (console) {
|
284
|
|
- const loggerLevels = require('@jitsi/logger').levels;
|
285
|
|
-
|
286
|
|
- Object.keys(loggerLevels).forEach(key => {
|
287
|
|
- const level = loggerLevels[key];
|
288
|
|
- const consoleLog = console[level];
|
289
|
|
-
|
290
|
|
- /* eslint-disable prefer-rest-params */
|
291
|
|
-
|
292
|
|
- if (typeof consoleLog === 'function') {
|
293
|
|
- console[level] = function(...args) {
|
294
|
|
- // XXX If console's disableYellowBox is truthy, then
|
295
|
|
- // react-native will not automatically display the
|
296
|
|
- // yellow box for the warn level. However, it will
|
297
|
|
- // still display the red box for the error level.
|
298
|
|
- // But I disable the yellow box when I don't want to
|
299
|
|
- // have react-native automatically show me the
|
300
|
|
- // console's output just like in the Release build
|
301
|
|
- // configuration. Because I didn't find a way to
|
302
|
|
- // disable the red box, downgrade the error level to
|
303
|
|
- // warn. The red box will still be displayed but not
|
304
|
|
- // for the error level.
|
305
|
|
- if (console.disableYellowBox && level === 'error') {
|
306
|
|
- console.warn(...args);
|
307
|
|
-
|
308
|
|
- return;
|
309
|
|
- }
|
310
|
|
-
|
311
|
|
- const { length } = args;
|
312
|
|
-
|
313
|
|
- for (let i = 0; i < length; ++i) {
|
314
|
|
- let arg = args[i];
|
315
|
|
-
|
316
|
|
- if (arg
|
317
|
|
- && typeof arg !== 'string'
|
318
|
|
-
|
319
|
|
- // Limit the console.log override to
|
320
|
|
- // Node (instances).
|
321
|
|
- && nodePrototype.isPrototypeOf(arg)) {
|
322
|
|
- const toString = arg.toString;
|
323
|
|
-
|
324
|
|
- if (toString) {
|
325
|
|
- arg = toString.call(arg);
|
326
|
|
- }
|
327
|
|
- }
|
328
|
|
- args[i] = arg;
|
329
|
|
- }
|
330
|
|
-
|
331
|
|
- consoleLog.apply(this, args);
|
332
|
|
- };
|
333
|
|
- }
|
334
|
|
-
|
335
|
|
- /* eslint-enable prefer-rest-params */
|
336
|
|
- });
|
337
|
|
- }
|
338
|
|
- }
|
339
|
|
-
|
340
|
240
|
global.document = document;
|
341
|
241
|
}
|
342
|
242
|
|