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 compact function #67

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
21 changes: 16 additions & 5 deletions lib/compass/functions/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,24 @@
}

@if not(function-exists(compact)) {
@function compact($vars...) {
@function compact($args...) {
Copy link
Author

Choose a reason for hiding this comment

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

$first: nth($args, 1);
$sep: comma;
$list: ();
@each $var in $vars {
@if $var {
$list: append($list, $var, comma);
}

@if length($args) == 1 and type_of($first) == 'list' {
$args: $first;
$sep: list-separator($args);
}

@for $index from 1 through length($args) {
Copy link
Author

Choose a reason for hiding this comment

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

@each $arg in $args won't work here when the first argument is list. It only returns first value in the first argument (list).
eg:
((opacity .2s ease), false, false, false)

The $arg will be opacity if we use @each, and this caused all the problems people mentioned in this issue: #34

Tested with single transition and multiple transitions, all work fine.

// single transition
@include transition(opacity .2s ease);

// multiple transitions
@include transition(transform .2s ease-out, top .3s ease-out);

$arg: nth($args, $index);

@if $arg {
$list: append($list, $arg, $sep);
}
}

@return $list;
}
}