瀏覽代碼

use index given by forEach

Gildas 7 年之前
父節點
當前提交
711c9e8fd6
共有 1 個文件被更改,包括 3 次插入5 次删除
  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++;
 				});
 			}
 		}