Build: Replace SASS division with function polyfill#4314
Conversation
mejiaj
left a comment
There was a problem hiding this comment.
Fantastic, thanks for your help on this. Minor comment on placement on function and question on spacing-multiple().
Otherwise LGTM.
| 9: divide(100% * 9, 12), | ||
| 10: divide(100% * 10, 12), | ||
| 11: divide(100% * 11, 12), | ||
| 12: divide(100% * 12, 12), |
There was a problem hiding this comment.
Let's just confirm this gives the expected results.
There was a problem hiding this comment.
A small difference in that there's no rounding for the final precision value at 10 decimal places (e.g. 16.6666666667% vs. 16.6666666666%):
https://www.sassmeister.com/gist/aduth/bcfcde6eeeec8272e56c4321a6678f48
There was a problem hiding this comment.
It might be possible to emulate the rounding: Do one extra level of recursion past $precision, then + 1 the last digit if that value is >= 5. 🤔
There was a problem hiding this comment.
Here's a version with rounding: https://www.sassmeister.com/gist/aduth/95bacec332c6390bacaff9fe5ccc82b9
To more accurately reflect an equivalent division value
A bit easier to follow the rounding logic
|
A couple additional thoughts as I've been thinking about this again lately:
|
See also: #4380 |
|
@aduth thanks for fixing this! Just checking to see if/when this will get merged. Looking to clean up build warnings in a USDS/CDC project |
|
Will be released this week in |
Fixes #4204
Previously: #4209 (comment)
Description
This is an attempt to resolve SASS division deprecation warnings and errors in projects which use recent versions of Dart Sass. As an alternative to #4209, it is intended to be compatible across Dart Sass, LibSass, and Ruby Sass. It does this by avoiding the division operation altogether, generating an equivalent result with only multiplication, addition, and subtraction. This could serve as a temporary solution until support for LibSass and Ruby Sass are dropped.
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm testand make sure the tests for the files you have changed have passed.