Last active
August 29, 2015 14:01
-
-
Save pascalduez/6e02a19bb9bfa849d24f to your computer and use it in GitHub Desktop.
Sass flexible prefixer mixin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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 | |
); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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