Fix theme re-selection after switching to none
Re-creating the #pagerite-theme link anchored to #pagerite-base, which does not exist in dev (base CSS is a Vite-injected <style>), so the fallback prepended it before the base styles and the theme lost the cascade. Anchor to the following sheet (banner design / custom CSS) or append at the end instead, keeping base < theme < design < custom order.
This commit is contained in:
@@ -432,11 +432,19 @@ async function onThemeChange() {
|
|||||||
if (link) {
|
if (link) {
|
||||||
link.href = href
|
link.href = href
|
||||||
} else {
|
} else {
|
||||||
|
// Re-create after "none": keep base < theme < design < custom CSS.
|
||||||
|
// In dev there is no #pagerite-base link (the base is a
|
||||||
|
// Vite-injected <style>), so anchor to the next sheet instead of
|
||||||
|
// prepending before the base styles.
|
||||||
link = document.createElement('link')
|
link = document.createElement('link')
|
||||||
link.rel = 'stylesheet'
|
link.rel = 'stylesheet'
|
||||||
link.id = 'pagerite-theme'
|
link.id = 'pagerite-theme'
|
||||||
document.getElementById('pagerite-base')?.after(link)
|
link.href = href
|
||||||
?? document.head.prepend(link)
|
const before = document.getElementById('pagerite-base')?.nextSibling
|
||||||
|
?? document.getElementById('pagerite-banner')
|
||||||
|
?? document.getElementById('pagerite-user')
|
||||||
|
if (before) before.before(link)
|
||||||
|
else document.head.append(link)
|
||||||
}
|
}
|
||||||
} else if (link) {
|
} else if (link) {
|
||||||
link.remove()
|
link.remove()
|
||||||
|
|||||||
Reference in New Issue
Block a user