forked from nju33/postcss-preref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 892 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Generated by CoffeeScript 1.10.0
(function() {
var fs, path, postcss, preref;
fs = require('fs');
path = require('path');
postcss = require('postcss');
preref = postcss.plugin('postcss-preref', function(opts) {
if (opts == null) {
opts = {
token: '-'
};
}
return function(css) {
var ref;
ref = null;
return css.walkRules(function(rule) {
var i, len, ref1, result, selector;
if (/^&/.test(rule.selector)) {
result = [];
ref1 = ref.split(/,/);
for (i = 0, len = ref1.length; i < len; i++) {
selector = ref1[i];
result.push(rule.selector.replace(/&/, selector));
}
return rule.selector = result.join(",");
} else {
return ref = rule.selector;
}
});
};
});
module.exports = preref;
}).call(this);