autoprefixer 6.7.6 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/AUTHORS +1 -0
  2. package/CHANGELOG.md +23 -0
  3. package/README.md +10 -16
  4. package/data/prefixes.js +551 -517
  5. package/lib/at-rule.js +55 -38
  6. package/lib/autoprefixer.js +89 -63
  7. package/lib/brackets.js +59 -39
  8. package/lib/browsers.js +102 -65
  9. package/lib/declaration.js +212 -121
  10. package/lib/hacks/align-content.js +65 -38
  11. package/lib/hacks/align-items.js +62 -38
  12. package/lib/hacks/align-self.js +63 -36
  13. package/lib/hacks/appearance.js +42 -0
  14. package/lib/hacks/background-size.js +29 -20
  15. package/lib/hacks/block-logical.js +36 -21
  16. package/lib/hacks/border-image.js +26 -16
  17. package/lib/hacks/border-radius.js +60 -39
  18. package/lib/hacks/break-props.js +69 -44
  19. package/lib/hacks/cross-fade.js +40 -37
  20. package/lib/hacks/display-flex.js +81 -31
  21. package/lib/hacks/display-grid.js +29 -19
  22. package/lib/hacks/filter-value.js +66 -45
  23. package/lib/hacks/filter.js +26 -17
  24. package/lib/hacks/flex-basis.js +60 -30
  25. package/lib/hacks/flex-direction.js +85 -53
  26. package/lib/hacks/flex-flow.js +67 -49
  27. package/lib/hacks/flex-grow.js +45 -26
  28. package/lib/hacks/flex-shrink.js +60 -30
  29. package/lib/hacks/flex-spec.js +18 -8
  30. package/lib/hacks/flex-values.js +39 -20
  31. package/lib/hacks/flex-wrap.js +29 -20
  32. package/lib/hacks/flex.js +68 -43
  33. package/lib/hacks/fullscreen.js +31 -21
  34. package/lib/hacks/gradient.js +462 -302
  35. package/lib/hacks/grid-column-align.js +55 -0
  36. package/lib/hacks/grid-end.js +53 -28
  37. package/lib/hacks/grid-row-align.js +39 -19
  38. package/lib/hacks/grid-start.js +80 -48
  39. package/lib/hacks/grid-template.js +91 -55
  40. package/lib/hacks/image-rendering.js +63 -33
  41. package/lib/hacks/image-set.js +28 -20
  42. package/lib/hacks/inline-logical.js +32 -17
  43. package/lib/hacks/intrinsic.js +66 -0
  44. package/lib/hacks/justify-content.js +69 -42
  45. package/lib/hacks/mask-border.js +36 -21
  46. package/lib/hacks/order.js +58 -35
  47. package/lib/hacks/pixelated.js +44 -30
  48. package/lib/hacks/placeholder.js +40 -25
  49. package/lib/hacks/text-emphasis-position.js +27 -20
  50. package/lib/hacks/transform-decl.js +94 -52
  51. package/lib/hacks/writing-mode.js +37 -27
  52. package/lib/info.js +117 -78
  53. package/lib/old-selector.js +84 -58
  54. package/lib/old-value.js +22 -20
  55. package/lib/prefixer.js +164 -95
  56. package/lib/prefixes.js +446 -351
  57. package/lib/processor.js +394 -278
  58. package/lib/resolution.js +135 -75
  59. package/lib/selector.js +145 -84
  60. package/lib/supports.js +330 -210
  61. package/lib/transition.js +396 -243
  62. package/lib/utils.js +84 -48
  63. package/lib/value.js +118 -80
  64. package/package.json +54 -14
  65. package/lib/hacks/justify-items.js +0 -31
  66. package/lib/hacks/stretch.js +0 -45
package/lib/at-rule.js CHANGED
@@ -1,51 +1,68 @@
1
- (function() {
2
- var AtRule, Prefixer,
3
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
4
- hasProp = {}.hasOwnProperty;
1
+ 'use strict';
5
2
 
6
- Prefixer = require('./prefixer');
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
4
 
8
- AtRule = (function(superClass) {
9
- extend(AtRule, superClass);
5
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
6
+
7
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8
+
9
+ var Prefixer = require('./prefixer');
10
+
11
+ var AtRule = function (_Prefixer) {
12
+ _inherits(AtRule, _Prefixer);
10
13
 
11
14
  function AtRule() {
12
- return AtRule.__super__.constructor.apply(this, arguments);
15
+ _classCallCheck(this, AtRule);
16
+
17
+ return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
13
18
  }
14
19
 
15
- AtRule.prototype.add = function(rule, prefix) {
16
- var already, cloned, prefixed;
17
- prefixed = prefix + rule.name;
18
- already = rule.parent.some(function(i) {
19
- return i.name === prefixed && i.params === rule.params;
20
- });
21
- if (already) {
22
- return;
23
- }
24
- cloned = this.clone(rule, {
25
- name: prefixed
26
- });
27
- return rule.parent.insertBefore(rule, cloned);
28
- };
20
+ /**
21
+ * Clone and add prefixes for at-rule
22
+ */
23
+ AtRule.prototype.add = function add(rule, prefix) {
24
+ var prefixed = prefix + rule.name;
29
25
 
30
- AtRule.prototype.process = function(node) {
31
- var j, len, parent, prefix, ref, results;
32
- parent = this.parentPrefix(node);
33
- ref = this.prefixes;
34
- results = [];
35
- for (j = 0, len = ref.length; j < len; j++) {
36
- prefix = ref[j];
37
- if (parent && parent !== prefix) {
38
- continue;
26
+ var already = rule.parent.some(function (i) {
27
+ return i.name === prefixed && i.params === rule.params;
28
+ });
29
+ if (already) {
30
+ return undefined;
39
31
  }
40
- results.push(this.add(node, prefix));
41
- }
42
- return results;
32
+
33
+ var cloned = this.clone(rule, { name: prefixed });
34
+ return rule.parent.insertBefore(rule, cloned);
43
35
  };
44
36
 
45
- return AtRule;
37
+ /**
38
+ * Clone node with prefixes
39
+ */
40
+
46
41
 
47
- })(Prefixer);
42
+ AtRule.prototype.process = function process(node) {
43
+ var parent = this.parentPrefix(node);
48
44
 
49
- module.exports = AtRule;
45
+ for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
46
+ var _ref;
47
+
48
+ if (_isArray) {
49
+ if (_i >= _iterator.length) break;
50
+ _ref = _iterator[_i++];
51
+ } else {
52
+ _i = _iterator.next();
53
+ if (_i.done) break;
54
+ _ref = _i.value;
55
+ }
56
+
57
+ var prefix = _ref;
58
+
59
+ if (!parent || parent === prefix) {
60
+ this.add(node, prefix);
61
+ }
62
+ }
63
+ };
64
+
65
+ return AtRule;
66
+ }(Prefixer);
50
67
 
51
- }).call(this);
68
+ module.exports = AtRule;
@@ -1,92 +1,118 @@
1
- (function() {
2
- var Browsers, Prefixes, browserslist, cache, isPlainObject, postcss, timeCapsule,
3
- slice = [].slice;
1
+ 'use strict';
4
2
 
5
- browserslist = require('browserslist');
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
6
4
 
7
- postcss = require('postcss');
5
+ var browserslist = require('browserslist');
6
+ var postcss = require('postcss');
8
7
 
9
- Browsers = require('./browsers');
8
+ var Browsers = require('./browsers');
9
+ var Prefixes = require('./prefixes');
10
10
 
11
- Prefixes = require('./prefixes');
12
-
13
- isPlainObject = function(obj) {
11
+ function isPlainObject(obj) {
14
12
  return Object.prototype.toString.apply(obj) === '[object Object]';
15
- };
13
+ }
16
14
 
17
- cache = {};
15
+ var cache = {};
18
16
 
19
- timeCapsule = function(result, prefixes) {
17
+ function timeCapsule(result, prefixes) {
20
18
  if (prefixes.browsers.selected.length === 0) {
21
- return;
19
+ return;
22
20
  }
23
21
  if (prefixes.add.selectors.length > 0) {
24
- return;
22
+ return;
25
23
  }
26
24
  if (Object.keys(prefixes.add).length > 2) {
27
- return;
25
+ return;
28
26
  }
29
- return result.warn('Greetings, time traveller. ' + 'We are in the golden age of prefix-less CSS, ' + 'where Autoprefixer is no longer needed for your stylesheet.');
30
- };
31
27
 
32
- module.exports = postcss.plugin('autoprefixer', function() {
33
- var loadPrefixes, options, plugin, reqs;
34
- reqs = 1 <= arguments.length ? slice.call(arguments, 0) : [];
28
+ result.warn('Greetings, time traveller. ' + 'We are in the golden age of prefix-less CSS, ' + 'where Autoprefixer is no longer needed for your stylesheet.');
29
+ }
30
+
31
+ module.exports = postcss.plugin('autoprefixer', function () {
32
+ for (var _len = arguments.length, reqs = Array(_len), _key = 0; _key < _len; _key++) {
33
+ reqs[_key] = arguments[_key];
34
+ }
35
+
36
+ var options = void 0;
35
37
  if (reqs.length === 1 && isPlainObject(reqs[0])) {
36
- options = reqs[0];
37
- reqs = void 0;
38
- } else if (reqs.length === 0 || (reqs.length === 1 && (reqs[0] == null))) {
39
- reqs = void 0;
40
- } else if (reqs.length <= 2 && (reqs[0] instanceof Array || (reqs[0] == null))) {
41
- options = reqs[1];
42
- reqs = reqs[0];
43
- } else if (typeof reqs[reqs.length - 1] === 'object') {
44
- options = reqs.pop();
38
+ options = reqs[0];
39
+ reqs = undefined;
40
+ } else if (reqs.length === 0 || reqs.length === 1 && !reqs[0]) {
41
+ reqs = undefined;
42
+ } else if (reqs.length <= 2 && (reqs[0] instanceof Array || !reqs[0])) {
43
+ options = reqs[1];
44
+ reqs = reqs[0];
45
+ } else if (_typeof(reqs[reqs.length - 1]) === 'object') {
46
+ options = reqs.pop();
45
47
  }
46
- options || (options = {});
48
+
49
+ if (!options) {
50
+ options = {};
51
+ }
52
+
47
53
  if (options.browser) {
48
- throw new Error('Change `browser` option to `browsers` in Autoprefixer');
54
+ throw new Error('Change `browser` option to `browsers` in Autoprefixer');
55
+ }
56
+
57
+ if (options.browsers) {
58
+ reqs = options.browsers;
49
59
  }
50
- if (options.browsers != null) {
51
- reqs = options.browsers;
60
+
61
+ if (typeof options.grid === 'undefined') {
62
+ options.grid = false;
52
63
  }
53
- loadPrefixes = function(opts) {
54
- var browsers, key, stats;
55
- stats = options.stats;
56
- browsers = new Browsers(module.exports.data.browsers, reqs, opts, stats);
57
- key = browsers.selected.join(', ') + JSON.stringify(options);
58
- return cache[key] || (cache[key] = new Prefixes(module.exports.data.prefixes, browsers, options));
64
+
65
+ var loadPrefixes = function loadPrefixes(opts) {
66
+ var data = module.exports.data;
67
+ var browsers = new Browsers(data.browsers, reqs, opts, options.stats);
68
+ var key = browsers.selected.join(', ') + JSON.stringify(options);
69
+
70
+ if (!cache[key]) {
71
+ cache[key] = new Prefixes(data.prefixes, browsers, options);
72
+ }
73
+
74
+ return cache[key];
59
75
  };
60
- plugin = function(css, result) {
61
- var prefixes, ref;
62
- prefixes = loadPrefixes({
63
- from: (ref = css.source) != null ? ref.input.file : void 0,
64
- env: options.env
65
- });
66
- timeCapsule(result, prefixes);
67
- if (options.remove !== false) {
68
- prefixes.processor.remove(css);
69
- }
70
- if (options.add !== false) {
71
- return prefixes.processor.add(css, result);
72
- }
76
+
77
+ var plugin = function plugin(css, result) {
78
+ var prefixes = loadPrefixes({
79
+ from: css.source && css.source.input.file,
80
+ env: options.env
81
+ });
82
+ timeCapsule(result, prefixes);
83
+ if (options.remove !== false) {
84
+ prefixes.processor.remove(css);
85
+ }
86
+ if (options.add !== false) {
87
+ prefixes.processor.add(css, result);
88
+ }
73
89
  };
90
+
74
91
  plugin.options = options;
75
- plugin.info = function(opts) {
76
- return require('./info')(loadPrefixes(opts));
92
+
93
+ plugin.info = function (opts) {
94
+ return require('./info')(loadPrefixes(opts));
77
95
  };
96
+
78
97
  return plugin;
79
- });
98
+ });
80
99
 
81
- module.exports.data = {
82
- browsers: require('caniuse-db/data.json').agents,
100
+ /**
101
+ * Autoprefixer data
102
+ */
103
+ module.exports.data = {
104
+ browsers: require('caniuse-lite').agents,
83
105
  prefixes: require('../data/prefixes')
84
- };
106
+ };
85
107
 
86
- module.exports.defaults = browserslist.defaults;
108
+ /**
109
+ * Autoprefixer default browsers
110
+ */
111
+ module.exports.defaults = browserslist.defaults;
87
112
 
88
- module.exports.info = function() {
113
+ /**
114
+ * Inspect with default Autoprefixer
115
+ */
116
+ module.exports.info = function () {
89
117
  return module.exports().info();
90
- };
91
-
92
- }).call(this);
118
+ };
package/lib/brackets.js CHANGED
@@ -1,46 +1,66 @@
1
- (function() {
2
- var brackets, last;
1
+ 'use strict';
3
2
 
4
- last = function(array) {
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ var last = function last(array) {
5
6
  return array[array.length - 1];
6
- };
7
-
8
- brackets = {
9
- parse: function(str) {
10
- var current, j, len, stack, sym;
11
- current = [''];
12
- stack = [current];
13
- for (j = 0, len = str.length; j < len; j++) {
14
- sym = str[j];
15
- if (sym === '(') {
16
- current = [''];
17
- last(stack).push(current);
18
- stack.push(current);
19
- } else if (sym === ')') {
20
- stack.pop();
21
- current = last(stack);
22
- current.push('');
23
- } else {
24
- current[current.length - 1] += sym;
7
+ };
8
+
9
+ var brackets = {
10
+
11
+ /**
12
+ * Parse string to nodes tree
13
+ */
14
+ parse: function parse(str) {
15
+ var current = [''];
16
+ var stack = [current];
17
+
18
+ for (var i = 0; i < str.length; i++) {
19
+ var sym = str[i];
20
+ if (sym === '(') {
21
+ current = [''];
22
+ last(stack).push(current);
23
+ stack.push(current);
24
+ } else if (sym === ')') {
25
+ stack.pop();
26
+ current = last(stack);
27
+ current.push('');
28
+ } else {
29
+ current[current.length - 1] += sym;
30
+ }
25
31
  }
26
- }
27
- return stack[0];
32
+
33
+ return stack[0];
28
34
  },
29
- stringify: function(ast) {
30
- var i, j, len, result;
31
- result = '';
32
- for (j = 0, len = ast.length; j < len; j++) {
33
- i = ast[j];
34
- if (typeof i === 'object') {
35
- result += '(' + brackets.stringify(i) + ')';
36
- } else {
37
- result += i;
35
+
36
+
37
+ /**
38
+ * Generate output string by nodes tree
39
+ */
40
+ stringify: function stringify(ast) {
41
+ var result = '';
42
+ for (var _iterator = ast, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
43
+ var _ref;
44
+
45
+ if (_isArray) {
46
+ if (_i >= _iterator.length) break;
47
+ _ref = _iterator[_i++];
48
+ } else {
49
+ _i = _iterator.next();
50
+ if (_i.done) break;
51
+ _ref = _i.value;
52
+ }
53
+
54
+ var i = _ref;
55
+
56
+ if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object') {
57
+ result += '(' + brackets.stringify(i) + ')';
58
+ } else {
59
+ result += i;
60
+ }
38
61
  }
39
- }
40
- return result;
62
+ return result;
41
63
  }
42
- };
43
-
44
- module.exports = brackets;
64
+ };
45
65
 
46
- }).call(this);
66
+ module.exports = brackets;
package/lib/browsers.js CHANGED
@@ -1,86 +1,123 @@
1
- (function() {
2
- var Browsers, browserslist, utils;
1
+ 'use strict';
3
2
 
4
- browserslist = require('browserslist');
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
4
 
6
- utils = require('./utils');
5
+ var browserslist = require('browserslist');
7
6
 
8
- Browsers = (function() {
9
- Browsers.prefixes = function() {
10
- var data, i, name;
11
- if (this.prefixesCache) {
12
- return this.prefixesCache;
13
- }
14
- data = require('caniuse-db/data.json').agents;
15
- return this.prefixesCache = utils.uniq((function() {
16
- var results;
17
- results = [];
18
- for (name in data) {
19
- i = data[name];
20
- results.push("-" + i.prefix + "-");
7
+ var utils = require('./utils');
8
+
9
+ var Browsers = function () {
10
+
11
+ /**
12
+ * Return all prefixes for default browser data
13
+ */
14
+ Browsers.prefixes = function prefixes() {
15
+ if (this.prefixesCache) {
16
+ return this.prefixesCache;
17
+ }
18
+
19
+ var data = require('caniuse-lite').agents;
20
+
21
+ this.prefixesCache = [];
22
+ for (var name in data) {
23
+ this.prefixesCache.push('-' + data[name].prefix + '-');
21
24
  }
22
- return results;
23
- })()).sort(function(a, b) {
24
- return b.length - a.length;
25
- });
25
+
26
+ this.prefixesCache = utils.uniq(this.prefixesCache).sort(function (a, b) {
27
+ return b.length - a.length;
28
+ });
29
+
30
+ return this.prefixesCache;
26
31
  };
27
32
 
28
- Browsers.withPrefix = function(value) {
29
- if (!this.prefixesRegexp) {
30
- this.prefixesRegexp = RegExp("" + (this.prefixes().join('|')));
31
- }
32
- return this.prefixesRegexp.test(value);
33
+ /**
34
+ * Check is value contain any possibe prefix
35
+ */
36
+
37
+
38
+ Browsers.withPrefix = function withPrefix(value) {
39
+ if (!this.prefixesRegexp) {
40
+ this.prefixesRegexp = new RegExp(this.prefixes().join('|'));
41
+ }
42
+
43
+ return this.prefixesRegexp.test(value);
33
44
  };
34
45
 
35
- function Browsers(data1, requirements, options, stats) {
36
- this.data = data1;
37
- this.options = options;
38
- this.stats = stats;
39
- this.selected = this.parse(requirements);
46
+ function Browsers(data, requirements, options, stats) {
47
+ _classCallCheck(this, Browsers);
48
+
49
+ this.data = data;
50
+ this.options = options || {};
51
+ this.stats = stats;
52
+ this.selected = this.parse(requirements);
40
53
  }
41
54
 
42
- Browsers.prototype.parse = function(requirements) {
43
- var ref, ref1;
44
- return browserslist(requirements, {
45
- stats: this.stats,
46
- path: (ref = this.options) != null ? ref.from : void 0,
47
- env: (ref1 = this.options) != null ? ref1.env : void 0
48
- });
49
- };
55
+ /**
56
+ * Return browsers selected by requirements
57
+ */
50
58
 
51
- Browsers.prototype.browsers = function(criteria) {
52
- var browser, data, ref, selected, versions;
53
- selected = [];
54
- ref = this.data;
55
- for (browser in ref) {
56
- data = ref[browser];
57
- versions = criteria(data).map(function(version) {
58
- return browser + " " + version;
59
+
60
+ Browsers.prototype.parse = function parse(requirements) {
61
+ return browserslist(requirements, {
62
+ stats: this.stats,
63
+ path: this.options.from,
64
+ env: this.options.env
59
65
  });
60
- selected = selected.concat(versions);
61
- }
62
- return selected;
63
66
  };
64
67
 
65
- Browsers.prototype.prefix = function(browser) {
66
- var data, name, prefix, ref, version;
67
- ref = browser.split(' '), name = ref[0], version = ref[1];
68
- data = this.data[name];
69
- if (data.prefix_exceptions) {
70
- prefix = data.prefix_exceptions[version];
71
- }
72
- prefix || (prefix = data.prefix);
73
- return '-' + prefix + '-';
68
+ /**
69
+ * Select major browsers versions by criteria
70
+ */
71
+
72
+
73
+ Browsers.prototype.browsers = function browsers(criteria) {
74
+ var _this = this;
75
+
76
+ var selected = [];
77
+
78
+ var _loop = function _loop(browser) {
79
+ var data = _this.data[browser];
80
+ var versions = criteria(data).map(function (version) {
81
+ return browser + ' ' + version;
82
+ });
83
+ selected = selected.concat(versions);
84
+ };
85
+
86
+ for (var browser in this.data) {
87
+ _loop(browser);
88
+ }
89
+ return selected;
74
90
  };
75
91
 
76
- Browsers.prototype.isSelected = function(browser) {
77
- return this.selected.indexOf(browser) !== -1;
92
+ /**
93
+ * Return prefix for selected browser
94
+ */
95
+
96
+
97
+ Browsers.prototype.prefix = function prefix(browser) {
98
+ var _browser$split = browser.split(' '),
99
+ name = _browser$split[0],
100
+ version = _browser$split[1];
101
+
102
+ var data = this.data[name];
103
+
104
+ var prefix = data.prefix_exceptions && data.prefix_exceptions[version];
105
+ if (!prefix) {
106
+ prefix = data.prefix;
107
+ }
108
+ return '-' + prefix + '-';
78
109
  };
79
110
 
80
- return Browsers;
111
+ /**
112
+ * Is browser is selected by requirements
113
+ */
114
+
81
115
 
82
- })();
116
+ Browsers.prototype.isSelected = function isSelected(browser) {
117
+ return this.selected.indexOf(browser) !== -1;
118
+ };
83
119
 
84
- module.exports = Browsers;
120
+ return Browsers;
121
+ }();
85
122
 
86
- }).call(this);
123
+ module.exports = Browsers;