Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace / division with multiplication and custom divide() function #34245

Merged
merged 4 commits into from
Jun 14, 2021

Conversation

mdo
Copy link
Member

@mdo mdo commented Jun 14, 2021

Fixes #34051.

This PR aims to resolve the Sass / deprecation issues from Dart Sass. One direction could've been to drop Libsass entirely, using the Dart Sass math module, but that'd effectively ruin any hope for support for Libsass-based projects. That matters not because we want to support something old and deprecated, but because there are dozens if not hundreds of projects that haven't updated to Dart Sass yet. Plus, it's easy enough for us to resolve on our own end without breaking things for others, so why not.

To make this happen, I've replaced the bulk of the division with multiplication, and then used a custom divide() function (thanks @alpadev!) to replace what I couldn't easily switch to multiplication.

Once we get this reviewed and merged, we'll be able to ship v5.0.2.

/cc @twbs/css-review

@mdo mdo requested a review from a team as a code owner June 14, 2021 00:51
@mdo mdo added this to Inbox in v5.0.2 via automation Jun 14, 2021
@XhmikosR XhmikosR moved this from Inbox to Review in v5.0.2 Jun 14, 2021
scss/_variables.scss Outdated Show resolved Hide resolved
@shehi
Copy link

shehi commented Jun 14, 2021

I don't think these "division-to-multiplication" conversions across all files should be made, as it adds complexity to reading the whole code. Why not use newly introduced divide() mixin instead? Cognitively, seeing something divided by 2 vs it being multiplied by 0.5 doesn't lead one to the same reasoning immediately, which might make things more brain numbing. I say all this as someone who checks these values regularly, overriding many of them for my purposes.

scss/_functions.scss Outdated Show resolved Hide resolved
scss/_functions.scss Outdated Show resolved Hide resolved
scss/_variables.scss Outdated Show resolved Hide resolved
Copy link
Contributor

@voltaek voltaek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some copy/paste errors

scss/_functions.scss Outdated Show resolved Hide resolved
scss/_functions.scss Outdated Show resolved Hide resolved
@mdo
Copy link
Member Author

mdo commented Jun 14, 2021

I don't think these "division-to-multiplication" conversions across all files should be made, as it adds complexity to reading the whole code. Why not use newly introduced divide() mixin instead?

I didn't want to require a function where it wasn't explicitly needed. Dividing by 2 or multiplying by .5 feels common enough to me to avoid changing $value / 2 to divide($value, 2), which is longer and inherently more complicated (because of the function) than $value * .5.

@mdo mdo merged commit be17444 into main Jun 14, 2021
v5.0.2 automation moved this from Review to Done Jun 14, 2021
@mdo mdo deleted the drop-sass-division branch June 14, 2021 16:35
@shehi
Copy link

shehi commented Jun 14, 2021

I don't think these "division-to-multiplication" conversions across all files should be made, as it adds complexity to reading the whole code. Why not use newly introduced divide() mixin instead?

I didn't want to require a function where it wasn't explicitly needed. Dividing by 2 or multiplying by .5 feels common enough to me to avoid changing $value / 2 to divide($value, 2), which is longer and inherently more complicated (because of the function) than $value * .5.

Agreed for simple divisions. And I see you fixed this issue for more complicated divisions. All is good, thank you!

@kelunik
Copy link

kelunik commented Jun 14, 2021

Do you plan to backport the same thing to 4.x?

marvin-hinkley-vortx pushed a commit to Vortx-Inc/bootstrap that referenced this pull request Aug 18, 2021
…on (twbs#34245)

* Convert bulk of division to multiplication

* Use custom divide() function instead of Dart Sass math module for greater compatibility

* Apply suggestions from code review

* Fix functions
@AdamGaskins
Copy link

Do you plan to backport the same thing to 4.x?

Here's the PR: #34571 looks like we're close! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
v5.0.2
  
Done
Development

Successfully merging this pull request may close these issues.

Sass deprecation warning: Using / for division is deprecated
9 participants