Skip to content

Commit b2c7abf

Browse files
authored
fix(material/core): add key validation to m2-theme (#31631)
* fix(material/core): add key validation to m2-theme * refactor: lint
1 parent 839aa3e commit b2c7abf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/material/core/tokens/_system.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
@use '../style/sass-utils';
2525
@use './m2';
2626
@use './m3';
27+
@use 'sass:list';
2728
@use 'sass:map';
2829
@use 'sass:meta';
2930

@@ -328,6 +329,20 @@
328329
'configs created with define-light-theme or define-dark-theme';
329330
}
330331

332+
// Check whether any override keys do not match keys in the theme
333+
// config system map.
334+
$invalid-keys: ();
335+
$config-system: map.get($theme-config, _mat-system);
336+
@each $key, $value in $overrides {
337+
@if (not map.has-key($config-system, $key)) {
338+
$invalid-keys: list.append($invalid-keys, $key);
339+
}
340+
}
341+
@if (list.length($invalid-keys) > 0) {
342+
@error 'The following overrides are not valid system variables: #{$invalid-keys}. ' +
343+
'Valid keys are: #{map.keys($config-system)}';
344+
}
345+
331346
$config: m2-inspection.get-m2-config($theme-config);
332347

333348
$color: map.get($config, color);

0 commit comments

Comments
 (0)