Skip to content

Instantly share code, notes, and snippets.

@RichNSD
Created May 17, 2023 18:09
Show Gist options
  • Select an option

  • Save RichNSD/aa2d9e1ab97d5c857fec78fc31f3526d to your computer and use it in GitHub Desktop.

Select an option

Save RichNSD/aa2d9e1ab97d5c857fec78fc31f3526d to your computer and use it in GitHub Desktop.

SASS Division Update

Sass currently treats / as a division operation in some contexts and a separator in others. This makes it difficult for Sass users to tell what any given / will mean, and makes it hard to work with new CSS features that use / as a separator. -Sass-Lang.org

Deprecated Syntax

@function strip-units($number) {
	@return $number / ($number * 0 + 1);
}

The above example will no longer be supported starting in Dart Sass 2.0, resulting in the following error message:

Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0

The easiest way to correct the issue is to place the equation inside a calc() function, like so:

Correct Syntax

@function strip-units($number) {
	@return calc($number / ($number * 0 + 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment