only affect links within the document (#1282)

This commit is contained in:
pngwn 2022-05-16 18:29:19 +01:00 committed by GitHub
parent 8b1a50775a
commit e49cf6f72d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -56,6 +56,7 @@
export let static_src: string;
export let title: string = "Gradio";
export let analytics_enabled: boolean = false;
export let target: HTMLElement;
let rootNode: Component = { id: layout.id, type: "column", props: {} };
components.push(rootNode);
@ -181,11 +182,11 @@
async function handle_mount() {
await tick();
var a = document.getElementsByTagName("a");
var a = target.getElementsByTagName("a");
for (var i = 0; i < a.length; i++) {
const target = a[i].getAttribute("target");
if (target !== "_blank") a[i].setAttribute("target", "_blank");
const _target = a[i].getAttribute("target");
if (_target !== "_blank") a[i].setAttribute("target", "_blank");
}
dependencies.forEach(

View File

@ -98,7 +98,7 @@ window.launchGradio = (config: Config, element_query: string) => {
new Blocks({
target: target,
props: config
props: { ...config, target }
});
}
};