Skip to content

Commit 89d9266

Browse files
reduce code duplication
1 parent 9eb9664 commit 89d9266

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

nicegui/elements/aggrid/aggrid.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export default {
55
template: "<div></div>",
66
mounted() {
77
this.update_grid();
8-
this.$el.setAttribute("data-ag-theme-mode", document.body.classList.contains("body--dark") ? "dark" : "light")
9-
this.themeObserver = new MutationObserver(() =>
10-
this.$el.setAttribute("data-ag-theme-mode", document.body.classList.contains("body--dark") ? "dark" : "light")
11-
);
8+
9+
const updateTheme = () =>
10+
this.$el.setAttribute("data-ag-theme-mode", document.body.classList.contains("body--dark") ? "dark" : "light");
11+
this.themeObserver = new MutationObserver(updateTheme);
1212
this.themeObserver.observe(document.body, { attributes: true, attributeFilter: ["class"] });
13+
updateTheme();
1314
},
1415
unmounted() {
1516
this.themeObserver.disconnect();

0 commit comments

Comments
 (0)