Skip to content

Commit 02f7561

Browse files
crisbetojelbourn
authored andcommitted
refactor(material/core): remove usages of deprecated Sass functions (#20811)
We had a bunch of places using the deprecated variants of functions like `map_get`, `map_has_key` and `map_merge`. These changes migrate to the non-deprecated variants. These changes are also necessary in order for the `sass-migrator` script to migrate the function calls. (cherry picked from commit 63a8ff5)
1 parent 2594c0b commit 02f7561

File tree

16 files changed

+104
-104
lines changed

16 files changed

+104
-104
lines changed

src/material-experimental/mdc-form-field/_form-field-density.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
// provided by MDC in order to support arbitrary form-field controls.
88
@mixin _mat-mdc-form-field-infix-vertical-spacing-filled($with-label-padding, $no-label-padding) {
99
.mat-mdc-text-field-wrapper:not(.mdc-text-field--outlined) .mat-mdc-form-field-infix {
10-
padding-top: map_get($with-label-padding, top);
11-
padding-bottom: map_get($with-label-padding, bottom);
10+
padding-top: map-get($with-label-padding, top);
11+
padding-bottom: map-get($with-label-padding, bottom);
1212
}
1313

1414
.mdc-text-field--no-label:not(.mdc-text-field--outlined):not(.mdc-text-field--textarea)
1515
.mat-mdc-form-field-infix {
16-
padding-top: map_get($no-label-padding, top);
17-
padding-bottom: map_get($no-label-padding, bottom);
16+
padding-top: map-get($no-label-padding, top);
17+
padding-bottom: map-get($no-label-padding, bottom);
1818
}
1919
}
2020

@@ -23,8 +23,8 @@
2323
// provided by MDC in order to support arbitrary form-field controls.
2424
@mixin _mat-mdc-form-field-infix-vertical-spacing-outlined($padding) {
2525
.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix {
26-
padding-top: map_get($padding, top);
27-
padding-bottom: map_get($padding, bottom);
26+
padding-top: map-get($padding, top);
27+
padding-bottom: map-get($padding, bottom);
2828
}
2929
}
3030

src/material-experimental/mdc-helpers/_focus-indicators.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
@mixin mat-mdc-strong-focus-indicators-color($config-or-theme) {
9898
$config: mat-get-color-config($config-or-theme);
99-
@include _mat-mdc-strong-focus-indicators-border-color(mat-color(map_get($config, primary)));
99+
@include _mat-mdc-strong-focus-indicators-border-color(mat-color(map-get($config, primary)));
100100
}
101101

102102
/// Mixin that sets the color of the focus indicators.

src/material-experimental/mdc-list/_interactive-list-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
&.mdc-list-item--selected::before {
17-
background: mat-color(map_get($config, primary));
17+
background: mat-color(map-get($config, primary));
1818
opacity: map-get($state-opacities, selected);
1919
}
2020

src/material/button/_button-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ $_mat-button-ripple-opacity: 0.1;
113113
}
114114

115115
.mat-button-focus-overlay {
116-
background: map_get($foreground, base);
116+
background: map-get($foreground, base);
117117
}
118118

119119
// Note: this needs a bit extra specificity, because we're not guaranteed the inclusion

src/material/checkbox/_checkbox-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
// Switch this to a solid color since we're using `opacity`
7878
// to control how opaque the ripple should be.
7979
.mat-checkbox .mat-ripple-element {
80-
background-color: map_get(map-get($config, foreground), base);
80+
background-color: map-get(map-get($config, foreground), base);
8181
}
8282

8383
.mat-checkbox-checked:not(.mat-checkbox-disabled),

src/material/chips/_chips-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ $mat-chip-remove-font-size: 18px;
6868
}
6969

7070
&::after {
71-
background: map_get($foreground, base);
71+
background: map-get($foreground, base);
7272
}
7373
}
7474

src/material/core/density/_index.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ $_mat-density-generate-styles: true;
4747
}
4848

4949
$value: null;
50-
$property-scale-map: map_get($density-config, $property-name);
50+
$property-scale-map: map-get($density-config, $property-name);
5151

52-
@if map_has_key($property-scale-map, $density-scale) {
53-
$value: map_get($property-scale-map, $density-scale);
52+
@if map-has-key($property-scale-map, $density-scale) {
53+
$value: map-get($property-scale-map, $density-scale);
5454
}
5555
@else {
56-
$value: map_get($property-scale-map, default) + $density-scale * $_mat-density-interval;
56+
$value: map-get($property-scale-map, default) + $density-scale * $_mat-density-interval;
5757
}
5858

59-
$min-value: map_get($property-scale-map, $_mat-density-minimum-scale);
60-
$max-value: map_get($property-scale-map, $_mat-density-maximum-scale);
59+
$min-value: map-get($property-scale-map, $_mat-density-minimum-scale);
60+
$max-value: map-get($property-scale-map, $_mat-density-maximum-scale);
6161

6262
@if ($value < $min-value or $value > $max-value) {
6363
@error 'mat-density: #{$property-name} must be between #{$min-value} and ' +

src/material/core/focus-indicators/_focus-indicators.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
@mixin mat-strong-focus-indicators-color($config-or-theme) {
8989
$config: mat-get-color-config($config-or-theme);
90-
@include _mat-strong-focus-indicators-border-color(mat-color(map_get($config, primary)));
90+
@include _mat-strong-focus-indicators-border-color(mat-color(map-get($config, primary)));
9191
}
9292

9393
/// Mixin that sets the color of the focus indicators.

src/material/core/ripple/_ripple.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ $mat-ripple-color-opacity: 0.1;
4747
/* Colors for the ripple elements.*/
4848
@mixin mat-ripple-color($config-or-theme) {
4949
$config: mat-get-color-config($config-or-theme);
50-
$foreground: map_get($config, foreground);
51-
$foreground-base: map_get($foreground, base);
50+
$foreground: map-get($config, foreground);
51+
$foreground-base: map-get($foreground, base);
5252

5353
.mat-ripple-element {
5454
// If the ripple color is resolves to a color *type*, we can use it directly, otherwise

src/material/core/theming/_check-duplicate-styles.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ $_mat-theme-emitted-density: () !default;
3131
$density-config: mat-get-density-config($theme);
3232
$typography-config: mat-get-typography-config($theme);
3333
// Lists of previous `color`, `density` and `typography` configurations.
34-
$previous-color: map_get($_mat-theme-emitted-color, $id) or ();
35-
$previous-typography: map_get($_mat-theme-emitted-typography, $id) or ();
36-
$previous-density: map_get($_mat-theme-emitted-density, $id) or ();
34+
$previous-color: map-get($_mat-theme-emitted-color, $id) or ();
35+
$previous-typography: map-get($_mat-theme-emitted-typography, $id) or ();
36+
$previous-density: map-get($_mat-theme-emitted-density, $id) or ();
3737
// Whether duplicate legacy density styles would be generated.
3838
$duplicate-legacy-density: false;
3939

@@ -74,11 +74,11 @@ $_mat-theme-emitted-density: () !default;
7474
$previous-density: append($previous-density, $density-config);
7575
}
7676

77-
$_mat-theme-emitted-color: map_merge(
77+
$_mat-theme-emitted-color: map-merge(
7878
$_mat-theme-emitted-color, ($id: $previous-color)) !global;
79-
$_mat-theme-emitted-density: map_merge(
79+
$_mat-theme-emitted-density: map-merge(
8080
$_mat-theme-emitted-density, ($id: $previous-density)) !global;
81-
$_mat-theme-emitted-typography: map_merge(
81+
$_mat-theme-emitted-typography: map-merge(
8282
$_mat-theme-emitted-typography, ($id: $previous-typography)) !global;
8383

8484
// Optionally, consumers of this mixin can wrap contents inside so that nested

src/material/core/theming/_palette.scss

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -672,40 +672,40 @@ $mat-blue-gray: $mat-blue-grey;
672672

673673
// Background palette for light themes.
674674
$mat-light-theme-background: (
675-
status-bar: map_get($mat-grey, 300),
676-
app-bar: map_get($mat-grey, 100),
677-
background: map_get($mat-grey, 50),
675+
status-bar: map-get($mat-grey, 300),
676+
app-bar: map-get($mat-grey, 100),
677+
background: map-get($mat-grey, 50),
678678
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
679679
card: white,
680680
dialog: white,
681681
disabled-button: rgba(black, 0.12),
682682
raised-button: white,
683683
focused-button: $dark-focused,
684-
selected-button: map_get($mat-grey, 300),
685-
selected-disabled-button: map_get($mat-grey, 400),
686-
disabled-button-toggle: map_get($mat-grey, 200),
687-
unselected-chip: map_get($mat-grey, 300),
688-
disabled-list-option: map_get($mat-grey, 200),
689-
tooltip: map_get($mat-grey, 700),
684+
selected-button: map-get($mat-grey, 300),
685+
selected-disabled-button: map-get($mat-grey, 400),
686+
disabled-button-toggle: map-get($mat-grey, 200),
687+
unselected-chip: map-get($mat-grey, 300),
688+
disabled-list-option: map-get($mat-grey, 200),
689+
tooltip: map-get($mat-grey, 700),
690690
);
691691

692692
// Background palette for dark themes.
693693
$mat-dark-theme-background: (
694694
status-bar: black,
695-
app-bar: map_get($mat-grey, 900),
695+
app-bar: map-get($mat-grey, 900),
696696
background: #303030,
697697
hover: rgba(white, 0.04), // TODO(kara): check style with Material Design UX
698-
card: map_get($mat-grey, 800),
699-
dialog: map_get($mat-grey, 800),
698+
card: map-get($mat-grey, 800),
699+
dialog: map-get($mat-grey, 800),
700700
disabled-button: rgba(white, 0.12),
701701
raised-button: map-get($mat-grey, 800),
702702
focused-button: $light-focused,
703-
selected-button: map_get($mat-grey, 900),
704-
selected-disabled-button: map_get($mat-grey, 800),
703+
selected-button: map-get($mat-grey, 900),
704+
selected-disabled-button: map-get($mat-grey, 800),
705705
disabled-button-toggle: black,
706-
unselected-chip: map_get($mat-grey, 700),
706+
unselected-chip: map-get($mat-grey, 700),
707707
disabled-list-option: black,
708-
tooltip: map_get($mat-grey, 700),
708+
tooltip: map-get($mat-grey, 700),
709709
);
710710

711711
// Foreground palette for light themes.

src/material/core/theming/_theming.scss

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $_mat-theme-generate-default-density: true !default;
1717
// @param $primary
1818
// @param $lighter
1919
@function mat-palette($base-palette, $default: 500, $lighter: 100, $darker: 700, $text: $default) {
20-
$result: map_merge($base-palette, (
20+
$result: map-merge($base-palette, (
2121
default: map-get($base-palette, $default),
2222
lighter: map-get($base-palette, $lighter),
2323
darker: map-get($base-palette, $darker),
@@ -30,7 +30,7 @@ $_mat-theme-generate-default-density: true !default;
3030

3131
// For each hue in the palette, add a "-contrast" color to the map.
3232
@each $hue, $color in $base-palette {
33-
$result: map_merge($result, (
33+
$result: map-merge($result, (
3434
'#{$hue}-contrast': mat-contrast($base-palette, $hue)
3535
));
3636
}
@@ -69,15 +69,15 @@ $_mat-theme-generate-default-density: true !default;
6969
// Validates the specified theme by ensuring that the optional color config defines
7070
// a primary, accent and warn palette. Returns the theme if no failures were found.
7171
@function _mat-validate-theme($theme) {
72-
@if map_get($theme, color) {
73-
$color: map_get($theme, color);
74-
@if not map_get($color, primary) {
72+
@if map-get($theme, color) {
73+
$color: map-get($theme, color);
74+
@if not map-get($color, primary) {
7575
@error 'Theme does not define a valid "primary" palette.';
7676
}
77-
@else if not map_get($color, accent) {
77+
@else if not map-get($color, accent) {
7878
@error 'Theme does not define a valid "accent" palette.';
7979
}
80-
@else if not map_get($color, warn) {
80+
@else if not map-get($color, warn) {
8181
@error 'Theme does not define a valid "warn" palette.';
8282
}
8383
}
@@ -94,19 +94,19 @@ $_mat-theme-generate-default-density: true !default;
9494
//
9595
// @mixin my-custom-component-theme($theme) {
9696
// .my-comp {
97-
// background-color: mat-color(map_get($theme, primary));
97+
// background-color: mat-color(map-get($theme, primary));
9898
// }
9999
// }
100100
//
101101
// Note that the `$theme.primary` key does usually not exist since the color configuration
102102
// is stored in `$theme.color` which contains a property for `primary`. This method copies
103103
// the map from `$theme.color` to `$theme` for backwards compatibility.
104104
@function _mat-create-backwards-compatibility-theme($theme) {
105-
@if not map_get($theme, color) {
105+
@if not map-get($theme, color) {
106106
@return $theme;
107107
}
108-
$color: map_get($theme, color);
109-
@return map_merge($theme, $color);
108+
$color: map-get($theme, color);
109+
@return map-merge($theme, $color);
110110
}
111111

112112
// Creates a light-themed color configuration from the specified
@@ -162,12 +162,12 @@ $_mat-theme-generate-default-density: true !default;
162162
// parts of the theming system, but update the `color` configuration if set. As explained
163163
// above, the color shorthand will be expanded to an actual light-themed color configuration.
164164
$result: $primary;
165-
@if map_get($primary, color) {
166-
$color-settings: map_get($primary, color);
167-
$primary: map_get($color-settings, primary);
168-
$accent: map_get($color-settings, accent);
169-
$warn: map_get($color-settings, warn);
170-
$result: map_merge($result, (color: _mat-create-light-color-config($primary, $accent, $warn)));
165+
@if map-get($primary, color) {
166+
$color-settings: map-get($primary, color);
167+
$primary: map-get($color-settings, primary);
168+
$accent: map-get($color-settings, accent);
169+
$warn: map-get($color-settings, warn);
170+
$result: map-merge($result, (color: _mat-create-light-color-config($primary, $accent, $warn)));
171171
}
172172
@return _mat-create-backwards-compatibility-theme(_mat-validate-theme($result));
173173
}
@@ -199,12 +199,12 @@ $_mat-theme-generate-default-density: true !default;
199199
// parts of the theming system, but update the `color` configuration if set. As explained
200200
// above, the color shorthand will be expanded to an actual dark-themed color configuration.
201201
$result: $primary;
202-
@if map_get($primary, color) {
203-
$color-settings: map_get($primary, color);
204-
$primary: map_get($color-settings, primary);
205-
$accent: map_get($color-settings, accent);
206-
$warn: map_get($color-settings, warn);
207-
$result: map_merge($result, (color: _mat-create-dark-color-config($primary, $accent, $warn)));
202+
@if map-get($primary, color) {
203+
$color-settings: map-get($primary, color);
204+
$primary: map-get($color-settings, primary);
205+
$accent: map-get($color-settings, accent);
206+
$warn: map-get($color-settings, warn);
207+
$result: map-merge($result, (color: _mat-create-dark-color-config($primary, $accent, $warn)));
208208
}
209209
@return _mat-create-backwards-compatibility-theme(_mat-validate-theme($result));
210210
}
@@ -223,8 +223,8 @@ $_mat-theme-generate-default-density: true !default;
223223
@if _mat-is-legacy-constructed-theme($theme) {
224224
@return $theme;
225225
}
226-
@if map_has_key($theme, color) {
227-
@return map_get($theme, color);
226+
@if map-has-key($theme, color) {
227+
@return map-get($theme, color);
228228
}
229229
@return $default;
230230
}
@@ -237,8 +237,8 @@ $_mat-theme-generate-default-density: true !default;
237237
}
238238
// In case a theme has been passed, extract the configuration if present,
239239
// or fall back to the default density config.
240-
@if map_has_key($theme-or-config, density) {
241-
@return map_get($theme-or-config, density);
240+
@if map-has-key($theme-or-config, density) {
241+
@return map-get($theme-or-config, density);
242242
}
243243
@return $default;
244244
}
@@ -252,8 +252,8 @@ $_mat-theme-generate-default-density: true !default;
252252
}
253253
// In case a theme has been passed, extract the configuration if present,
254254
// or fall back to the default typography config.
255-
@if (map_has_key($theme-or-config, typography)) {
256-
@return map_get($theme-or-config, typography);
255+
@if (map-has-key($theme-or-config, typography)) {
256+
@return map-get($theme-or-config, typography);
257257
}
258258
@return $default;
259259
}
@@ -262,16 +262,16 @@ $_mat-theme-generate-default-density: true !default;
262262
// of type `map` and can optionally only specify `color`, `density` or `typography`.
263263
@function _mat-is-theme-object($value) {
264264
@return type-of($value) == 'map' and (
265-
map_has_key($value, color) or
266-
map_has_key($value, density) or
267-
map_has_key($value, typography) or
265+
map-has-key($value, color) or
266+
map-has-key($value, density) or
267+
map-has-key($value, typography) or
268268
length($value) == 0
269269
);
270270
}
271271

272272
// Checks whether a given value corresponds to a legacy constructed theme.
273273
@function _mat-is-legacy-constructed-theme($value) {
274-
@return type-of($value) == 'map' and map_get($value, '_is-legacy-theme');
274+
@return type-of($value) == 'map' and map-get($value, '_is-legacy-theme');
275275
}
276276

277277
// Gets the theme from the given value that is either already a theme, or a color configuration.

0 commit comments

Comments
 (0)