Fix linting issues with injection code

This commit is contained in:
Rob Garrison 2017-08-18 11:13:03 -05:00
parent 3c160a3fa5
commit 014adf8d8a

View File

@ -78,7 +78,7 @@ function onDOMscripted(scripts) {
if (onDOMscripted.scriptQueue) { if (onDOMscripted.scriptQueue) {
return new Promise(resolve => addResolver(resolve)); return new Promise(resolve => addResolver(resolve));
} }
if (document.readyState != 'loading') { if (document.readyState !== 'loading') {
if (onDOMscripted.resolveOnReady) { if (onDOMscripted.resolveOnReady) {
onDOMscripted.resolveOnReady.forEach(r => r()); onDOMscripted.resolveOnReady.forEach(r => r());
onDOMscripted.resolveOnReady = null; onDOMscripted.resolveOnReady = null;
@ -92,15 +92,13 @@ function onDOMscripted(scripts) {
if (!next) { if (!next) {
onDOMscripted.scriptQueue = null; onDOMscripted.scriptQueue = null;
onDOMscripted(); onDOMscripted();
} } else if (typeof next === 'function') {
else if (typeof next == 'function') {
Promise.resolve(next()) Promise.resolve(next())
.then(loadNextScript); .then(loadNextScript);
} } else {
else {
Promise.all( Promise.all(
(next instanceof Array ? next : [next]).map(next => (next instanceof Array ? next : [next]).map(next =>
typeof next == 'function' typeof next === 'function'
? next() ? next()
: injectScript({src: next, async: true}) : injectScript({src: next, async: true})
) )
@ -118,7 +116,7 @@ function onDOMscripted(scripts) {
function injectScript(properties) { function injectScript(properties) {
if (typeof properties == 'string') { if (typeof properties === 'string') {
properties = {src: properties}; properties = {src: properties};
} }
if (!properties || !properties.src) { if (!properties || !properties.src) {
@ -128,7 +126,7 @@ function injectScript(properties) {
Object.assign(script, properties); Object.assign(script, properties);
if (!properties.onload) { if (!properties.onload) {
return new Promise(resolve => { return new Promise(resolve => {
script.onload = () => { script.onload = null; resolve() }; script.onload = () => { script.onload = null; resolve(); };
}); });
} }
} }