Skip to content

Commit 498c150

Browse files
committed
component.Base, container.Base: afterSetTheme() #6292
1 parent ee5954a commit 498c150

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/component/Base.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -970,12 +970,16 @@ class Component extends Base {
970970
*/
971971
afterSetTheme(value, oldValue) {
972972
if (value || oldValue !== undefined) {
973-
let cls = this.cls;
973+
let me = this,
974+
{cls} = me;
974975

975-
NeoArray.remove(cls, oldValue);
976-
value && NeoArray.add(cls, value);
976+
// We do not need to add a DOM based CSS selector, in case the theme is already inherited
977+
if (value !== me.parent?.theme) {
978+
NeoArray.remove(cls, oldValue);
979+
value && NeoArray.add(cls, value);
977980

978-
this.cls = cls
981+
me.cls = cls
982+
}
979983
}
980984
}
981985

src/container/Base.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ class Container extends Component {
216216
}
217217
}
218218

219+
/**
220+
* Triggered after the theme config got changed
221+
* @param {String|null} value
222+
* @param {String|null} oldValue
223+
* @protected
224+
*/
225+
afterSetTheme(value, oldValue) {
226+
super.afterSetTheme(value, oldValue);
227+
228+
value && this.items?.forEach(item => {
229+
if (!Neo.isString(item)) {
230+
item.theme = value
231+
}
232+
})
233+
}
234+
219235
/**
220236
* Triggered after the windowId config got changed
221237
* @param {Number|null} value

0 commit comments

Comments
 (0)