ソースを参照

added constant FLOW_ELEMENTS_SELECTOR

Former-commit-id: 13c95a112642189cee77363b086fd70752ab1d24
Gildas 6 年 前
コミット
fc6ec69c72
1 ファイル変更3 行追加2 行削除
  1. 3 2
      lib/single-file/single-file-helper.js

+ 3 - 2
lib/single-file/single-file-helper.js

@@ -44,6 +44,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 	const DISABLED_NOSCRIPT_ATTRIBUTE_NAME = "data-single-file-disabled-noscript";
 	const SELECTED_CONTENT_ATTRIBUTE_NAME = "data-single-file-selected-content";
 	const ASYNC_SCRIPT_ATTRIBUTE_NAME = "data-single-file-async-script";
+	const FLOW_ELEMENTS_SELECTOR = "*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)";
 	const IGNORED_REMOVED_TAG_NAMES = ["NOSCRIPT", "DISABLED-NOSCRIPT", "META", "LINK", "STYLE", "TITLE", "TEMPLATE", "SOURCE", "OBJECT", "SCRIPT", "HEAD"];
 	const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
 	const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
@@ -98,10 +99,10 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 		});
 		initDoc(doc);
 		if (doc.head) {
-			doc.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach(element => element.hidden = true);
+			doc.head.querySelectorAll(FLOW_ELEMENTS_SELECTOR).forEach(element => element.hidden = true);
 		}
 		doc.querySelectorAll("svg foreignObject").forEach(element => {
-			const flowElements = element.querySelectorAll("html > head > *:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title), html > body > *:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)");
+			const flowElements = element.querySelectorAll("html > head > " + FLOW_ELEMENTS_SELECTOR + ", html > body > " + FLOW_ELEMENTS_SELECTOR);
 			if (flowElements.length) {
 				Array.from(element.childNodes).forEach(node => node.remove());
 				flowElements.forEach(flowElement => element.appendChild(flowElement));