Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stylesheets/_SassyLists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Repository: https://github.com/at-import/functions/

@import 'helpers/missing-dependencies';
@import 'helpers/safe-get-function';
@import 'helpers/str-compare';
@import 'helpers/true';
@import 'helpers/is-number';
Expand Down
6 changes: 3 additions & 3 deletions stylesheets/functions/_every.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

@function sl-every($list, $function, $args...) {
@each $item in $list {
@if not call($function, $item, $args...) {
@if not call(sl-safe-get-function($function), $item, $args...) {
@return false;
}
}
}

@return true;
}
8 changes: 4 additions & 4 deletions stylesheets/functions/_some.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
///
/// @return {Bool}
///

@function sl-some($list, $function, $args...) {
@each $item in $list {
@if call($function, $item, $args...) {
@if call(sl-safe-get-function($function), $item, $args...) {
@return true;
}
}
}

@return false;
}
8 changes: 4 additions & 4 deletions stylesheets/functions/_walk.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
///
/// @return {List | Null}
///

@function sl-walk($list, $function, $args...) {
$_: sl-missing-dependencies('sl-to-map', 'sl-to-list');

@if not function-exists($function) {
@error 'There is no `#{$function}` function for `sl-walk`.';
}

@each $index, $value in sl-to-map($list) {
$arguments: join($value, $args);
$list: set-nth($list, $index, call($function, $arguments...));
$list: set-nth($list, $index, call(sl-safe-get-function($function), $arguments...));
}

@return sl-to-list($list);
}
28 changes: 28 additions & 0 deletions stylesheets/helpers/_safe-get-function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2016, Kaelig Deloumeau-Prigent
// All rights reserved.
// BSD 2-Clause License
// https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)

///
/// Polyfill for the `get-function` function
/// @link https://github.com/kaelig/sass-safe-get-function
/// @link http://sass-lang.com/documentation/Sass/Script/Functions.html#get_function-instance_method
///
/// @access private
///
/// @param {String} $name - Name of the function
///
/// @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.

@if (type-of($name) != 'string') {
@error 'The parameter passed to safe-get-function() must be a String. Good: safe-get-function(\'foo\') / Bad: safe-get-function(5).';
}

@if function-exists('get-function') {
@return get-function($name);
}

@return $name;

}