Ver código fonte

Coding style

master
Lyubo Marinov 8 anos atrás
pai
commit
0d3927fed1

+ 16
- 29
react/features/base/lib-jitsi-meet/native/polyfills-browser.js Ver arquivo

@@ -22,10 +22,9 @@ function _getCommonPrototype(a, b) {
22 22
 
23 23
     let p;
24 24
 
25
-    if ((p = Object.getPrototypeOf(a)) && (p = _getCommonPrototype(b, p))) {
26
-        return p;
27
-    }
28
-    if ((p = Object.getPrototypeOf(b)) && (p = _getCommonPrototype(a, p))) {
25
+    if (((p = Object.getPrototypeOf(a)) && (p = _getCommonPrototype(b, p)))
26
+            || ((p = Object.getPrototypeOf(b))
27
+                && (p = _getCommonPrototype(a, p)))) {
29 28
         return p;
30 29
     }
31 30
 
@@ -90,7 +89,7 @@ function _visitNode(node, callback) {
90 89
 }
91 90
 
92 91
 (global => {
93
-    const DOMParser = require('xmldom').DOMParser;
92
+    const { DOMParser } = require('xmldom');
94 93
 
95 94
     // addEventListener
96 95
     //
@@ -234,7 +233,7 @@ function _visitNode(node, callback) {
234 233
 
235 234
                     if (typeof consoleLog === 'function') {
236 235
                         console[level] = function(...args) {
237
-                            const length = args.length;
236
+                            const { length } = args;
238 237
 
239 238
                             for (let i = 0; i < length; ++i) {
240 239
                                 let arg = args[i];
@@ -331,8 +330,8 @@ function _visitNode(node, callback) {
331 330
     // sessionStorage
332 331
     //
333 332
     // Required by:
333
+    // - herment
334 334
     // - Strophe
335
-    // - herment - requires a working sessionStorage, no empty impl. functions
336 335
     if (typeof global.sessionStorage === 'undefined') {
337 336
         let internalStorage = {};
338 337
 
@@ -358,7 +357,7 @@ function _visitNode(node, callback) {
358 357
 
359 358
     // XMLHttpRequest
360 359
     if (global.XMLHttpRequest) {
361
-        const prototype = global.XMLHttpRequest.prototype;
360
+        const { prototype } = global.XMLHttpRequest;
362 361
 
363 362
         // XMLHttpRequest.responseXML
364 363
         //
@@ -367,17 +366,13 @@ function _visitNode(node, callback) {
367 366
         if (prototype && !prototype.hasOwnProperty('responseXML')) {
368 367
             Object.defineProperty(prototype, 'responseXML', {
369 368
                 get() {
370
-                    const responseText = this.responseText;
371
-                    let responseXML;
369
+                    const { responseText } = this;
372 370
 
373
-                    if (responseText) {
374
-                        responseXML
375
-                            = new DOMParser().parseFromString(
371
+                    return (
372
+                        responseText
373
+                            && new DOMParser().parseFromString(
376 374
                                 responseText,
377
-                                'text/xml');
378
-                    }
379
-
380
-                    return responseXML;
375
+                                'text/xml'));
381 376
                 }
382 377
             });
383 378
         }
@@ -392,17 +387,9 @@ function _visitNode(node, callback) {
392 387
     // Required by:
393 388
     // - lib-jitsi-meet
394 389
     // - Strophe
395
-    global.clearTimeout
396
-        = window.clearTimeout
397
-        = BackgroundTimer.clearTimeout.bind(BackgroundTimer);
398
-    global.clearInterval
399
-        = window.clearInterval
400
-        = BackgroundTimer.clearInterval.bind(BackgroundTimer);
401
-    global.setInterval
402
-        = window.setInterval
403
-        = BackgroundTimer.setInterval.bind(BackgroundTimer);
404
-    global.setTimeout
405
-        = window.setTimeout
406
-        = BackgroundTimer.setTimeout.bind(BackgroundTimer);
390
+    global.clearTimeout = BackgroundTimer.clearTimeout.bind(BackgroundTimer);
391
+    global.clearInterval = BackgroundTimer.clearInterval.bind(BackgroundTimer);
392
+    global.setInterval = BackgroundTimer.setInterval.bind(BackgroundTimer);
393
+    global.setTimeout = BackgroundTimer.setTimeout.bind(BackgroundTimer);
407 394
 
408 395
 })(global || window || this); // eslint-disable-line no-invalid-this

Carregando…
Cancelar
Salvar