Skip to content

Commit d1d53f5

Browse files
committedNov 6, 2024·
fix(multiple): remove usages of Sass globals (#29972)
In the latest version of Sass, the compiler logs a warning for usages of global functions. These changes switch our code to import the functions instead. (cherry picked from commit 3a3be4c)
1 parent be29219 commit d1d53f5

File tree

8 files changed

+18
-14
lines changed

8 files changed

+18
-14
lines changed
 

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"requirejs": "^2.3.6",
161161
"rollup": "^2.66.1",
162162
"rollup-plugin-sourcemaps": "^0.6.3",
163-
"sass": "^1.77.8",
163+
"sass": "^1.80.6",
164164
"selenium-webdriver": "^3.6.0",
165165
"semver": "^7.3.5",
166166
"send": "^0.17.2",

Diff for: ‎src/material/core/m2/_theming.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use 'sass:list';
22
@use 'sass:map';
33
@use 'sass:meta';
4+
@use 'sass:color';
45
@use '../theming/theming';
56
@use './palette';
67

@@ -82,7 +83,7 @@
8283
@return $color;
8384
}
8485

85-
@return rgba($color, if($opacity == null, opacity($color), $opacity));
86+
@return rgba($color, if($opacity == null, color.opacity($color), $opacity));
8687
}
8788

8889
// Validates the specified theme by ensuring that the optional color config defines

Diff for: ‎src/material/core/theming/_theming.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use 'sass:map';
33
@use 'sass:math';
44
@use 'sass:meta';
5+
@use 'sass:color';
56

67
// Whether to enable compatibility with legacy methods for accessing theme information.
78
$theme-legacy-inspection-api-compatibility: true !default;
@@ -332,7 +333,7 @@ $private-internal-name: _mat-theming-internals-do-not-access;
332333
// We convert the rgba color into a solid one by taking the opacity from the rgba
333334
// value and using it to determine the percentage of the background to put
334335
// into foreground when mixing the colors together.
335-
@return mix($background-color, rgba($color, 1), (1 - opacity($color)) * 100%);
336+
@return color.mix($background-color, rgba($color, 1), (1 - color.opacity($color)) * 100%);
336337
}
337338

338339
// Clamps the density scale to a number between the given min and max.

Diff for: ‎src/material/core/tokens/_m3-tokens.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ $_cached-token-slots: null;
130130
@function create-map($keys, $prefix) {
131131
$result: ();
132132
@each $key in $keys {
133-
$result: map-merge($result, ($key: var(--#{$prefix}-#{$key})));
133+
$result: map.merge($result, ($key: var(--#{$prefix}-#{$key})));
134134
}
135135
@return $result;
136136
}
@@ -191,8 +191,8 @@ $_cached-token-slots: null;
191191
'tertiary-fixed',
192192
'tertiary-fixed-dim'
193193
);
194-
@return map-merge(create-map($keys, $prefix), (
195-
shadow: map.get($mdc-sys-color, shadow)
194+
@return map.merge(create-map($keys, $prefix), (
195+
shadow: map.get($mdc-sys-color, shadow)
196196
));
197197
}
198198

Diff for: ‎src/material/core/tokens/m2/mat/_badge.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $prefix: (mat, badge);
5656
// the value to determine the percentage of the background to put into foreground when
5757
// mixing the colors together.
5858
@if (meta.type-of($disabled-background) == color and meta.type-of($app-background) == color) {
59-
$badge-opacity: opacity($disabled-background);
59+
$badge-opacity: color.opacity($disabled-background);
6060
$disabled-background: color.mix($app-background,
6161
rgba($disabled-background, 1), (1 - $badge-opacity) * 100%);
6262
}

Diff for: ‎src/material/core/tokens/m2/mat/_datepicker.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ $private-default-overlap-color: #a8dab5;
6060
// for a solid border, but because we're using a dashed border for the
6161
// preview range, we need to bump its opacity to ensure that it's visible.
6262
@if meta.type-of($preview-outline-color) == color {
63-
$preview-outline-opacity: math.min(opacity($preview-outline-color) * 2, 1);
63+
$preview-outline-opacity: math.min(color.opacity($preview-outline-color) * 2, 1);
6464
$preview-outline-color: rgba($preview-outline-color, $preview-outline-opacity);
6565
}
6666

Diff for: ‎src/material/core/tokens/m2/mat/_sort.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $prefix: (mat, sort);
2626
// when mixing the colors together. Otherwise, if it resolves to something different
2727
// (e.g. it resolves to a CSS variable), we use the color directly.
2828
@if (meta.type-of($table-background) == color and meta.type-of($text-color) == color) {
29-
$text-opacity: opacity($text-color);
29+
$text-opacity: color.opacity($text-color);
3030
$arrow-color: color.mix($table-background, rgba($text-color, 1), (1 - $text-opacity) * 100%);
3131
}
3232
@else {

Diff for: ‎yarn.lock

+7-5
Original file line numberDiff line numberDiff line change
@@ -14471,14 +14471,16 @@ sass@1.80.5:
1447114471
immutable "^4.0.0"
1447214472
source-map-js ">=0.6.2 <2.0.0"
1447314473

14474-
sass@^1.77.8:
14475-
version "1.77.8"
14476-
resolved "https://registry.yarnpkg.com/sass/-/sass-1.77.8.tgz#9f18b449ea401759ef7ec1752a16373e296b52bd"
14477-
integrity sha512-4UHg6prsrycW20fqLGPShtEvo/WyHRVRHwOP4DzkUrObWoWI05QBSfzU71TVB7PFaL104TwNaHpjlWXAZbQiNQ==
14474+
sass@^1.80.6:
14475+
version "1.80.6"
14476+
resolved "https://registry.yarnpkg.com/sass/-/sass-1.80.6.tgz#5d0aa55763984effe41e40019c9571ab73e6851f"
14477+
integrity sha512-ccZgdHNiBF1NHBsWvacvT5rju3y1d/Eu+8Ex6c21nHp2lZGLBEtuwc415QfiI1PJa1TpCo3iXwwSRjRpn2Ckjg==
1447814478
dependencies:
14479-
chokidar ">=3.0.0 <4.0.0"
14479+
chokidar "^4.0.0"
1448014480
immutable "^4.0.0"
1448114481
source-map-js ">=0.6.2 <2.0.0"
14482+
optionalDependencies:
14483+
"@parcel/watcher" "^2.4.1"
1448214484

1448314485
saucelabs@^1.5.0:
1448414486
version "1.5.0"

0 commit comments

Comments
 (0)
Please sign in to comment.