Skip to content

Commit

Permalink
Fix wasm_proxied_mount_css to not reuse an existing style element (#7709
Browse files Browse the repository at this point in the history
)

* Fix wasm_proxied_mount_css to not reuse an existing style element but replace it for theme updates upon rerunning a new app

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
whitphx and gradio-pr-bot committed Mar 18, 2024
1 parent 0a3870d commit f67759d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/tiny-years-rest.md
@@ -0,0 +1,6 @@
---
"@gradio/app": patch
"gradio": patch
---

fix:Fix wasm_proxied_mount_css to not reuse an existing style element
5 changes: 3 additions & 2 deletions js/app/src/lite/css.ts
Expand Up @@ -35,10 +35,11 @@ export async function wasm_proxied_mount_css(
});
const css = new TextDecoder().decode(response.body);

const existing_link = document.querySelector(
// Gradio Lite can be reloaded without refreshing the page, so we need to remove the existing style element if it exists.
const existing_style = document.querySelector(
`style[data-wasm-path='${url_string}']`
);
if (existing_link) return;
existing_style?.remove();

if (url.pathname === DYNAMIC_THEME_CSS_URL_PATH) {
console.debug(
Expand Down

0 comments on commit f67759d

Please sign in to comment.