Skip to content

Commit

Permalink
fix theme shifting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Dec 17, 2023
1 parent 439147e commit 6e99365
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions themes/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ def from_cookie_str(c):
"""

js_code_for_css_changing = """(css) => {
var existingStyles = document.querySelectorAll("body > gradio-app > div > style")
for (var i = 0; i < existingStyles.length; i++) {
var style = existingStyles[i];
style.parentNode.removeChild(style);
}
var existingStyles = document.querySelectorAll("style[data-loaded-css]");
for (var i = 0; i < existingStyles.length; i++) {
var style = existingStyles[i];
style.parentNode.removeChild(style);
}
var styleElement = document.createElement('style');
styleElement.setAttribute('data-loaded-css', css);
styleElement.setAttribute('data-loaded-css', 'placeholder');
styleElement.innerHTML = css;
document.head.appendChild(styleElement);
document.body.appendChild(styleElement);
}
"""

Expand Down

0 comments on commit 6e99365

Please sign in to comment.