Skip to content

Commit

Permalink
fix(ui/localize.js): make LocalizeManager ssr-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
tlouisse committed Oct 29, 2024
1 parent 2d4fb0e commit 5b37c3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-eagles-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/ui': patch
---

[localize] make LocalizeManager ssr-compatible
31 changes: 3 additions & 28 deletions packages/ui/components/localize/src/LocalizeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ 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,
fallbackLocale = '',
showKeyAsFallback = false,
allowOverridesForExistingNamespaces = false,
} = {}) {
/** @private */
this.__delegationTarget = document.createDocumentFragment();
super();

/** @protected */
this._autoLoadOnLocaleChange = !!autoLoadOnLocaleChange;
/** @protected */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b37c3d

Please sign in to comment.