ソースを参照

fixed meta[charset] tag appending when the head tag is empty

Gildas 7 年 前
コミット
83cfe4f2de
1 ファイル変更5 行追加1 行削除
  1. 5 1
      lib/single-file/single-file-core.js

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

@@ -462,7 +462,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			});
 			const metaElement = this.doc.createElement("meta");
 			metaElement.setAttribute("charset", "utf-8");
-			this.doc.head.insertBefore(metaElement, this.doc.head.firstElementChild);
+			if (this.doc.head.firstChild) {
+				this.doc.head.insertBefore(metaElement, this.doc.head.firstChild);
+			} else {
+				this.doc.head.appendChild(metaElement);
+			}
 		}
 
 		insertFaviconLink() {