Skip to content

Commit 8ec47aa

Browse files
authored
fix(material/core): throw better error when mixin doesn't support color variants (#28880)
Fixes that calling a theming mixin for a component that doesn't support color variants was throwing a cryptic error. Fixes #28860.
1 parent d3ea71d commit 8ec47aa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/material/core/tokens/_token-utils.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,13 @@ $_component-prefix: null;
203203
}
204204
$overrides: map.get($tokens, list.append($prefix, $color-variant));
205205
@if $overrides == null {
206-
@error #{'Invalid color variant: '}#{$color-variant}#{'. Supported color variants are: '}#{
207-
_supported-color-variants($tokens, $prefix)
208-
}#{'.'};
206+
$variants: _supported-color-variants($tokens, $prefix);
207+
$secondary-message: if($variants == (),
208+
'Mixin does not support color variants',
209+
'Supported color variants are: #{$variants}'
210+
);
211+
212+
@error 'Invalid color variant: #{$color-variant}. #{$secondary-message}.';
209213
}
210214
@return if($emit-overrides-only, $overrides, map.merge($values, $overrides));
211215
}

0 commit comments

Comments
 (0)