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,
|
observeOn,
|
||||||
take,
|
take,
|
||||||
shareReplay,
|
shareReplay,
|
||||||
share
|
share,
|
||||||
|
skip
|
||||||
} from "rxjs/operators"
|
} from "rxjs/operators"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -347,7 +348,7 @@ export function initialize(config: unknown) {
|
|||||||
/* Resolve relative links for stability */
|
/* Resolve relative links for stability */
|
||||||
for (const selector of [
|
for (const selector of [
|
||||||
`link[rel="shortcut icon"]`,
|
`link[rel="shortcut icon"]`,
|
||||||
`link[rel="stylesheet"]`
|
// `link[rel="stylesheet"]` // reduce style computations
|
||||||
])
|
])
|
||||||
for (const el of getElements<HTMLLinkElement>(selector))
|
for (const el of getElements<HTMLLinkElement>(selector))
|
||||||
el.href = el.href
|
el.href = el.href
|
||||||
|
@ -64,8 +64,8 @@ export function patchScripts(
|
|||||||
for (const el of els) {
|
for (const el of els) {
|
||||||
if (el.src || /(^|\/javascript)$/i.test(el.type)) {
|
if (el.src || /(^|\/javascript)$/i.test(el.type)) {
|
||||||
const script = document.createElement("script")
|
const script = document.createElement("script")
|
||||||
const key = el.src ? "src" : "innerText"
|
const key = el.src ? "src" : "textContent"
|
||||||
script[key] = el[key]
|
script[key] = el[key]!
|
||||||
el.replaceWith(script)
|
el.replaceWith(script)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ let lang: Record<string, string>
|
|||||||
export function translate(key: TranslateKey, value?: string): string {
|
export function translate(key: TranslateKey, value?: string): string {
|
||||||
if (typeof lang === "undefined") {
|
if (typeof lang === "undefined") {
|
||||||
const el = getElementOrThrow("#__lang")
|
const el = getElementOrThrow("#__lang")
|
||||||
lang = JSON.parse(el.innerText)
|
lang = JSON.parse(el.textContent!)
|
||||||
}
|
}
|
||||||
if (typeof lang[key] === "undefined") {
|
if (typeof lang[key] === "undefined") {
|
||||||
throw new ReferenceError(`Invalid translation: ${key}`)
|
throw new ReferenceError(`Invalid translation: ${key}`)
|
||||||
|
Loading…
Reference in New Issue
Block a user