Skip to content

Instantly share code, notes, and snippets.

@pascalduez
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalduez/6e02a19bb9bfa849d24f to your computer and use it in GitHub Desktop.
Save pascalduez/6e02a19bb9bfa849d24f to your computer and use it in GitHub Desktop.
Sass flexible prefixer mixin.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
// A Sass flexible prefixer mixin.
// Returns a list containing all the entries from `$list`
// that are not present in any of the other `$lists`.
// -----------------------------------------------------------------------------
// @param [list] $list
// @param [arglist] $lists
// -----------------------------------------------------------------------------
// @return [list]
@function diff(
$list,
$lists...
) {
$result: $list;
@each $list in $lists {
$temp: ();
@each $item in $result {
@if not index($list, $item) {
$temp: append($temp, $item, list-separator($list));
}
}
$result: $temp;
}
@return if(length($result) == 1, nth($result, 1), $result);
}
$prefixes: (
webkit,
khtml,
moz,
ms ,
o,
spec
) !default;
// Prefixer mixin.
// -----------------------------------------------------------------------------
// @param [map] $declaration
// @param [list] $include
// @param [list] $exclude
// -----------------------------------------------------------------------------
// @print [css]
@mixin prefixr(
$declarations,
$include: $prefixes,
$exclude: null
) {
@if $exclude {
$include: diff($include, $exclude);
}
@each $property, $value in $declarations {
@each $prefix in $include {
$prefix: if($prefix == spec, '', '-#{$prefix}-');
#{$prefix + $property}: $value;
}
}
}
Sass {
@include prefixr(
(font-feature-settings: "onum=1"), moz
);
/**/
@include prefixr(
(font-feature-settings: "onum" 1), $exclude: khtml o
);
}
Sass {
-moz-font-feature-settings: "onum=1";
/**/
-webkit-font-feature-settings: "onum" 1;
-moz-font-feature-settings: "onum" 1;
-ms-font-feature-settings: "onum" 1;
font-feature-settings: "onum" 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment