Browse Source

don't remove symbol tags when saving selection

Gildas 6 năm trước cách đây
mục cha
commit
88e8fa742c
1 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 11 5
      lib/single-file/single-file-core.js

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

@@ -544,19 +544,25 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 						} else if (selectedElementFound) {
 							removeNode(node);
 						} else {
-							node.style.setProperty("display", "none", "important");
-							Array.from(node.childNodes).forEach(removeNode);
+							if (canHideNode(node)) {
+								node.style.setProperty("display", "none", "important");
+								Array.from(node.childNodes).forEach(removeNode);
+							}
 						}
 					}
 				});
 			}
 
 			function removeNode(node) {
+				if (canHideNode(node)) {
+					node.remove();
+				}
+			}
+
+			function canHideNode(node) {
 				if (node.nodeType == 1) {
 					const tagName = node.tagName && node.tagName.toLowerCase();
-					if (tagName != "svg" && tagName != "style" && tagName != "link") {
-						node.remove();
-					}
+					return (tagName != "svg" && tagName != "style" && tagName != "link");
 				}
 			}
 		}