-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rustdoc] Fix system theme detection #63847
Conversation
@@ -118,7 +118,8 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) { | |||
} | |||
|
|||
function getSystemValue() { | |||
return getComputedStyle(document.documentElement).getPropertyValue('content'); | |||
var property = getComputedStyle(document.documentElement).getPropertyValue('content'); | |||
return property.replace(/\"/g, "").replace(/\'/g, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return property.replace(/\"/g, "").replace(/\'/g, ""); | |
return property.replace(/[\"\']/g, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case we change the css for whatever reason, I'd prefer to keep the replace of single quotes as well. Let's avoid surprising regressions if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely @bjorn3's suggestion replaces both double and single quotes, just in one .replace() call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh indeed! Completely missed it... Sorry @bjorn3...
I'm afraid I have no way to know for certain if this functions correctly. |
You can run the code of the function in your browser directly (yes, again... sorry...). You just need to ensure it returns "dark" or "light" without double quotes. |
@kinnison: 🔑 Insufficient privileges: Not in reviewers |
4944373
to
fcbbf8d
Compare
Updated with @bjorn3's suggestion. |
Any updates on this? Do we need to find a different reviewer since @kinnison doesn't have access? |
📌 Commit fcbbf8d has been approved by |
…on, r=kinnison [rustdoc] Fix system theme detection Fixes rust-lang#63830 The problem is that it returns the property "entirely" (so with the quotes in our case). Removing them fixes the issue. cc @fenhl r? @kinnison
Rollup of 7 pull requests Successful merges: - #62957 (Match the loop examples) - #63600 (Merge oli-obk mail addresses) - #63684 (Constify LinkedList new function) - #63847 ([rustdoc] Fix system theme detection) - #63999 (Add missing links on AsRef trait) - #64014 ( miri: detect too large dynamically sized objects ) - #64015 (some const-eval test tweaks) Failed merges: r? @ghost
Fixes #63830
The problem is that it returns the property "entirely" (so with the quotes in our case). Removing them fixes the issue.
cc @fenhl
r? @kinnison