mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-04-07 00:21:05 +00:00
Fix dynamic themes not removing last class
This commit is contained in:
parent
f96b4beb2d
commit
a0c020f7a8
1 changed files with 12 additions and 6 deletions
|
|
@ -120,13 +120,19 @@ export default function install(Vue, themes) {
|
|||
|
||||
document.body.classList.add('md-theme-default');
|
||||
|
||||
Vue.directive('mdTheme', function(el, bindings) {
|
||||
let theme = bindings.value;
|
||||
Vue.directive('mdTheme', (element, { value, oldValue }) => {
|
||||
let theme = value;
|
||||
let newClass = 'md-theme-' + theme;
|
||||
let oldClass = 'md-theme-' + oldValue;
|
||||
|
||||
if (theme && registedThemes.indexOf(theme) >= 0) {
|
||||
el.classList.add('md-theme-' + theme);
|
||||
} else {
|
||||
console.warn('Attempted to use unregistered theme "' + theme + '\".');
|
||||
if (!element.classList.contains(newClass)) {
|
||||
element.classList.remove(oldClass);
|
||||
|
||||
if (theme && registedThemes.indexOf(theme) >= 0) {
|
||||
element.classList.add(newClass);
|
||||
} else {
|
||||
console.warn('Attempted to use unregistered theme "' + theme + '\".');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue