瀏覽代碼

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");
 					}
 				});