Skip to content

Commit 425c469

Browse files
authored
fix(material/core): add validation to create-token-slot (#27357)
Currently we look up if a token is set to null in the token map, and if it is, we don't emit the slot at all. The problem is that `null` is also returned if the token doesn't exist at all which may mask some bugs. These changes add a check to verify that the token exists before trying to look it up.
1 parent becbdf1 commit 425c469

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ $_component-prefix: null;
7575
@if $_component-prefix == null or $_tokens == null {
7676
@error '`create-token-slot` must be used within `use-tokens`';
7777
}
78+
@if not map.has-key($_tokens, $token) {
79+
@error 'Token #{$token} does not exist. Configured tokens are: #{map.keys($_tokens)}';
80+
}
7881
@if map.get($_tokens, $token) != null {
7982
$fallback: null;
8083

0 commit comments

Comments
 (0)