We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc9e7c9 commit bdfbcd5Copy full SHA for bdfbcd5
1 file changed
src/script-loader.ts
@@ -31,14 +31,12 @@ export default class ScriptLoader {
31
if (!this._scripts[src]) {
32
this._scripts[src] = new Promise((resolve, reject) => {
33
const script = document.createElement('script') as LegacyHTMLScriptElement;
34
- const { async = false } = options || {};
35
- const scriptAttributes = options && options.attributes;
+ const { async = false, attributes = {} } = options || {};
36
37
- for (const key in scriptAttributes) {
38
- if (scriptAttributes.hasOwnProperty(key)) {
39
- script.setAttribute(key, scriptAttributes[key]);
40
- }
41
+ Object.keys(attributes)
+ .forEach(key => {
+ script.setAttribute(key, attributes[key]);
+ });
42
43
script.onload = () => resolve();
44
script.onreadystatechange = () => resolve();
0 commit comments