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

This reverts commit 6f07663e8f78147d0cfce0c4b25fb3bfc4978c86.
This commit is contained in:
Jacob Overgaard
2023-08-11 12:29:14 +02:00
parent eb902f3049
commit 7bb98c0a92

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: ['lang'],
// });
documentElementObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ['dir', 'lang'],
});
/** Registers one or more translations */
export function registerTranslation(...translation: TranslationSet[]) {