mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-06 14:39:22 +00:00
fix: keep locale gate within view budget
Track locale-owned inert and busy state together, preserving the same render contract while keeping the deterministic initial View graph below its hard gzip budget. Refresh generated assets and the documentation fingerprint after the source cleanup. Issue: #348 User-Visible: no
This commit is contained in:
@@ -4,4 +4,3 @@ import dictionary from './de.json' with { type: 'json' };
|
||||
export const fingerprint = '__HOUSEPLAN_SOURCE_FINGERPRINT__';
|
||||
|
||||
export { dictionary };
|
||||
|
||||
|
||||
@@ -91,14 +91,12 @@ interface LanguageHostElement {
|
||||
inert: boolean;
|
||||
isConnected: boolean;
|
||||
requestUpdate(): void;
|
||||
hasAttribute(name: string): boolean;
|
||||
setAttribute(name: string, value: string): void;
|
||||
removeAttribute(name: string): void;
|
||||
}
|
||||
|
||||
const committedHosts = new WeakSet<LanguageHostElement>();
|
||||
const localeInertHosts = new WeakSet<LanguageHostElement>();
|
||||
const localeBusyHosts = new WeakSet<LanguageHostElement>();
|
||||
const pendingHosts = new WeakSet<LanguageHostElement>();
|
||||
|
||||
/** Lightweight production render gate; generic controller below remains testable in isolation. */
|
||||
export function languageRenderGate(
|
||||
@@ -108,21 +106,20 @@ export function languageRenderGate(
|
||||
): LanguageRenderGate {
|
||||
const state = code ? runtime.state(code) : 'ready';
|
||||
if (!code || state !== 'pending') {
|
||||
if (localeInertHosts.delete(host)) host.inert = false;
|
||||
if (localeBusyHosts.delete(host)) host.removeAttribute('aria-busy');
|
||||
if (pendingHosts.delete(host)) {
|
||||
host.inert = false;
|
||||
host.removeAttribute('aria-busy');
|
||||
}
|
||||
if (code) {
|
||||
host.setAttribute('lang', state === 'fallback' ? 'en' : code);
|
||||
committedHosts.add(host);
|
||||
}
|
||||
return 'ready';
|
||||
}
|
||||
if (!host.inert) {
|
||||
if (!pendingHosts.has(host)) {
|
||||
host.inert = true;
|
||||
localeInertHosts.add(host);
|
||||
}
|
||||
if (!host.hasAttribute('aria-busy')) {
|
||||
host.setAttribute('aria-busy', 'true');
|
||||
localeBusyHosts.add(host);
|
||||
pendingHosts.add(host);
|
||||
}
|
||||
void runtime.ensure(code).then(() => {
|
||||
if (host.isConnected) host.requestUpdate();
|
||||
|
||||
Reference in New Issue
Block a user