Refactor #6715
parent
a1873d0d9c
commit
6ae87fe433
|
@ -37,6 +37,8 @@ export default {
|
|||
isUnstyled: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
ThemeService.off('theme:change', this._loadCoreStyles);
|
||||
|
||||
if (!newValue) {
|
||||
this._loadCoreStyles();
|
||||
this._themeChangeListener(this._loadCoreStyles); // update styles with theme settings
|
||||
|
@ -46,9 +48,7 @@ export default {
|
|||
dt: {
|
||||
immediate: true,
|
||||
handler(newValue, oldValue) {
|
||||
if (oldValue) {
|
||||
ThemeService.off('theme:change', this._themeScopedListener);
|
||||
}
|
||||
ThemeService.off('theme:change', this._themeScopedListener);
|
||||
|
||||
if (newValue) {
|
||||
this._loadScopedThemeStyles(newValue);
|
||||
|
@ -105,8 +105,7 @@ export default {
|
|||
this._hook('onBeforeUnmount');
|
||||
},
|
||||
unmounted() {
|
||||
ThemeService.off('theme:change', this._loadCoreStyles);
|
||||
ThemeService.off('theme:change', this._load);
|
||||
this._removeThemeListeners();
|
||||
this._unloadScopedThemeStyles();
|
||||
this._hook('onUnmounted');
|
||||
},
|
||||
|
@ -208,6 +207,11 @@ export default {
|
|||
Base.clearLoadedStyleNames();
|
||||
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) {
|
||||
return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined;
|
||||
},
|
||||
|
|
|
@ -197,7 +197,7 @@ const BaseDirective = {
|
|||
el.$pd[name] = { ...el.$pd?.[name], name, instance: el.$instance };
|
||||
};
|
||||
|
||||
const handleWatch = (el) => {
|
||||
const handleWatchers = (el) => {
|
||||
const watchers = el.$instance?.watch;
|
||||
|
||||
const handleWatchConfig = ({ newValue, oldValue }) => watchers?.['config']?.call(el.$instance, newValue, oldValue);
|
||||
|
@ -214,7 +214,7 @@ const BaseDirective = {
|
|||
PrimeVueService.on('config:ripple:change', handleWatchConfigRipple);
|
||||
};
|
||||
|
||||
const removeWatch = (el) => {
|
||||
const stopWatchers = (el) => {
|
||||
const watchers = el.$instance.$watchersCallback;
|
||||
|
||||
if (watchers) {
|
||||
|
@ -232,7 +232,7 @@ const BaseDirective = {
|
|||
beforeMount: (el, binding, vnode, prevVnode) => {
|
||||
BaseDirective._loadStyles(el, binding, vnode);
|
||||
handleHook('beforeMount', el, binding, vnode, prevVnode);
|
||||
handleWatch(el);
|
||||
handleWatchers(el);
|
||||
},
|
||||
mounted: (el, binding, vnode, prevVnode) => {
|
||||
BaseDirective._loadStyles(el, binding, vnode);
|
||||
|
@ -246,7 +246,7 @@ const BaseDirective = {
|
|||
handleHook('updated', el, binding, vnode, prevVnode);
|
||||
},
|
||||
beforeUnmount: (el, binding, vnode, prevVnode) => {
|
||||
removeWatch(el);
|
||||
stopWatchers(el);
|
||||
BaseDirective._removeThemeListeners(el.$instance);
|
||||
handleHook('beforeUnmount', el, binding, vnode, prevVnode);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue