Passing percentage units to the global abs() function is deprecated

Created on 5 October 2023, 9 months ago
Updated 25 April 2024, 2 months ago

Problem/Motivation

Deprecation Warning: Passing percentage units to the global abs() function is deprecated.
In the future, this will emit a CSS abs() function to be resolved by the browser.
To preserve current behavior: math.abs(40%)
To emit a CSS abs() now: abs(#{40%})
More info: https://sass-lang.com/d/abs-percent

  โ•ท
6 โ”‚     $alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
  โ”‚                                                                  ^^^^^^^^^^^^^^^^^^^^^^^
  โ•ต
    ../../contrib/bootstrap5/scss/drupal/_theme.scss 6:66  @import
    ../../contrib/bootstrap5/scss/_drupal.scss 15:9        @import
    ../../contrib/bootstrap5/scss/style.scss 5:9           @import
    scss/style.scss 9:9                                    root stylesheet

Steps to reproduce

Install with npm install saas
Run with npx sass --watch scss/style.scss dist/css/style.css

Proposed resolution

Remaining tasks

๐Ÿ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia sime Canberra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sime
  • Assigned to sarwan
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sarwan
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sarwan

    Hi @sime,
    I have fixed this issue Passing percentage units to the global abs() function is deprecated and also attached patch,
    please review and verify.

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ravi kant Jaipur
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States kclarkson Atlanta, Georiga

    Good stuff. I just noticed this deprecation today.

    Installed the patch and it removed my compiling errors.

  • Status changed to RTBC 5 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada dshields

    Does what it says it does.

  • Merge request !57Removed abs() โ†’ (Open) created by ravi kant
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ravi kant Jaipur

    I have created MR according to patch.

  • Status changed to Postponed: needs info 4 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia

    Why didn't you use recordation from compiler?
    To preserve current behavior: math.abs(40%)

  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia sime Canberra

    I see my steps to reproduce are different to the installation instructions, so I assume didn't set it up correctly?

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada robbdavis

    I'm getting this warning too.

    I set up gulp to trigger my sass watch. So not sure the error is due to the way I set up sass to compile or if this is a legitimate deprecation warning due to using the most recent version of sass?

    Deprecation Warning: Passing percentage units to the global abs() function is deprecated.
    In the future, this will emit a CSS abs() function to be resolved by the browser.
    To preserve current behavior: math.abs(40%)
    To emit a CSS abs() now: abs(#{40%})
    More info: https://sass-lang.com/d/abs-percent
    
      โ•ท
    6 โ”‚     $alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
    
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada robbdavis

    OK I tried using math.abs() but it wasn't working until I found you need to use @use 'sass:math' at the top of the file. Not sure how to create a patch file so here's the code that works for _theme.scss:

    @use 'sass:math';
    
    @each $state, $value in $theme-colors {
      $alert-background: shift-color($value, $alert-bg-scale);
      $alert-border: shift-color($value, $alert-border-scale);
      $alert-color: shift-color($value, $alert-color-scale);
      @if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) {
        $alert-color: mix($value, color-contrast($alert-background), math.abs($alert-color-scale));
      }
      .color-#{$state} {
        --#{$prefix}alert-color: #{$alert-color};
        --#{$prefix}alert-bg: #{$alert-color};
        --#{$prefix}alert-border-color: #{$alert-border};
    
        // @todo: remove .alert-link  and enable line below when 5.2 is removed.
        //--#{$prefix}alert-link-color: shade-color($alert-color, 20%);
    
        .alert-link {
          color: shade-color($alert-color, 20%);
        }
      }
    }
    
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany stefan.korn Jossgrund

    stefan.korn โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany stefan.korn Jossgrund

    I changed the MR to comply with #13 and take advise from #10:

    Why didn't you use recordation from compiler?
    To preserve current behavior: math.abs(40%)

    Reverted the change in dist/bootstrap/5.2.3/scss/_alert.scss, because bootstrap itself is using this: https://github.com/twbs/bootstrap/blob/v5.2.3/scss/_alert.scss#L65 (so probably this won't get changed anymore for BS 5.2)

    including patch from MR

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ravi kant Jaipur

    ravi kant โ†’ changed the visibility of the branch '3391813-passing-percentage-units' to hidden.

Production build 0.69.0 2024