Skip to content

Commit

Permalink
Switch to for...of
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 26, 2024
1 parent 65d9d97 commit 42fe4d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ function run(data) {
}
}

(cli.input || []).forEach((file) => {
for (const file of cli.input || []) {
const temporary = read(file);
try {
parse(temporary);
options_.css = temporary;
} catch {
options_.html = temporary;
}
});
}

if (!options_.html || !options_.css) {
cli.showHelp();
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function inline(html, styles, options) {
);

// Add link tags before old links
o.replaceStylesheets.forEach((href) => {
for (const href of o.replaceStylesheets) {
const link = document.createElement('link');

link.setAttribute('rel', 'stylesheet');
Expand Down Expand Up @@ -139,26 +139,26 @@ export function inline(html, styles, options) {
document.remove(link);
}
}
});
}

// Remove old links
removable.forEach((link) => {
for (const link of removable) {
if (link.parentElement.tagName === 'NOSCRIPT') {
document.remove(link.parentElement);
} else {
document.remove(link);
}
});
}
} else {
// Modify links and add clones to noscript block
links.forEach((link) => {
for (const link of links) {
const href = link.getAttribute('href');
const media = link.getAttribute('media');
const type = link.getAttribute('type');
const integrity = link.getAttribute('integrity');

if (['print', 'speech'].includes(media)) {
return;
continue;
}

if (o.extract) {
Expand Down Expand Up @@ -218,7 +218,7 @@ export function inline(html, styles, options) {
document.remove(link);
}
}
});
}
}

return Buffer.from(document.serialize());
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"prettier": true,
"rules": {
"prefer-template": "error",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-reduce": "off"
},
"overrides": [
Expand Down

0 comments on commit 42fe4d1

Please sign in to comment.