Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

In this function I compile rem to px and em to px.

$base: 16 !default;
    
    @function scut-strip-unit ($num) {
      @return $num / ($num * 0 + 1);
    }
    
    @function rem ($pixels) {
      @return scut-strip-unit($pixels) / $base * 1rem;
    }
    @function em ($pixels, $context: $base) {
        @return #{$pixels/$context}em;
      }

But in new update sass 1.49, we are facing this error:

    Error
    Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
    
    Recommendation: math.div(scut-strip-unit($pixels), $base) or calc(scut-strip-unit($pixels) / $base)
    
    More info and automated migrator: https://sass-lang.com/d/slash-div
    
      â•·
    8 │   @return scut-strip-unit($pixels) / $base * 1rem;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

What they are saying is that you should be using the math.div from sass:math to make divisions. You could do it this way (notice the @use "sass:math";):

@use "sass:math";

@function to-rem($pxNb) {
    @return math.div($pxNb, 16) * 1rem;
}


@function scut-strip-unit ($num) {
  @return math.div($num, ($num * 0 + 1));
}


@function rem ($pixels) {
  @return math.div(scut-strip-unit($pixels),($base * 1rem));
}
@function em ($pixels, $context: $base) {
    @return #{math.div($pixels,$context)}em;
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading