Sfoglia il codice sorgente

improved removal of nodes after the selection

Former-commit-id: 69b8da868ddfa60f5668bf2ee4b713873cc7ebf4
Gildas 6 anni fa
parent
commit
f89a284ab9
1 ha cambiato i file con 10 aggiunte e 4 eliminazioni
  1. 10 4
      lib/single-file/single-file-core.js

+ 10 - 4
lib/single-file/single-file-core.js

@@ -565,10 +565,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 						} else if (selectedElementFound) {
 							removeNode(node);
 						} else {
-							if (canHideNode(node)) {
-								node.style.setProperty("display", "none", "important");
-								Array.from(node.childNodes).forEach(removeNode);
-							}
+							hideNode(node);
 						}
 					}
 				});
@@ -577,6 +574,15 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			function removeNode(node) {
 				if ((node.nodeType != 1 || !node.querySelector("svg,style,link")) && canHideNode(node)) {
 					node.remove();
+				} else {
+					hideNode(node);
+				}
+			}
+
+			function hideNode(node) {
+				if (canHideNode(node)) {
+					node.style.setProperty("display", "none", "important");
+					Array.from(node.childNodes).forEach(removeNode);
 				}
 			}