Sfoglia il codice sorgente

fixed rare styling issue when saving selected content

Gildas 7 anni fa
parent
commit
ef4915b584
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      lib/single-file/single-file-core.js

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

@@ -958,7 +958,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		}
 
 		static isolateElements(rootElement) {
-			rootElement.querySelectorAll("*").forEach(element => {
+			rootElement.querySelectorAll("*:not(style)").forEach(element => {
 				if (element.getAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME) == "") {
 					element.removeAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME);
 				} else if (!element.querySelector("[" + SELECTED_CONTENT_ATTRIBUTE_NAME + "]")) {
@@ -970,13 +970,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			function isolateParentElements(parentElement, element) {
 				if (parentElement) {
 					Array.from(parentElement.childNodes).forEach(node => {
-						if (node != element && node.tagName != "HEAD" && node.tagName != "STYLE") {
+						if (node != element && node.tagName != "STYLE") {
 							node.remove();
 						}
 					});
 				}
 				element = element.parentElement;
-				if (element && element.parentElement) {
+				if (element && element.parentElement && element.parentElement.tagName != "BODY") {
 					isolateParentElements(element.parentElement, element);
 				}
 			}