Prechádzať zdrojové kódy

fixed selection issue

Gildas 7 rokov pred
rodič
commit
ca6105e908
1 zmenil súbory, kde vykonal 3 pridanie a 1 odobranie
  1. 3 1
      extension/core/content/content.js

+ 3 - 1
extension/core/content/content.js

@@ -136,7 +136,6 @@ this.singlefile.top = this.singlefile.top || (() => {
 		const treeWalker = document.createTreeWalker(range.commonAncestorContainer);
 		let selectionFound = false;
 		const ancestorElement = range.commonAncestorContainer != Node.ELEMENT_NODE ? range.commonAncestorContainer.parentElement : range.commonAncestorContainer;
-		ancestorElement.setAttribute(SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
 		while (treeWalker.nextNode() && treeWalker.currentNode != range.endContainer) {
 			if (treeWalker.currentNode == range.startContainer) {
 				selectionFound = true;
@@ -146,6 +145,9 @@ this.singlefile.top = this.singlefile.top || (() => {
 				element.setAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME, "");
 			}
 		}
+		if (selectionFound) {
+			ancestorElement.setAttribute(SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
+		}
 		return selectionFound;
 	}