Browse Source

Coding style

master
Lyubo Marinov 8 years ago
parent
commit
0d3927fed1
1 changed files with 16 additions and 29 deletions
  1. 16
    29
      react/features/base/lib-jitsi-meet/native/polyfills-browser.js

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

22
 
22
 
23
     let p;
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
         return p;
28
         return p;
30
     }
29
     }
31
 
30
 
90
 }
89
 }
91
 
90
 
92
 (global => {
91
 (global => {
93
-    const DOMParser = require('xmldom').DOMParser;
92
+    const { DOMParser } = require('xmldom');
94
 
93
 
95
     // addEventListener
94
     // addEventListener
96
     //
95
     //
234
 
233
 
235
                     if (typeof consoleLog === 'function') {
234
                     if (typeof consoleLog === 'function') {
236
                         console[level] = function(...args) {
235
                         console[level] = function(...args) {
237
-                            const length = args.length;
236
+                            const { length } = args;
238
 
237
 
239
                             for (let i = 0; i < length; ++i) {
238
                             for (let i = 0; i < length; ++i) {
240
                                 let arg = args[i];
239
                                 let arg = args[i];
331
     // sessionStorage
330
     // sessionStorage
332
     //
331
     //
333
     // Required by:
332
     // Required by:
333
+    // - herment
334
     // - Strophe
334
     // - Strophe
335
-    // - herment - requires a working sessionStorage, no empty impl. functions
336
     if (typeof global.sessionStorage === 'undefined') {
335
     if (typeof global.sessionStorage === 'undefined') {
337
         let internalStorage = {};
336
         let internalStorage = {};
338
 
337
 
358
 
357
 
359
     // XMLHttpRequest
358
     // XMLHttpRequest
360
     if (global.XMLHttpRequest) {
359
     if (global.XMLHttpRequest) {
361
-        const prototype = global.XMLHttpRequest.prototype;
360
+        const { prototype } = global.XMLHttpRequest;
362
 
361
 
363
         // XMLHttpRequest.responseXML
362
         // XMLHttpRequest.responseXML
364
         //
363
         //
367
         if (prototype && !prototype.hasOwnProperty('responseXML')) {
366
         if (prototype && !prototype.hasOwnProperty('responseXML')) {
368
             Object.defineProperty(prototype, 'responseXML', {
367
             Object.defineProperty(prototype, 'responseXML', {
369
                 get() {
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
                                 responseText,
374
                                 responseText,
377
-                                'text/xml');
378
-                    }
379
-
380
-                    return responseXML;
375
+                                'text/xml'));
381
                 }
376
                 }
382
             });
377
             });
383
         }
378
         }
392
     // Required by:
387
     // Required by:
393
     // - lib-jitsi-meet
388
     // - lib-jitsi-meet
394
     // - Strophe
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
 })(global || window || this); // eslint-disable-line no-invalid-this
395
 })(global || window || this); // eslint-disable-line no-invalid-this

Loading…
Cancel
Save