Skip to content

fix: fix libsass 4 call deprecation warning #63#65

Open
ncoden wants to merge 4 commits intoat-import:masterfrom
ncoden:fix/sass-4-call-deprecation-warning
Open

fix: fix libsass 4 call deprecation warning #63#65
ncoden wants to merge 4 commits intoat-import:masterfrom
ncoden:fix/sass-4-call-deprecation-warning

Conversation

@ncoden
Copy link
Contributor

@ncoden ncoden commented May 31, 2018

Fix the following deprecation warning:

DEPRECATION WARNING: Passing a string to call() is deprecated and will be illegal
in Sass 4.0. Use call(get-function("fade")) instead.

Call call() with a function retrieved by the new function get-function.

Changes:

  • add sl-safe-call-function polyfill for call() with support of both function (LibSass >= 3.5) and function name string (LibSass < 3.5)
  • add a warning message about the deprecated usage of function name string in LibSass >= 3.5
  • use sl-safe-call-function instead of call()

Closes #63

@ncoden
Copy link
Contributor Author

ncoden commented May 31, 2018

@hugogiraudel

@ncoden ncoden changed the title fix: Fix libsass 4 call deprecation warning #63 fix: fix libsass 4 call deprecation warning #63 Jun 1, 2018
///
/// @return {Function|String}
///
@function safe-get-function($name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall this be prefixed with sl-?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should, yes.

@xzyfer
Copy link

xzyfer commented Jun 1, 2018

There's an alternative approach that would maintain BC with older Sass. You could instead have a safe-call-function. See a very simplified example below.

@function safe-call-function($name, ...$args) {
  @if function-exists('get-function') && type-of($name) == string {
    @return call(get-function($name),  ...$args);
  }
  @return call($name, ...$args);
}

This approach will work on all version Sass so theres no need for the @error.

@KittyGiraudel
Copy link
Contributor

That’s a good idea (expect for && that should be and in Sass ;)), let’s do this. :)

ncoden added 2 commits June 1, 2018 23:57
Use `sl-safe-call-function` instead and add a warning message to encourage users to switch to first-class functions.

        sl-safe-call-function($func, ...$args)
        Polyfill for the `call` function supporting both functions and strings.
@ncoden
Copy link
Contributor Author

ncoden commented Jun 1, 2018

@hugogiraudel @xzyfer I applied the required changes. See PR description

@ncoden
Copy link
Contributor Author

ncoden commented Jun 3, 2018

hmmm actually I found a more suitable way to make these checks. See foundation/motion-ui#117. I think I'll make a package from it.

@ncoden
Copy link
Contributor Author

ncoden commented Jun 6, 2018

Done. See https://github.com/ncoden/sassy-functions. @hugogiraudel @xzyfer I'll use it for this pull request, after I added some tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants