Browse Source

fixed navigation from web components

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

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

@@ -1006,17 +1006,17 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 									const frameDoc = frameData.processor.getDocument();
 									frameDoc.documentElement.setAttribute("style", "overflow:hidden");
 									frameDoc.querySelectorAll("a[href]").forEach(element => {
-										element.target = "_top";
-										element.rel = "noopener";
+										element.target = "_blank";
+										element.rel = "noopener noreferrer";
 									});
 								}
 								const pageData = await frameData.processor.getPageData();
 								frameElement.removeAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME);
-								if (pageData.content.match(NOSCRIPT_TAG_FOUND) || pageData.content.match(SCRIPT_TAG_FOUND) || frameData.shadowRootContent) {
-									frameElement.setAttribute("sandbox", "allow-popups allow-scripts allow-same-origin");
-								} else {
-									frameElement.setAttribute("sandbox", "allow-popups");
+								let sandbox = "allow-popups allow-top-navigation allow-top-navigation-by-user-activation";
+								if (pageData.content.match(NOSCRIPT_TAG_FOUND) || pageData.content.match(SCRIPT_TAG_FOUND)) {
+									sandbox += "allow-scripts allow-same-origin";
 								}
+								frameElement.setAttribute("sandbox", sandbox);
 								if (frameElement.tagName == "OBJECT") {
 									frameElement.setAttribute("data", "data:text/html," + pageData.content);
 								} else {