Skip to content

fix(material/core): add key validation to m2-theme #31631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/material/core/tokens/_system.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@use '../style/sass-utils';
@use './m2';
@use './m3';
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';

Expand Down Expand Up @@ -328,6 +329,20 @@
'configs created with define-light-theme or define-dark-theme';
}

// Check whether any override keys do not match keys in the theme
// config system map.
$invalid-keys: ();
$config-system: map.get($theme-config, _mat-system);
@each $key, $value in $overrides {
@if (not map.has-key($config-system, $key)) {
$invalid-keys: list.append($invalid-keys, $key);
}
}
@if (list.length($invalid-keys) > 0) {
@error 'The following overrides are not valid system variables: #{$invalid-keys}. ' +
'Valid keys are: #{map.keys($config-system)}';
}

$config: m2-inspection.get-m2-config($theme-config);

$color: map.get($config, color);
Expand Down
Loading