autoprefixer 6.7.7 → 7.1.1

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 +9 -15
  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 +73 -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 +53 -13
  65. package/lib/hacks/justify-items.js +0 -31
  66. package/lib/hacks/stretch.js +0 -45
package/lib/resolution.js CHANGED
@@ -1,98 +1,158 @@
1
- (function() {
2
- var Prefixer, Resolution, n2f, regexp, split, utils,
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
- utils = require('./utils');
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; }
9
6
 
10
- n2f = require('num2fraction');
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; }
11
8
 
12
- regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi;
9
+ var Prefixer = require('./prefixer');
10
+ var utils = require('./utils');
13
11
 
14
- split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i;
12
+ var n2f = require('num2fraction');
15
13
 
16
- Resolution = (function(superClass) {
17
- extend(Resolution, superClass);
14
+ var regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi;
15
+ var split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i;
16
+
17
+ var Resolution = function (_Prefixer) {
18
+ _inherits(Resolution, _Prefixer);
18
19
 
19
20
  function Resolution() {
20
- return Resolution.__super__.constructor.apply(this, arguments);
21
+ _classCallCheck(this, Resolution);
22
+
23
+ return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
21
24
  }
22
25
 
23
- Resolution.prototype.prefixName = function(prefix, name) {
24
- return name = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio';
26
+ /**
27
+ * Return prefixed query name
28
+ */
29
+ Resolution.prototype.prefixName = function prefixName(prefix, name) {
30
+ var newName = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio';
31
+ return newName;
25
32
  };
26
33
 
27
- Resolution.prototype.prefixQuery = function(prefix, name, colon, value, units) {
28
- if (units === 'dpi') {
29
- value = Number(value / 96);
30
- }
31
- if (prefix === '-o-') {
32
- value = n2f(value);
33
- }
34
- return this.prefixName(prefix, name) + colon + value;
35
- };
34
+ /**
35
+ * Return prefixed query
36
+ */
36
37
 
37
- Resolution.prototype.clean = function(rule) {
38
- var j, len, prefix, ref;
39
- if (!this.bad) {
40
- this.bad = [];
41
- ref = this.prefixes;
42
- for (j = 0, len = ref.length; j < len; j++) {
43
- prefix = ref[j];
44
- this.bad.push(this.prefixName(prefix, 'min'));
45
- this.bad.push(this.prefixName(prefix, 'max'));
38
+
39
+ Resolution.prototype.prefixQuery = function prefixQuery(prefix, name, colon, value, units) {
40
+ if (units === 'dpi') {
41
+ value = Number(value / 96);
46
42
  }
47
- }
48
- return rule.params = utils.editList(rule.params, (function(_this) {
49
- return function(queries) {
50
- return queries.filter(function(query) {
51
- return _this.bad.every(function(i) {
52
- return query.indexOf(i) === -1;
53
- });
54
- });
55
- };
56
- })(this));
43
+ if (prefix === '-o-') {
44
+ value = n2f(value);
45
+ }
46
+ return this.prefixName(prefix, name) + colon + value;
57
47
  };
58
48
 
59
- Resolution.prototype.process = function(rule) {
60
- var parent, prefixes;
61
- parent = this.parentPrefix(rule);
62
- prefixes = parent ? [parent] : this.prefixes;
63
- return rule.params = utils.editList(rule.params, (function(_this) {
64
- return function(origin, prefixed) {
65
- var j, k, len, len1, prefix, processed, query;
66
- for (j = 0, len = origin.length; j < len; j++) {
67
- query = origin[j];
68
- if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) {
69
- prefixed.push(query);
70
- continue;
49
+ /**
50
+ * Remove prefixed queries
51
+ */
52
+
53
+
54
+ Resolution.prototype.clean = function clean(rule) {
55
+ var _this2 = this;
56
+
57
+ if (!this.bad) {
58
+ this.bad = [];
59
+ for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
60
+ var _ref;
61
+
62
+ if (_isArray) {
63
+ if (_i >= _iterator.length) break;
64
+ _ref = _iterator[_i++];
65
+ } else {
66
+ _i = _iterator.next();
67
+ if (_i.done) break;
68
+ _ref = _i.value;
69
+ }
70
+
71
+ var prefix = _ref;
72
+
73
+ this.bad.push(this.prefixName(prefix, 'min'));
74
+ this.bad.push(this.prefixName(prefix, 'max'));
71
75
  }
72
- for (k = 0, len1 = prefixes.length; k < len1; k++) {
73
- prefix = prefixes[k];
74
- if (prefix === '-moz-' && rule.params.indexOf('dpi') !== -1) {
75
- continue;
76
- } else {
77
- processed = query.replace(regexp, function(str) {
78
- var parts;
79
- parts = str.match(split);
80
- return _this.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
76
+ }
77
+
78
+ rule.params = utils.editList(rule.params, function (queries) {
79
+ return queries.filter(function (query) {
80
+ return _this2.bad.every(function (i) {
81
+ return query.indexOf(i) === -1;
81
82
  });
82
- prefixed.push(processed);
83
- }
84
- }
85
- prefixed.push(query);
86
- }
87
- return utils.uniq(prefixed);
88
- };
89
- })(this));
83
+ });
84
+ });
90
85
  };
91
86
 
92
- return Resolution;
87
+ /**
88
+ * Add prefixed queries
89
+ */
93
90
 
94
- })(Prefixer);
95
91
 
96
- module.exports = Resolution;
92
+ Resolution.prototype.process = function process(rule) {
93
+ var _this3 = this;
94
+
95
+ var parent = this.parentPrefix(rule);
96
+ var prefixes = parent ? [parent] : this.prefixes;
97
+
98
+ rule.params = utils.editList(rule.params, function (origin, prefixed) {
99
+ for (var _iterator2 = origin, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
100
+ var _ref2;
101
+
102
+ if (_isArray2) {
103
+ if (_i2 >= _iterator2.length) break;
104
+ _ref2 = _iterator2[_i2++];
105
+ } else {
106
+ _i2 = _iterator2.next();
107
+ if (_i2.done) break;
108
+ _ref2 = _i2.value;
109
+ }
110
+
111
+ var query = _ref2;
112
+
113
+ if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) {
114
+ prefixed.push(query);
115
+ continue;
116
+ }
117
+
118
+ var _loop = function _loop(prefix) {
119
+ if (prefix === '-moz-' && rule.params.indexOf('dpi') !== -1) {
120
+ return 'continue';
121
+ } else {
122
+ var processed = query.replace(regexp, function (str) {
123
+ var parts = str.match(split);
124
+ return _this3.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
125
+ });
126
+ prefixed.push(processed);
127
+ }
128
+ };
129
+
130
+ for (var _iterator3 = prefixes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
131
+ var _ref3;
132
+
133
+ if (_isArray3) {
134
+ if (_i3 >= _iterator3.length) break;
135
+ _ref3 = _iterator3[_i3++];
136
+ } else {
137
+ _i3 = _iterator3.next();
138
+ if (_i3.done) break;
139
+ _ref3 = _i3.value;
140
+ }
141
+
142
+ var prefix = _ref3;
143
+
144
+ var _ret = _loop(prefix);
145
+
146
+ if (_ret === 'continue') continue;
147
+ }
148
+ prefixed.push(query);
149
+ }
150
+
151
+ return utils.uniq(prefixed);
152
+ });
153
+ };
154
+
155
+ return Resolution;
156
+ }(Prefixer);
97
157
 
98
- }).call(this);
158
+ module.exports = Resolution;
package/lib/selector.js CHANGED
@@ -1,117 +1,178 @@
1
- (function() {
2
- var Browsers, OldSelector, Prefixer, Selector, utils,
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
- OldSelector = require('./old-selector');
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
4
 
8
- Prefixer = require('./prefixer');
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; }
9
6
 
10
- Browsers = require('./browsers');
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; }
11
8
 
12
- utils = require('./utils');
9
+ var OldSelector = require('./old-selector');
10
+ var Prefixer = require('./prefixer');
11
+ var Browsers = require('./browsers');
12
+ var utils = require('./utils');
13
13
 
14
- Selector = (function(superClass) {
15
- extend(Selector, superClass);
14
+ var Selector = function (_Prefixer) {
15
+ _inherits(Selector, _Prefixer);
16
16
 
17
- function Selector(name1, prefixes, all) {
18
- this.name = name1;
19
- this.prefixes = prefixes;
20
- this.all = all;
21
- this.regexpCache = {};
17
+ function Selector(name, prefixes, all) {
18
+ _classCallCheck(this, Selector);
19
+
20
+ var _this = _possibleConstructorReturn(this, _Prefixer.call(this, name, prefixes, all));
21
+
22
+ _this.regexpCache = {};
23
+ return _this;
22
24
  }
23
25
 
24
- Selector.prototype.check = function(rule) {
25
- if (rule.selector.indexOf(this.name) !== -1) {
26
- return !!rule.selector.match(this.regexp());
27
- } else {
28
- return false;
29
- }
26
+ /**
27
+ * Is rule selectors need to be prefixed
28
+ */
29
+
30
+
31
+ Selector.prototype.check = function check(rule) {
32
+ if (rule.selector.indexOf(this.name) !== -1) {
33
+ return !!rule.selector.match(this.regexp());
34
+ } else {
35
+ return false;
36
+ }
30
37
  };
31
38
 
32
- Selector.prototype.prefixed = function(prefix) {
33
- return this.name.replace(/^([^\w]*)/, '$1' + prefix);
39
+ /**
40
+ * Return prefixed version of selector
41
+ */
42
+
43
+
44
+ Selector.prototype.prefixed = function prefixed(prefix) {
45
+ return this.name.replace(/^([^\w]*)/, '$1' + prefix);
34
46
  };
35
47
 
36
- Selector.prototype.regexp = function(prefix) {
37
- var name;
38
- if (this.regexpCache[prefix]) {
48
+ /**
49
+ * Lazy loadRegExp for name
50
+ */
51
+
52
+
53
+ Selector.prototype.regexp = function regexp(prefix) {
54
+ if (this.regexpCache[prefix]) {
55
+ return this.regexpCache[prefix];
56
+ }
57
+
58
+ var name = prefix ? this.prefixed(prefix) : this.name;
59
+ this.regexpCache[prefix] = new RegExp('(^|[^:"\'=])' + utils.escapeRegexp(name), 'gi');
39
60
  return this.regexpCache[prefix];
40
- }
41
- name = prefix ? this.prefixed(prefix) : this.name;
42
- return this.regexpCache[prefix] = RegExp("(^|[^:\"'=])" + (utils.escapeRegexp(name)), "gi");
43
61
  };
44
62
 
45
- Selector.prototype.possible = function() {
46
- return Browsers.prefixes();
47
- };
63
+ /**
64
+ * All possible prefixes
65
+ */
48
66
 
49
- Selector.prototype.prefixeds = function(rule) {
50
- var i, len, prefix, prefixeds, ref;
51
- if (rule._autoprefixerPrefixeds) {
52
- return rule._autoprefixerPrefixeds;
53
- }
54
- prefixeds = {};
55
- ref = this.possible();
56
- for (i = 0, len = ref.length; i < len; i++) {
57
- prefix = ref[i];
58
- prefixeds[prefix] = this.replace(rule.selector, prefix);
59
- }
60
- return rule._autoprefixerPrefixeds = prefixeds;
67
+
68
+ Selector.prototype.possible = function possible() {
69
+ return Browsers.prefixes();
61
70
  };
62
71
 
63
- Selector.prototype.already = function(rule, prefixeds, prefix) {
64
- var before, index, key, prefixed, some;
65
- index = rule.parent.index(rule) - 1;
66
- while (index >= 0) {
67
- before = rule.parent.nodes[index];
68
- if (before.type !== 'rule') {
69
- return false;
72
+ /**
73
+ * Return all possible selector prefixes
74
+ */
75
+
76
+
77
+ Selector.prototype.prefixeds = function prefixeds(rule) {
78
+ if (rule._autoprefixerPrefixeds) {
79
+ return rule._autoprefixerPrefixeds;
70
80
  }
71
- some = false;
72
- for (key in prefixeds) {
73
- prefixed = prefixeds[key];
74
- if (before.selector === prefixed) {
75
- if (prefix === key) {
76
- return true;
81
+
82
+ var prefixeds = {};
83
+ for (var _iterator = this.possible(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
84
+ var _ref;
85
+
86
+ if (_isArray) {
87
+ if (_i >= _iterator.length) break;
88
+ _ref = _iterator[_i++];
77
89
  } else {
78
- some = true;
79
- break;
90
+ _i = _iterator.next();
91
+ if (_i.done) break;
92
+ _ref = _i.value;
80
93
  }
81
- }
82
- }
83
- if (!some) {
84
- return false;
94
+
95
+ var prefix = _ref;
96
+
97
+ prefixeds[prefix] = this.replace(rule.selector, prefix);
85
98
  }
86
- index -= 1;
87
- }
88
- return false;
99
+
100
+ rule._autoprefixerPrefixeds = prefixeds;
101
+ return rule._autoprefixerPrefixeds;
89
102
  };
90
103
 
91
- Selector.prototype.replace = function(selector, prefix) {
92
- return selector.replace(this.regexp(), '$1' + this.prefixed(prefix));
104
+ /**
105
+ * Is rule already prefixed before
106
+ */
107
+
108
+
109
+ Selector.prototype.already = function already(rule, prefixeds, prefix) {
110
+ var index = rule.parent.index(rule) - 1;
111
+
112
+ while (index >= 0) {
113
+ var before = rule.parent.nodes[index];
114
+
115
+ if (before.type !== 'rule') {
116
+ return false;
117
+ }
118
+
119
+ var some = false;
120
+ for (var key in prefixeds) {
121
+ var prefixed = prefixeds[key];
122
+ if (before.selector === prefixed) {
123
+ if (prefix === key) {
124
+ return true;
125
+ } else {
126
+ some = true;
127
+ break;
128
+ }
129
+ }
130
+ }
131
+ if (!some) {
132
+ return false;
133
+ }
134
+
135
+ index -= 1;
136
+ }
137
+
138
+ return false;
93
139
  };
94
140
 
95
- Selector.prototype.add = function(rule, prefix) {
96
- var cloned, prefixeds;
97
- prefixeds = this.prefixeds(rule);
98
- if (this.already(rule, prefixeds, prefix)) {
99
- return;
100
- }
101
- cloned = this.clone(rule, {
102
- selector: prefixeds[prefix]
103
- });
104
- return rule.parent.insertBefore(rule, cloned);
141
+ /**
142
+ * Replace selectors by prefixed one
143
+ */
144
+
145
+
146
+ Selector.prototype.replace = function replace(selector, prefix) {
147
+ return selector.replace(this.regexp(), '$1' + this.prefixed(prefix));
105
148
  };
106
149
 
107
- Selector.prototype.old = function(prefix) {
108
- return new OldSelector(this, prefix);
150
+ /**
151
+ * Clone and add prefixes for at-rule
152
+ */
153
+
154
+
155
+ Selector.prototype.add = function add(rule, prefix) {
156
+ var prefixeds = this.prefixeds(rule);
157
+
158
+ if (this.already(rule, prefixeds, prefix)) {
159
+ return;
160
+ }
161
+
162
+ var cloned = this.clone(rule, { selector: prefixeds[prefix] });
163
+ rule.parent.insertBefore(rule, cloned);
109
164
  };
110
165
 
111
- return Selector;
166
+ /**
167
+ * Return function to fast find prefixed selector
168
+ */
112
169
 
113
- })(Prefixer);
114
170
 
115
- module.exports = Selector;
171
+ Selector.prototype.old = function old(prefix) {
172
+ return new OldSelector(this, prefix);
173
+ };
174
+
175
+ return Selector;
176
+ }(Prefixer);
116
177
 
117
- }).call(this);
178
+ module.exports = Selector;