fix(ui/localize.js): make LocalizeManager ssr-compatible
This commit is contained in:
parent
615472cc0a
commit
7baecb5e19
2 changed files with 8 additions and 28 deletions
5
.changeset/olive-eagles-glow.md
Normal file
5
.changeset/olive-eagles-glow.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/ui': patch
|
||||
---
|
||||
|
||||
[localize] make LocalizeManager ssr-compatible
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue