Coding style

This commit is contained in:
Lyubo Marinov 2017-09-07 12:30:09 -05:00
parent 9049f52402
commit 0d3927fed1
1 changed files with 16 additions and 29 deletions

View File

@ -22,10 +22,9 @@ function _getCommonPrototype(a, b) {
let p; let p;
if ((p = Object.getPrototypeOf(a)) && (p = _getCommonPrototype(b, p))) { if (((p = Object.getPrototypeOf(a)) && (p = _getCommonPrototype(b, p)))
return p; || ((p = Object.getPrototypeOf(b))
} && (p = _getCommonPrototype(a, p)))) {
if ((p = Object.getPrototypeOf(b)) && (p = _getCommonPrototype(a, p))) {
return p; return p;
} }
@ -90,7 +89,7 @@ function _visitNode(node, callback) {
} }
(global => { (global => {
const DOMParser = require('xmldom').DOMParser; const { DOMParser } = require('xmldom');
// addEventListener // addEventListener
// //
@ -234,7 +233,7 @@ function _visitNode(node, callback) {
if (typeof consoleLog === 'function') { if (typeof consoleLog === 'function') {
console[level] = function(...args) { console[level] = function(...args) {
const length = args.length; const { length } = args;
for (let i = 0; i < length; ++i) { for (let i = 0; i < length; ++i) {
let arg = args[i]; let arg = args[i];
@ -331,8 +330,8 @@ function _visitNode(node, callback) {
// sessionStorage // sessionStorage
// //
// Required by: // Required by:
// - herment
// - Strophe // - Strophe
// - herment - requires a working sessionStorage, no empty impl. functions
if (typeof global.sessionStorage === 'undefined') { if (typeof global.sessionStorage === 'undefined') {
let internalStorage = {}; let internalStorage = {};
@ -358,7 +357,7 @@ function _visitNode(node, callback) {
// XMLHttpRequest // XMLHttpRequest
if (global.XMLHttpRequest) { if (global.XMLHttpRequest) {
const prototype = global.XMLHttpRequest.prototype; const { prototype } = global.XMLHttpRequest;
// XMLHttpRequest.responseXML // XMLHttpRequest.responseXML
// //
@ -367,17 +366,13 @@ function _visitNode(node, callback) {
if (prototype && !prototype.hasOwnProperty('responseXML')) { if (prototype && !prototype.hasOwnProperty('responseXML')) {
Object.defineProperty(prototype, 'responseXML', { Object.defineProperty(prototype, 'responseXML', {
get() { get() {
const responseText = this.responseText; const { responseText } = this;
let responseXML;
if (responseText) { return (
responseXML responseText
= new DOMParser().parseFromString( && new DOMParser().parseFromString(
responseText, responseText,
'text/xml'); 'text/xml'));
}
return responseXML;
} }
}); });
} }
@ -392,17 +387,9 @@ function _visitNode(node, callback) {
// Required by: // Required by:
// - lib-jitsi-meet // - lib-jitsi-meet
// - Strophe // - Strophe
global.clearTimeout global.clearTimeout = BackgroundTimer.clearTimeout.bind(BackgroundTimer);
= window.clearTimeout global.clearInterval = BackgroundTimer.clearInterval.bind(BackgroundTimer);
= BackgroundTimer.clearTimeout.bind(BackgroundTimer); global.setInterval = BackgroundTimer.setInterval.bind(BackgroundTimer);
global.clearInterval global.setTimeout = BackgroundTimer.setTimeout.bind(BackgroundTimer);
= window.clearInterval
= BackgroundTimer.clearInterval.bind(BackgroundTimer);
global.setInterval
= window.setInterval
= BackgroundTimer.setInterval.bind(BackgroundTimer);
global.setTimeout
= window.setTimeout
= BackgroundTimer.setTimeout.bind(BackgroundTimer);
})(global || window || this); // eslint-disable-line no-invalid-this })(global || window || this); // eslint-disable-line no-invalid-this