Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradio/templates/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"
>
<head>
<base target="_blank" />
<!-- <base target="_blank" /> -->
Comment thread
pngwn marked this conversation as resolved.
Outdated
Comment thread
pngwn marked this conversation as resolved.
Outdated
<meta charset="utf-8" />
<meta
name="viewport"
Expand Down Expand Up @@ -59,8 +59,8 @@
rel="stylesheet"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
<script type="module" crossorigin src="./assets/index.11df9c88.js"></script>
<link rel="stylesheet" href="./assets/index.4b0ec74e.css">
<script type="module" crossorigin src="./assets/index.2696258f.js"></script>
<link rel="stylesheet" href="./assets/index.bf810f69.css">
</head>

<body
Expand Down
1 change: 0 additions & 1 deletion ui/packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"
>
<head>
<base target="_blank" />
<meta charset="utf-8" />
<meta
name="viewport"
Expand Down
8 changes: 8 additions & 0 deletions ui/packages/app/src/Blocks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@

async function handle_mount() {
await tick();

Copy link
Copy Markdown
Contributor

@aliabid94 aliabid94 May 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we affecting all links on the page?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we want to open them all in a new tab (including any links that are generated via markdown, which is why we need to do it this way), this was previously being done with the base element but that also affects form actions which we don't want because of the login form in iframes.

var a = document.getElementsByTagName("a");

for (var i = 0; i < a.length; i++) {
const target = a[i].getAttribute("target");
if (target !== "_blank") a[i].setAttribute("target", "_blank");
}

dependencies.forEach(
(
{ targets, trigger, inputs, outputs, queue, backend_fn, frontend_fn },
Expand Down
1 change: 1 addition & 0 deletions ui/packages/app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ window.launchGradio = (config: Config, element_query: string) => {
target: target,
props: config
});
window.__gradio_loader__.$set({ status: "complete" });
} else {
handle_darkmode(target);

Expand Down