Created
June 11, 2015 22:16
-
-
Save aarontam/3b58fd4df0acdd906849 to your computer and use it in GitHub Desktop.
For less.js, explodes a set of selectors for a given rule.
This file contains hidden or 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
/* | |
This assumes that the mixin is being included inside a selector. | |
Particularly useful for a set of selectors that have vendor-specific | |
prefixes, which cannot be mixed in a selector group. | |
Example usage: | |
@selectors: bar, baz, ~'::-webkit-input-placeholder', ~'::-moz-placeholder';; | |
.foo { | |
.explode-rule({ | |
width: 100%; | |
}, @selectors); | |
} | |
Output: | |
.foo.bar { | |
width: 100%; | |
} | |
.foo.baz { | |
width: 100%; | |
} | |
.foo::-webkit-input-placeholder { | |
width: 100%; | |
} | |
.foo::-moz-placeholder { | |
width: 100%; | |
} | |
*/ | |
.explode-rule(@rule, @selectorArray) { | |
.-(@i: length(@selectorArray)) when (@i > 0) { | |
@selector: extract(@selectorArray, @i); | |
&@{selector} { @rule(); } | |
.-((@i - 1)); | |
} .-; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment