Skip to content

Commit 4a56d6a

Browse files
committed
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. (cherry picked from commit 8ec47aa)
1 parent 69b5ded commit 4a56d6a

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
@@ -200,9 +200,13 @@ $_component-prefix: null;
200200
}
201201
$overrides: map.get($tokens, list.append($prefix, $color-variant));
202202
@if $overrides == null {
203-
@error #{'Invalid color variant: '}#{$color-variant}#{'. Supported color variants are: '}#{
204-
_supported-color-variants($tokens, $prefix)
205-
}#{'.'};
203+
$variants: _supported-color-variants($tokens, $prefix);
204+
$secondary-message: if($variants == (),
205+
'Mixin does not support color variants',
206+
'Supported color variants are: #{$variants}'
207+
);
208+
209+
@error 'Invalid color variant: #{$color-variant}. #{$secondary-message}.';
206210
}
207211
@return map.merge($values, $overrides);
208212
}

0 commit comments

Comments
 (0)