-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathautoprefixer.js
88 lines (76 loc) · 2.65 KB
/
autoprefixer.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(function() {
var Browsers, Prefixes, browserslist, cache, isPlainObject, postcss,
slice = [].slice;
browserslist = require('browserslist');
postcss = require('postcss');
Browsers = require('./browsers');
Prefixes = require('./prefixes');
isPlainObject = function(obj) {
return Object.prototype.toString.apply(obj) === '[object Object]';
};
cache = {};
module.exports = postcss.plugin('autoprefixer', function() {
var loadPrefixes, options, plugin, reqs;
reqs = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (reqs.length === 1 && isPlainObject(reqs[0])) {
options = reqs[0];
reqs = void 0;
} else if (reqs.length === 0 || (reqs.length === 1 && (reqs[0] == null))) {
reqs = void 0;
} else if (reqs.length <= 2 && (reqs[0] instanceof Array || (reqs[0] == null))) {
options = reqs[1];
reqs = reqs[0];
} else if (typeof reqs[reqs.length - 1] === 'object') {
options = reqs.pop();
}
options || (options = {});
if (options.browsers != null) {
reqs = options.browsers;
}
loadPrefixes = function(opts) {
var browsers, key;
browsers = new Browsers(module.exports.data.browsers, reqs, opts);
key = browsers.selected.join(', ') + options.cascade;
return cache[key] || (cache[key] = new Prefixes(module.exports.data.prefixes, browsers, options));
};
plugin = function(css, result) {
var prefixes;
prefixes = loadPrefixes({
from: css.source.input.file
});
if (options.remove !== false) {
prefixes.processor.remove(css);
}
if (options.add !== false) {
return prefixes.processor.add(css, result);
}
};
plugin.options = options;
plugin.process = function(str, options) {
if (options == null) {
options = {};
}
if (typeof console !== "undefined" && console !== null) {
if (typeof console.warn === "function") {
console.warn('Autoprefixer\'s process() method is deprecated ' + 'and will removed in next major release. ' + 'Use postcss([autoprefixer]).process() instead');
}
}
return postcss(plugin).process(str, options);
};
plugin.info = function(opts) {
return require('./info')(loadPrefixes(opts));
};
return plugin;
});
module.exports.data = {
browsers: require('caniuse-db/data').agents,
prefixes: require('../data/prefixes')
};
module.exports.defaults = browserslist.defaults;
module.exports.process = function(css, options) {
return module.exports().process(css, options);
};
module.exports.info = function() {
return module.exports().info();
};
}).call(this);