ソースを参照

ensure attributes exist before reading them

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

+ 2 - 2
lib/single-file/single-file-core.js

@@ -328,12 +328,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			if (this.options.removeScripts) {
 				this.onEventAttributeNames.forEach(attributeName => this.doc.querySelectorAll("[" + attributeName + "]").forEach(element => element.removeAttribute(attributeName)));
 				this.doc.querySelectorAll("[href]").forEach(element => {
-					if (element.href.match(/^\s*javascript:/)) {
+					if (element.href && element.href.match(/^\s*javascript:/)) {
 						element.removeAttribute("href");
 					}
 				});
 				this.doc.querySelectorAll("[src]").forEach(element => {
-					if (element.src.match(/^\s*javascript:/)) {
+					if (element.src && element.src.match(/^\s*javascript:/)) {
 						element.removeAttribute("src");
 					}
 				});