Bladeren bron

use index given by forEach

Gildas 7 jaren geleden
bovenliggende
commit
711c9e8fd6
1 gewijzigde bestanden met toevoegingen van 3 en 5 verwijderingen
  1. 3 5
      lib/single-file/single-file-core.js

+ 3 - 5
lib/single-file/single-file-core.js

@@ -463,12 +463,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 		replaceStyleContents() {
 			if (this.options.stylesheetContents) {
-				let indexStyle = 0;
-				this.doc.querySelectorAll("style").forEach(styleElement => {
-					if (this.options.stylesheetContents[indexStyle]) {
-						styleElement.textContent = this.options.stylesheetContents[indexStyle];
+				this.doc.querySelectorAll("style").forEach((styleElement, styleIndex) => {
+					if (this.options.stylesheetContents[styleIndex]) {
+						styleElement.textContent = this.options.stylesheetContents[styleIndex];
 					}
-					indexStyle++;
 				});
 			}
 		}