mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed JavaScript and CSS evaluation on instant loading
This commit is contained in:
parent
6daac21f65
commit
ea29135841
@ -46,7 +46,8 @@ import {
|
||||
observeOn,
|
||||
take,
|
||||
shareReplay,
|
||||
share
|
||||
share,
|
||||
skip
|
||||
} from "rxjs/operators"
|
||||
|
||||
import {
|
||||
@ -347,7 +348,7 @@ export function initialize(config: unknown) {
|
||||
/* Resolve relative links for stability */
|
||||
for (const selector of [
|
||||
`link[rel="shortcut icon"]`,
|
||||
`link[rel="stylesheet"]`
|
||||
// `link[rel="stylesheet"]` // reduce style computations
|
||||
])
|
||||
for (const el of getElements<HTMLLinkElement>(selector))
|
||||
el.href = el.href
|
||||
|
@ -64,8 +64,8 @@ export function patchScripts(
|
||||
for (const el of els) {
|
||||
if (el.src || /(^|\/javascript)$/i.test(el.type)) {
|
||||
const script = document.createElement("script")
|
||||
const key = el.src ? "src" : "innerText"
|
||||
script[key] = el[key]
|
||||
const key = el.src ? "src" : "textContent"
|
||||
script[key] = el[key]!
|
||||
el.replaceWith(script)
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ let lang: Record<string, string>
|
||||
export function translate(key: TranslateKey, value?: string): string {
|
||||
if (typeof lang === "undefined") {
|
||||
const el = getElementOrThrow("#__lang")
|
||||
lang = JSON.parse(el.innerText)
|
||||
lang = JSON.parse(el.textContent!)
|
||||
}
|
||||
if (typeof lang[key] === "undefined") {
|
||||
throw new ReferenceError(`Invalid translation: ${key}`)
|
||||
|
Loading…
Reference in New Issue
Block a user