Skip to content

Commit c14d176

Browse files
authored
fix(material/core): add optional warning for incomplete themes (#25654)
1 parent d082d4d commit c14d176

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/material/core/theming/_theming.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ $_legacy-theme-warning: 'Angular Material themes should be created from a map co
2020
'palette values for "primary", "accent", and "warn". ' +
2121
'See https://material.angular.io/guide/theming for more information.';
2222

23+
// Flag whether theme config getter functions should warn if a key is expected to exist but not
24+
// present in the config. This can be transformed internally in Google to ensure all clients have
25+
// comprehensive theme configurations.
26+
$_enable-strict-theme-config: false;
27+
2328
// These variable are not intended to be overridden externally. They use `!default` to
2429
// avoid being reset every time this file is imported.
2530
$_emitted-color: () !default;
@@ -255,6 +260,9 @@ $_emitted-density: () !default;
255260
@if map.has-key($theme, color) {
256261
@return map.get($theme, color);
257262
}
263+
@else if ($_enable-strict-theme-config) {
264+
@error 'Angular Material theme configuration is missing a "color" value';
265+
}
258266
@return $default;
259267
}
260268

@@ -274,6 +282,9 @@ $_emitted-density: () !default;
274282
@if map.has-key($theme-or-config, density) {
275283
@return map.get($theme-or-config, density);
276284
}
285+
@else if ($_enable-strict-theme-config) {
286+
@error 'Angular Material theme configuration is missing a "density" value';
287+
}
277288
@return $default;
278289
}
279290

@@ -294,6 +305,9 @@ $_emitted-density: () !default;
294305
@if (map.has-key($theme-or-config, typography)) {
295306
@return map.get($theme-or-config, typography);
296307
}
308+
@else if ($_enable-strict-theme-config) {
309+
@error 'Angular Material theme configuration is missing a "typography" value';
310+
}
297311
@return $default;
298312
}
299313

0 commit comments

Comments
 (0)