Skip to content

Commit a752641

Browse files
crisbetozarend
authored andcommitted
fix(material/core): handle hues inferred as numbers (#23237)
We have some hues that start with a number (e.g. `700-contrast`), which can break the map lookup in `get-color-from-palette`, because Sass infers them as numbers. These changes make it so that the key is cast to a string before we do the lookup. Fixes #23230. (cherry picked from commit df7c46b)
1 parent efa9e92 commit a752641

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/material/core/theming/_theming.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ $_emitted-density: () !default;
7777
@return get-color-from-palette($palette, default, $hue);
7878
}
7979

80-
$color: map.get($palette, $hue);
80+
// We cast the $hue to a string, because some hues starting with a number, like `700-contrast`,
81+
// might be inferred as numbers by Sass. Casting them to string fixes the map lookup.
82+
$color: if(map.has-key($palette, $hue), map.get($palette, $hue), map.get($palette, $hue + ''));
8183

8284
@if (meta.type-of($color) != color) {
8385
// If the $color resolved to something different from a color (e.g. a CSS variable),

0 commit comments

Comments
 (0)