From a691819fa3608d977d2add503037ddada4401fa3 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 26 Jul 2021 08:01:02 +0200 Subject: [PATCH] fix(material/core): handle hues inferred as numbers 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. --- src/material/core/theming/_theming.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/material/core/theming/_theming.scss b/src/material/core/theming/_theming.scss index 5f91c85c48ce..cef0814284f4 100644 --- a/src/material/core/theming/_theming.scss +++ b/src/material/core/theming/_theming.scss @@ -77,7 +77,9 @@ $_emitted-density: () !default; @return get-color-from-palette($palette, default, $hue); } - $color: map.get($palette, $hue); + // We cast the $hue to a string, because some hues starting with a number, like `700-contrast`, + // might be inferred as numbers by Sass. Casting them to string fixes the map lookup. + $color: if(map.has-key($palette, $hue), map.get($palette, $hue), map.get($palette, $hue + '')); @if (meta.type-of($color) != color) { // If the $color resolved to something different from a color (e.g. a CSS variable),