Skip to content

Commit 15c6e77

Browse files
committed
refactor(multiple): fix warnings related to division operator in latest version of Sass
The latest version of Sass prints a warning when the division operator is used. These changes migrate us to the recommended `math.div` function. Fixes #22866.
1 parent 23dfbbb commit 15c6e77

34 files changed

+117
-85
lines changed

WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ http_archive(
1515
# Add sass rules
1616
http_archive(
1717
name = "io_bazel_rules_sass",
18-
sha256 = "c310ba8fe69cce7793954a7f1778b65a86b06690215a504751e12b7df3ab51f8",
19-
strip_prefix = "rules_sass-1.32.13",
18+
sha256 = "80d3e70ab5a8d59494aa9e3a7e4722f9f9a6fe98d1497be6bfa0b9e106b1ea54",
19+
strip_prefix = "rules_sass-1.34.1",
2020
urls = [
21-
"https://github.com/bazelbuild/rules_sass/archive/1.32.13.zip",
22-
"https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.32.13.zip",
21+
"https://github.com/bazelbuild/rules_sass/archive/1.34.1.zip",
22+
"https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.34.1.zip",
2323
],
2424
)
2525

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"rollup-plugin-commonjs": "^10.1.0",
211211
"rollup-plugin-node-resolve": "^5.2.0",
212212
"rollup-plugin-sourcemaps": "^0.6.3",
213-
"sass": "^1.32.13",
213+
"sass": "^1.34.1",
214214
"selenium-webdriver": "^3.6.0",
215215
"semver": "^7.3.4",
216216
"send": "^0.17.1",

src/material-experimental/mdc-card/card.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '@material/card' as mdc-card;
23
@use '../mdc-helpers/mdc-helpers';
34

@@ -43,7 +44,7 @@ $mat-card-default-padding: 16px !default;
4344
// When a subtitle is inside of a header, we want to move it up slightly to reduce the space with
4445
// the title, and add a margin bottom to create space underneath the header.
4546
.mat-mdc-card-subtitle {
46-
margin-top: -($mat-card-default-padding / 2);
47+
margin-top: -(math.div($mat-card-default-padding, 2));
4748
margin-bottom: $mat-card-default-padding;
4849
}
4950
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '@material/density' as mdc-density;
23
@use '@material/textfield' as mdc-textfield;
34
@use 'sass:map';
@@ -54,7 +55,7 @@
5455
// cannot update the spacing to explicit numbers based on the density scale. Instead, we
5556
// determine the height reduction and equally subtract it from the default `top` and `bottom`
5657
// padding that is provided by the Material Design specification.
57-
$vertical-deduction: (mdc-textfield.$height - $height) / 2;
58+
$vertical-deduction: math.div(mdc-textfield.$height - $height, 2);
5859
// Map that describes the padding for form-fields with label.
5960
$with-label-padding: (
6061
top: form-field-sizing.$mat-form-field-with-label-input-padding-top - $vertical-deduction,
@@ -77,7 +78,7 @@
7778
// form-field because we do not know what type of form-field control is set up. Hence
7879
// we always use a fixed position for the label. This does not have any implications.
7980
.mat-mdc-form-field .mat-mdc-text-field-wrapper .mdc-floating-label {
80-
top: $height / 2;
81+
top: math.div($height, 2);
8182
}
8283

8384
// For the outline appearance, we re-create the active floating label transform. This is

src/material-experimental/mdc-form-field/_form-field-native-select.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use 'sass:map';
23
@use '../mdc-helpers/mdc-helpers';
34
@use '../../cdk/a11y';
@@ -65,8 +66,8 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
6566
content: '';
6667
width: 0;
6768
height: 0;
68-
border-left: ($mat-form-field-select-arrow-width / 2) solid transparent;
69-
border-right: ($mat-form-field-select-arrow-width / 2) solid transparent;
69+
border-left: math.div($mat-form-field-select-arrow-width, 2) solid transparent;
70+
border-right: math.div($mat-form-field-select-arrow-width, 2) solid transparent;
7071
border-top: $mat-form-field-select-arrow-height solid;
7172
position: absolute;
7273
right: 0;

src/material-experimental/mdc-select/select.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '@material/menu-surface' as mdc-menu-surface;
23
@use '@material/list' as mdc-list;
34
@use '../../material/core/style/variables';
@@ -105,8 +106,8 @@ $scale: 0.75 !default;
105106
.mat-mdc-select-placeholder {
106107
// Delay the transition until the label has animated about a third of the way through, in
107108
// order to prevent the placeholder from overlapping for a split second.
108-
transition: color variables.$swift-ease-out-duration variables.$swift-ease-out-duration / 3
109-
variables.$swift-ease-out-timing-function;
109+
transition: color variables.$swift-ease-out-duration
110+
math.div(variables.$swift-ease-out-duration, 3) variables.$swift-ease-out-timing-function;
110111

111112
._mat-animation-noopable & {
112113
transition: none;
@@ -137,7 +138,7 @@ $scale: 0.75 !default;
137138
}
138139

139140
.mdc-floating-label--float-above {
140-
max-width: calc(100% / #{$scale} - #{$mat-select-placeholder-arrow-space / $scale});
141+
max-width: calc(100% / #{$scale} - #{math.div($mat-select-placeholder-arrow-space, $scale)});
141142
}
142143
}
143144
&.mat-form-field-appearance-outline {

src/material-experimental/mdc-slide-toggle/slide-toggle.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
@use 'sass:math';
2+
@use 'sass:map';
13
@use '@material/switch/deprecated' as mdc-switch with ($deprecated-suffix: '');
24
@use '@material/form-field' as mdc-form-field;
35
@use '@material/ripple' as mdc-ripple;
4-
@use 'sass:map';
56
@use '../mdc-helpers/mdc-helpers';
67
@use '../../material/core/style/layout-common';
78
@use '../../cdk/a11y';
@@ -87,7 +88,7 @@
8788
// Usually 1px would be enough, but MDC reduces the opacity on the
8889
// element so we need to make this a bit more prominent.
8990
outline: solid 2px;
90-
outline-offset: mdc-switch.$track-height / 2;
91+
outline-offset: math.div(mdc-switch.$track-height, 2);
9192
}
9293
}
9394
}

src/material/badge/_badge-theme.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This contains all of the styles for the badge
22
// rather than just the color/theme because of
33
// no style sheet support for directives.
4+
@use 'sass:math';
45
@use 'sass:color';
56
@use 'sass:map';
67
@use 'sass:meta';
@@ -25,13 +26,13 @@ $large-size: $default-size + 6;
2526

2627
&.mat-badge-above {
2728
.mat-badge-content {
28-
top: -$size / 2;
29+
top: math.div(-$size, 2);
2930
}
3031
}
3132

3233
&.mat-badge-below {
3334
.mat-badge-content {
34-
bottom: -$size / 2;
35+
bottom: math.div(-$size, 2);
3536
}
3637
}
3738

@@ -64,27 +65,27 @@ $large-size: $default-size + 6;
6465
&.mat-badge-overlap {
6566
&.mat-badge-before {
6667
.mat-badge-content {
67-
left: -$size / 2;
68+
left: math.div(-$size, 2);
6869
}
6970
}
7071

7172
[dir='rtl'] &.mat-badge-before {
7273
.mat-badge-content {
7374
left: auto;
74-
right: -$size / 2;
75+
right: math.div(-$size, 2);
7576
}
7677
}
7778

7879
&.mat-badge-after {
7980
.mat-badge-content {
80-
right: -$size / 2;
81+
right: math.div(-$size, 2);
8182
}
8283
}
8384

8485
[dir='rtl'] &.mat-badge-after {
8586
.mat-badge-content {
8687
right: auto;
87-
left: -$size / 2;
88+
left: math.div(-$size, 2);
8889
}
8990
}
9091
}

src/material/card/card.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '../core/style/variables';
23
@use '../core/style/elevation';
34
@use '../core/style/private';
@@ -59,8 +60,8 @@ $header-size: 40px !default;
5960

6061
.mat-card-actions {
6162
@extend %mat-card-section-base;
62-
margin-left: -$padding / 2;
63-
margin-right: -$padding / 2;
63+
margin-left: math.div(-$padding, 2);
64+
margin-right: math.div(-$padding, 2);
6465
padding: 8px 0;
6566
}
6667

src/material/checkbox/checkbox.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $_ripple-radius: 20px;
1818
$_item-spacing: variables.$toggle-padding;
1919

2020
// The width of the line used to draw the checkmark / mixedmark.
21-
$_mark-stroke-size: 2 / 15 * checkbox-common.$size !default;
21+
$_mark-stroke-size: math.div(2, 15) * checkbox-common.$size !default;
2222

2323

2424
// Fades in the background of the checkbox when it goes from unchecked -> {checked,indeterminate}.

src/material/core/option/option.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '../style/menu-common';
23
@use '../style/vendor-prefixes';
34
@use '../style/layout-common';
@@ -77,7 +78,7 @@
7778
}
7879

7980
.mat-option-pseudo-checkbox {
80-
$margin: menu-common.$side-padding / 2;
81+
$margin: math.div(menu-common.$side-padding, 2);
8182
margin-right: $margin;
8283

8384
[dir='rtl'] & {

src/material/core/selection/pseudo-checkbox/pseudo-checkbox.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '../../style/checkbox-common';
23
@use '../../style/private';
34
@use '../../style/variables';
@@ -50,19 +51,20 @@ $_checkmark-size: checkbox-common.$size - (2 * $_padding);
5051
}
5152

5253
.mat-pseudo-checkbox-indeterminate::after {
53-
top: (checkbox-common.$size - checkbox-common.$border-width) / 2 - checkbox-common.$border-width;
54-
left: checkbox-common.$border-width / 2;
54+
top: math.div(checkbox-common.$size - checkbox-common.$border-width, 2) -
55+
checkbox-common.$border-width;
56+
left: math.div(checkbox-common.$border-width, 2);
5557
width: checkbox-common.$size - 6px;
5658
opacity: 1;
5759
border-radius: 2px;
5860
}
5961

6062
.mat-pseudo-checkbox-checked::after {
61-
top: (checkbox-common.$size / 2) - ($_checkmark-size / 4) -
62-
(checkbox-common.$size / 10) - checkbox-common.$border-width;
63+
top: math.div(checkbox-common.$size, 2) - math.div($_checkmark-size, 4) -
64+
math.div(checkbox-common.$size, 10) - checkbox-common.$border-width;
6365
left: $_padding - checkbox-common.$border-width * 1.5;
6466
width: $_checkmark-size;
65-
height: ($_checkmark-size - checkbox-common.$border-width) / 2;
67+
height: math.div($_checkmark-size - checkbox-common.$border-width, 2);
6668
border-left: checkbox-common.$border-width solid currentColor;
6769
transform: rotate(-45deg);
6870
opacity: 1;

src/material/core/style/_menu-common.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use './list-common';
23
@use './layout-common';
34

@@ -63,7 +64,7 @@ $icon-margin: 16px !default;
6364

6465
// Renders a triangle to indicate that the menu item will open a sub-menu.
6566
&::after {
66-
$size: $triangle-height / 2;
67+
$size: math.div($triangle-height, 2);
6768

6869
width: 0;
6970
height: 0;

src/material/core/typography/_typography-utils.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:list';
12
@use 'sass:map';
23
@use 'sass:meta';
34
@use 'sass:string';
@@ -76,9 +77,9 @@
7677
}
7778
@else {
7879
// Otherwise use the shorthand `font`, because it's the least amount of bytes. Note
79-
// that we need to use interpolation for `font-size/line-height` in order to prevent
80+
// that we need to use `list.slash` for `font-size/line-height` in order to prevent
8081
// Sass from dividing the two values.
81-
font: $font-weight #{$font-size}/#{$line-height} $font-family;
82+
font: $font-weight list.slash($font-size, $line-height) $font-family;
8283
}
8384
}
8485

src/material/datepicker/calendar-body.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
@use 'sass:math';
12
@use '../../cdk/a11y';
23

34
$calendar-body-label-padding-start: 5% !default;
45
// We don't want the label to jump around when we switch between month and year views, so we use
56
// the same amount of padding regardless of the number of columns. We align the header label with
67
// the one third mark of the first cell, this was chosen somewhat arbitrarily to make it look
78
// roughly like the mock. Half way is too far since the cell text is center aligned.
8-
$calendar-body-label-side-padding: 33% / 7 !default;
9+
$calendar-body-label-side-padding: math.div(33%, 7) !default;
910
$calendar-body-cell-min-size: 32px !default;
1011
$calendar-body-cell-content-margin: 5% !default;
1112
$calendar-body-cell-content-border-width: 1px !default;

src/material/datepicker/date-range-input.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use '../core/style/variables';
23
@use '../core/style/vendor-prefixes';
34
@use '../../cdk/a11y';
@@ -6,8 +7,8 @@ $date-range-input-separator-spacing: 4px;
67
$date-range-input-part-max-width: calc(50% - #{$date-range-input-separator-spacing});
78

89
@mixin _placeholder-transition($property) {
9-
transition: #{$property} variables.$swift-ease-out-duration variables.$swift-ease-out-duration / 3
10-
variables.$swift-ease-out-timing-function;
10+
transition: #{$property} variables.$swift-ease-out-duration
11+
math.div(variables.$swift-ease-out-duration, 3) variables.$swift-ease-out-timing-function;
1112
}
1213

1314
// Host of the date range input.

src/material/form-field/_form-field-fill-theme.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use 'sass:map';
23
@use '../core/theming/theming';
34
@use '../core/typography/typography';
@@ -54,7 +55,7 @@ $fill-dedupe: 0;
5455
@mixin _label-floating($font-scale, $infix-padding, $infix-margin-top) {
5556
transform: translateY(-$infix-margin-top - $infix-padding + $fill-dedupe)
5657
scale($font-scale);
57-
width: 100% / $font-scale + $fill-dedupe;
58+
width: math.div(100%, $font-scale) + $fill-dedupe;
5859

5960
$fill-dedupe: $fill-dedupe + 0.00001 !global;
6061
}

src/material/form-field/_form-field-legacy-theme.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use 'sass:map';
23
@use '../core/theming/theming';
34
@use '../core/style/form-common';
@@ -54,7 +55,7 @@ $legacy-dedupe: 0;
5455
-ms-transform: translateY(-$infix-margin-top - $infix-padding + $legacy-dedupe)
5556
scale($font-scale);
5657

57-
width: 100% / $font-scale + $legacy-dedupe;
58+
width: math.div(100%, $font-scale) + $legacy-dedupe;
5859

5960
$legacy-dedupe: $legacy-dedupe + 0.00001 !global;
6061
}
@@ -79,7 +80,7 @@ $legacy-dedupe: 0;
7980
$subscript-font-scale: 0.75;
8081
// The amount of space between the top of the line and the top of the actual text
8182
// (as a fraction of the font-size).
82-
$line-spacing: ($line-height - 1) / 2;
83+
$line-spacing: math.div($line-height - 1, 2);
8384
// The padding on the infix. Mocks show half of the text size, but seem to measure from the edge
8485
// of the text itself, not the edge of the line; therefore we subtract off the line spacing.
8586
$infix-padding: 0.5em - $line-spacing;
@@ -90,7 +91,7 @@ $legacy-dedupe: 0;
9091
// text font size, so we need to divide by the scale factor to make it half of the original text
9192
// size. We again need to subtract off the line spacing since the mocks measure to the edge of the
9293
// text, not the edge of the line.
93-
$subscript-margin-top: 0.5em / $subscript-font-scale - ($line-spacing * 2);
94+
$subscript-margin-top: math.div(0.5em, $subscript-font-scale) - ($line-spacing * 2);
9495
// The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
9596
// absolutely positioned. This is a combination of the subscript's margin and line-height, but we
9697
// need to multiply by the subscript font scale factor since the wrapper has a larger font size.
@@ -143,7 +144,7 @@ $legacy-dedupe: 0;
143144

144145
// We want the subscript to start at the end of the content box, not the padding box,
145146
// so we move it up by the padding amount (adjusted for the smaller font size);
146-
top: calc(100% - #{$wrapper-padding-bottom / $subscript-font-scale});
147+
top: calc(100% - #{math.div($wrapper-padding-bottom, $subscript-font-scale)});
147148
}
148149
}
149150

src/material/form-field/_form-field-outline-theme.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:math';
12
@use 'sass:map';
23
@use '../core/theming/theming';
34
@use '../core/typography/typography';
@@ -77,7 +78,7 @@ $outline-dedupe: 0;
7778
@mixin _label-floating($font-scale, $infix-padding, $infix-margin-top) {
7879
transform: translateY(-$infix-margin-top - $infix-padding + $outline-dedupe)
7980
scale($font-scale);
80-
width: 100% / $font-scale + $outline-dedupe;
81+
width: math.div(100%, $font-scale) + $outline-dedupe;
8182

8283
$outline-dedupe: $outline-dedupe + 0.00001 !global;
8384
}
@@ -97,7 +98,7 @@ $outline-dedupe: 0;
9798
// Mocks show half of the text size, but this margin is applied to an element with the subscript
9899
// text font size, so we need to divide by the scale factor to make it half of the original text
99100
// size.
100-
$subscript-margin-top: 0.5em / $subscript-font-scale;
101+
$subscript-margin-top: math.div(0.5em, $subscript-font-scale);
101102
// The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
102103
// absolutely positioned. This is a combination of the subscript's margin and line-height, but we
103104
// need to multiply by the subscript font scale factor since the wrapper has a larger font size.

0 commit comments

Comments
 (0)