we call update() manualle through registerTranslation() at the moment, so no need to observe the 'lang' attribute

this might change in the future if we separate loading of languages from changing of languages
This commit is contained in:
Jacob Overgaard
2023-08-11 12:15:22 +02:00
parent b0e56fb062
commit eb902f3049

View File

@@ -26,17 +26,17 @@ export interface DefaultTranslationSet extends TranslationSet {
}
export const connectedElements = new Set<HTMLElement>();
const documentElementObserver = new MutationObserver(update);
// const documentElementObserver = new MutationObserver(update);
export const translations: Map<string, TranslationSet> = new Map();
export let documentDirection = document.documentElement.dir || 'ltr';
export let documentLanguage = document.documentElement.lang || navigator.language;
export let fallback: TranslationSet;
// Watch for changes on <html lang>
documentElementObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ['dir', 'lang'],
});
// documentElementObserver.observe(document.documentElement, {
// attributes: true,
// attributeFilter: ['lang'],
// });
/** Registers one or more translations */
export function registerTranslation(...translation: TranslationSet[]) {