Sync <html> lang/dir on hot page swaps (fetch nav, editor re-renders)
This commit is contained in:
@@ -832,6 +832,11 @@ import { reconnectPolicy, socketSlot, watchConnecting } from "./reconnect";
|
|||||||
// stylesheet after the server-rendered tag.
|
// stylesheet after the server-rendered tag.
|
||||||
const userStyle = document.getElementById("pagerite-user");
|
const userStyle = document.getElementById("pagerite-user");
|
||||||
if (userStyle) document.head.appendChild(userStyle);
|
if (userStyle) document.head.appendChild(userStyle);
|
||||||
|
// The served language rides on <html> (lang + dir, rtl for e.g.
|
||||||
|
// Arabic) — follow the swapped page (the editor panel carries its
|
||||||
|
// own lang="en" dir="ltr", so it is unaffected).
|
||||||
|
document.documentElement.lang = doc.documentElement.lang;
|
||||||
|
document.documentElement.dir = doc.documentElement.dir;
|
||||||
document.title = doc.title;
|
document.title = doc.title;
|
||||||
// Banners may contain scripts (canvas etc.), content pages may too.
|
// Banners may contain scripts (canvas etc.), content pages may too.
|
||||||
runScripts(document.getElementById("page-banner"));
|
runScripts(document.getElementById("page-banner"));
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ function swapRegions(doc) {
|
|||||||
}
|
}
|
||||||
anchor = imported
|
anchor = imported
|
||||||
}
|
}
|
||||||
|
// The served language rides on <html> (lang + dir, rtl for e.g. Arabic):
|
||||||
|
// follow the swapped page. The editor panel carries its own lang="en"
|
||||||
|
// dir="ltr", so it is unaffected.
|
||||||
|
document.documentElement.lang = doc.documentElement.lang
|
||||||
|
document.documentElement.dir = doc.documentElement.dir
|
||||||
// The editor keeps its own title while open; only inherit the server title
|
// The editor keeps its own title while open; only inherit the server title
|
||||||
// when navigating outside the editor (e.g. fetch-navigation swaps).
|
// when navigating outside the editor (e.g. fetch-navigation swaps).
|
||||||
if (!document.body.classList.contains('editing')) {
|
if (!document.body.classList.contains('editing')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user