fix: restore original unmounted implementation in BaseComponent

pull/6889/head
YannisJustine 2024-11-28 22:07:42 +01:00
parent e165c82513
commit 01713fb1ab
2 changed files with 10 additions and 10 deletions

View File

@ -53,7 +53,7 @@ export default {
if (newValue) { if (newValue) {
this._loadScopedThemeStyles(newValue); this._loadScopedThemeStyles(newValue);
this._themeScopedListener = () => this._loadScopedThemeStyles(newValue); this._themeScopedListener = () => this._loadScopedThemeStyles(newValue);
this._themeChangeListener(this._themeScopedListener) this._themeChangeListener(this._themeScopedListener);
} else { } else {
this._unloadScopedThemeStyles(); this._unloadScopedThemeStyles();
} }
@ -107,6 +107,7 @@ export default {
unmounted() { unmounted() {
ThemeService.off('theme:change', this._loadCoreStyles); ThemeService.off('theme:change', this._loadCoreStyles);
ThemeService.off('theme:change', this._load); ThemeService.off('theme:change', this._load);
this._unloadScopedThemeStyles();
this._hook('onUnmounted'); this._hook('onUnmounted');
}, },
methods: { methods: {

View File

@ -79,7 +79,7 @@ const BaseDirective = {
BaseDirective._loadThemeStyles(el.$instance, useStyleOptions); BaseDirective._loadThemeStyles(el.$instance, useStyleOptions);
BaseDirective._loadScopedThemeStyles(el.$instance, useStyleOptions); BaseDirective._loadScopedThemeStyles(el.$instance, useStyleOptions);
const loadStyle = () => BaseDirective._loadThemeStyles(el.$instance, useStyleOptions) const loadStyle = () => BaseDirective._loadThemeStyles(el.$instance, useStyleOptions);
BaseDirective._themeChangeListener(el.$instance, loadStyle); BaseDirective._themeChangeListener(el.$instance, loadStyle);
}, },
@ -137,7 +137,7 @@ const BaseDirective = {
}, },
_themeChangeListener(instance, callback = () => {}) { _themeChangeListener(instance, callback = () => {}) {
if (!instance || !callback) return; if (!instance || !callback) return;
// Store callback reference // Store callback reference
let listeners = _themesCallback.get(instance.$attrSelector); let listeners = _themesCallback.get(instance.$attrSelector);
@ -155,7 +155,7 @@ const BaseDirective = {
const listeners = _themesCallback.get(instance.$attrSelector); const listeners = _themesCallback.get(instance.$attrSelector);
if (listeners) { if (listeners) {
listeners.forEach(callback => { listeners.forEach((callback) => {
ThemeService.off('theme:change', callback); ThemeService.off('theme:change', callback);
}); });
listeners.clear(); listeners.clear();
@ -221,11 +221,10 @@ const BaseDirective = {
const handleWatch = (el) => { const handleWatch = (el) => {
const watchers = el.$instance?.watch; const watchers = el.$instance?.watch;
const handleWatchConfig = ({ newValue, oldValue }) => watchers?.['config']?.call(el.$instance, newValue, oldValue); const handleWatchConfig = ({ newValue, oldValue }) => watchers?.['config']?.call(el.$instance, newValue, oldValue);
const handleWatchConfigRipple = ({ newValue, oldValue }) => watchers?.['config.ripple']?.call(el.$instance, newValue, oldValue) const handleWatchConfigRipple = ({ newValue, oldValue }) => watchers?.['config.ripple']?.call(el.$instance, newValue, oldValue);
_configCallback.set(el, { config: handleWatchConfig, 'config.ripple': handleWatchConfigRipple }); _configCallback.set(el.$instance.$attrSelector, { config: handleWatchConfig, 'config.ripple': handleWatchConfigRipple });
// for 'config' // for 'config'
watchers?.['config']?.call(el.$instance, el.$instance?.$primevueConfig); watchers?.['config']?.call(el.$instance, el.$instance?.$primevueConfig);
@ -237,14 +236,14 @@ const BaseDirective = {
}; };
const removeWatch = (el) => { const removeWatch = (el) => {
const watchers = _configCallback.get(el); const watchers = _configCallback.get(el.$instance.$attrSelector);
if (watchers) { if (watchers) {
PrimeVueService.off('config:change', watchers.config); PrimeVueService.off('config:change', watchers.config);
PrimeVueService.off('config:ripple:change', watchers['config.ripple']); PrimeVueService.off('config:ripple:change', watchers['config.ripple']);
_configCallback.delete(el); _configCallback.delete(el.$instance.$attrSelector);
} }
} };
return { return {
created: (el, binding, vnode, prevVnode) => { created: (el, binding, vnode, prevVnode) => {