diff --git a/.changeset/olive-eagles-glow.md b/.changeset/olive-eagles-glow.md new file mode 100644 index 000000000..382e4e82c --- /dev/null +++ b/.changeset/olive-eagles-glow.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +[localize] make LocalizeManager ssr-compatible diff --git a/packages/ui/components/localize/src/LocalizeManager.js b/packages/ui/components/localize/src/LocalizeManager.js index 43dd39814..8b75d9c74 100644 --- a/packages/ui/components/localize/src/LocalizeManager.js +++ b/packages/ui/components/localize/src/LocalizeManager.js @@ -12,7 +12,7 @@ import isLocalizeESModule from './isLocalizeESModule.js'; /** * `LocalizeManager` manages your translations (includes loading) */ -export class LocalizeManager { +export class LocalizeManager extends EventTarget { // eslint-disable-line no-unused-vars constructor({ autoLoadOnLocaleChange = false, @@ -20,8 +20,8 @@ export class LocalizeManager { showKeyAsFallback = false, allowOverridesForExistingNamespaces = false, } = {}) { - /** @private */ - this.__delegationTarget = document.createDocumentFragment(); + super(); + /** @protected */ this._autoLoadOnLocaleChange = !!autoLoadOnLocaleChange; /** @protected */ @@ -480,31 +480,6 @@ export class LocalizeManager { return locale.substring(0, 2); } - /** - * @param {string} type - * @param {EventListener} listener - * @param {...Object} options - */ - addEventListener(type, listener, ...options) { - this.__delegationTarget.addEventListener(type, listener, ...options); - } - - /** - * @param {string} type - * @param {EventListener} listener - * @param {...Object} options - */ - removeEventListener(type, listener, ...options) { - this.__delegationTarget.removeEventListener(type, listener, ...options); - } - - /** - * @param {CustomEvent} event - */ - dispatchEvent(event) { - this.__delegationTarget.dispatchEvent(event); - } - /** * @param {string} newLocale * @param {string} oldLocale