pull/6454/merge
Mert Sincan 2025-01-13 11:22:54 +00:00
parent a1873d0d9c
commit 6ae87fe433
2 changed files with 13 additions and 9 deletions

View File

@ -37,6 +37,8 @@ export default {
isUnstyled: { isUnstyled: {
immediate: true, immediate: true,
handler(newValue) { handler(newValue) {
ThemeService.off('theme:change', this._loadCoreStyles);
if (!newValue) { if (!newValue) {
this._loadCoreStyles(); this._loadCoreStyles();
this._themeChangeListener(this._loadCoreStyles); // update styles with theme settings this._themeChangeListener(this._loadCoreStyles); // update styles with theme settings
@ -46,9 +48,7 @@ export default {
dt: { dt: {
immediate: true, immediate: true,
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (oldValue) { ThemeService.off('theme:change', this._themeScopedListener);
ThemeService.off('theme:change', this._themeScopedListener);
}
if (newValue) { if (newValue) {
this._loadScopedThemeStyles(newValue); this._loadScopedThemeStyles(newValue);
@ -105,8 +105,7 @@ export default {
this._hook('onBeforeUnmount'); this._hook('onBeforeUnmount');
}, },
unmounted() { unmounted() {
ThemeService.off('theme:change', this._loadCoreStyles); this._removeThemeListeners();
ThemeService.off('theme:change', this._load);
this._unloadScopedThemeStyles(); this._unloadScopedThemeStyles();
this._hook('onUnmounted'); this._hook('onUnmounted');
}, },
@ -208,6 +207,11 @@ export default {
Base.clearLoadedStyleNames(); Base.clearLoadedStyleNames();
ThemeService.on('theme:change', callback); ThemeService.on('theme:change', callback);
}, },
_removeThemeListeners() {
ThemeService.off('theme:change', this._loadCoreStyles);
ThemeService.off('theme:change', this._load);
ThemeService.off('theme:change', this._themeScopedListener);
},
_getHostInstance(instance) { _getHostInstance(instance) {
return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined; return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined;
}, },

View File

@ -197,7 +197,7 @@ const BaseDirective = {
el.$pd[name] = { ...el.$pd?.[name], name, instance: el.$instance }; el.$pd[name] = { ...el.$pd?.[name], name, instance: el.$instance };
}; };
const handleWatch = (el) => { const handleWatchers = (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);
@ -214,7 +214,7 @@ const BaseDirective = {
PrimeVueService.on('config:ripple:change', handleWatchConfigRipple); PrimeVueService.on('config:ripple:change', handleWatchConfigRipple);
}; };
const removeWatch = (el) => { const stopWatchers = (el) => {
const watchers = el.$instance.$watchersCallback; const watchers = el.$instance.$watchersCallback;
if (watchers) { if (watchers) {
@ -232,7 +232,7 @@ const BaseDirective = {
beforeMount: (el, binding, vnode, prevVnode) => { beforeMount: (el, binding, vnode, prevVnode) => {
BaseDirective._loadStyles(el, binding, vnode); BaseDirective._loadStyles(el, binding, vnode);
handleHook('beforeMount', el, binding, vnode, prevVnode); handleHook('beforeMount', el, binding, vnode, prevVnode);
handleWatch(el); handleWatchers(el);
}, },
mounted: (el, binding, vnode, prevVnode) => { mounted: (el, binding, vnode, prevVnode) => {
BaseDirective._loadStyles(el, binding, vnode); BaseDirective._loadStyles(el, binding, vnode);
@ -246,7 +246,7 @@ const BaseDirective = {
handleHook('updated', el, binding, vnode, prevVnode); handleHook('updated', el, binding, vnode, prevVnode);
}, },
beforeUnmount: (el, binding, vnode, prevVnode) => { beforeUnmount: (el, binding, vnode, prevVnode) => {
removeWatch(el); stopWatchers(el);
BaseDirective._removeThemeListeners(el.$instance); BaseDirective._removeThemeListeners(el.$instance);
handleHook('beforeUnmount', el, binding, vnode, prevVnode); handleHook('beforeUnmount', el, binding, vnode, prevVnode);
}, },