Fix linting issues with injection code
This commit is contained in:
parent
3c160a3fa5
commit
014adf8d8a
14
js/dom.js
14
js/dom.js
|
@ -78,7 +78,7 @@ function onDOMscripted(scripts) {
|
|||
if (onDOMscripted.scriptQueue) {
|
||||
return new Promise(resolve => addResolver(resolve));
|
||||
}
|
||||
if (document.readyState != 'loading') {
|
||||
if (document.readyState !== 'loading') {
|
||||
if (onDOMscripted.resolveOnReady) {
|
||||
onDOMscripted.resolveOnReady.forEach(r => r());
|
||||
onDOMscripted.resolveOnReady = null;
|
||||
|
@ -92,15 +92,13 @@ function onDOMscripted(scripts) {
|
|||
if (!next) {
|
||||
onDOMscripted.scriptQueue = null;
|
||||
onDOMscripted();
|
||||
}
|
||||
else if (typeof next == 'function') {
|
||||
} else if (typeof next === 'function') {
|
||||
Promise.resolve(next())
|
||||
.then(loadNextScript);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Promise.all(
|
||||
(next instanceof Array ? next : [next]).map(next =>
|
||||
typeof next == 'function'
|
||||
typeof next === 'function'
|
||||
? next()
|
||||
: injectScript({src: next, async: true})
|
||||
)
|
||||
|
@ -118,7 +116,7 @@ function onDOMscripted(scripts) {
|
|||
|
||||
|
||||
function injectScript(properties) {
|
||||
if (typeof properties == 'string') {
|
||||
if (typeof properties === 'string') {
|
||||
properties = {src: properties};
|
||||
}
|
||||
if (!properties || !properties.src) {
|
||||
|
@ -128,7 +126,7 @@ function injectScript(properties) {
|
|||
Object.assign(script, properties);
|
||||
if (!properties.onload) {
|
||||
return new Promise(resolve => {
|
||||
script.onload = () => { script.onload = null; resolve() };
|
||||
script.onload = () => { script.onload = null; resolve(); };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user