Explorar o código

allow navigation from iframes used for web-components

Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
722bd2906b
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      lib/single-file/single-file-core.js

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

@@ -1005,10 +1005,14 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 								if (frameData.shadowRootContent) {
 									const frameDoc = frameData.processor.getDocument();
 									frameDoc.documentElement.setAttribute("style", "overflow:hidden");
+									frameDoc.querySelectorAll("a[href]").forEach(element => {
+										element.target = "_top";
+										element.rel = "noopener";
+									});
 								}
 								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)) {
+								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");