Skip to content

Commit 929a1ba

Browse files
dkimmich-onventisjson-derulo
authored andcommitted
fix: prevent runtime error when providing undefined config
1 parent 8179107 commit 929a1ba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

projects/material-css-vars/src/lib/material-css-vars.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ export class MaterialCssVarsService {
5757
constructor() {
5858
this.renderer = inject(RendererFactory2).createRenderer(null, null);
5959
const cfg = inject(MATERIAL_CSS_VARS_CFG);
60-
this.ROOT = this._getRootElement(cfg.rootSelector);
6160

6261
this.cfg = {
6362
...DEFAULT_MAT_CSS_CFG,
6463
...cfg,
6564
};
6665
this.isAutoContrast = this.cfg.isAutoContrast;
66+
this.ROOT = this._getRootElement(this.cfg.rootSelector);
6767

6868
if (typeof this.cfg.isDarkTheme === "boolean") {
6969
this.setDarkTheme(this.cfg.isDarkTheme);
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InjectionToken } from "@angular/core";
22
import { MaterialCssVariablesConfig } from "./lib/model";
33

4-
export const MATERIAL_CSS_VARS_CFG =
5-
new InjectionToken<MaterialCssVariablesConfig>("Mat Css Config");
4+
export const MATERIAL_CSS_VARS_CFG = new InjectionToken<
5+
MaterialCssVariablesConfig | undefined
6+
>("Mat Css Config");

0 commit comments

Comments
 (0)