Skip to content

Commit c713177

Browse files
allan-chencopybara-github
authored andcommitted
fix(button): prevent null values from being passed to elevation resolver
PiperOrigin-RevId: 401623592
1 parent 4181724 commit c713177

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

components/button/lib/_elevation-theme.scss

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,26 @@ $_selectors: button-theme.$selectors;
6969
);
7070

7171
@each $key in $elevation-keys {
72-
// Unlike `theme-styles`, which delegates to elevation module to resolve
73-
// each state's elevation and place it under the correct selector, for
74-
// runtime theming the state is managed here and the elevation resolver is
75-
// passed a stateless (default state) value. This allows us to cleanly
76-
// attach each state's resolved value to its corresponding key in
77-
// $elevation-keys, without worrying about having to strip state prefixes
78-
// from the resolved keys to match the `theme-styles` CSS custom prop names.
79-
$elevation: (
80-
default: map.get($theme, $key),
81-
);
82-
$resolved-value: meta.call(
83-
$resolver,
84-
$elevation: $elevation,
85-
$shadow-color: $shadow-color
86-
);
87-
// Update the key with the resolved value.
88-
$theme: map.set($theme, $key, $resolved-value);
72+
$elevation-level: map.get($theme, $key);
73+
@if $elevation-level != null {
74+
// Unlike `theme-styles`, which delegates to elevation module to resolve
75+
// each state's elevation and place it under the correct selector, for
76+
// runtime theming the state is managed here and the elevation resolver is
77+
// passed a stateless (default state) value. This allows us to cleanly
78+
// attach each state's resolved value to its corresponding key in
79+
// $elevation-keys, without worrying about having to strip state prefixes
80+
// from the resolved keys to match the `theme-styles` CSS custom prop names.
81+
$elevation: (
82+
default: $elevation-level,
83+
);
84+
$resolved-value: meta.call(
85+
$resolver,
86+
$elevation: $elevation,
87+
$shadow-color: $shadow-color
88+
);
89+
// Update the key with the resolved value.
90+
$theme: map.set($theme, $key, $resolved-value);
91+
}
8992
}
9093
@return $theme;
9194
}

0 commit comments

Comments
 (0)