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
@@ -1,368 +1,528 @@
1
- (function() {
2
- var Gradient, OldValue, Value, isDirection, list, parser, range, 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,
5
- slice = [].slice;
1
+ 'use strict';
6
2
 
7
- OldValue = require('../old-value');
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
4
 
9
- Value = require('../value');
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; }
10
6
 
11
- utils = require('../utils');
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; }
12
8
 
13
- parser = require('postcss-value-parser');
9
+ var OldValue = require('../old-value');
10
+ var Value = require('../value');
11
+ var utils = require('../utils');
14
12
 
15
- range = require('normalize-range');
13
+ var parser = require('postcss-value-parser');
14
+ var range = require('normalize-range');
16
15
 
17
- list = require('postcss/lib/list');
16
+ var isDirection = /top|left|right|bottom/gi;
18
17
 
19
- isDirection = /top|left|right|bottom/gi;
20
-
21
- Gradient = (function(superClass) {
22
- extend(Gradient, superClass);
18
+ var Gradient = function (_Value) {
19
+ _inherits(Gradient, _Value);
23
20
 
24
21
  function Gradient() {
25
- return Gradient.__super__.constructor.apply(this, arguments);
22
+ var _temp, _this, _ret;
23
+
24
+ _classCallCheck(this, Gradient);
25
+
26
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
27
+ args[_key] = arguments[_key];
28
+ }
29
+
30
+ return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Value.call.apply(_Value, [this].concat(args))), _this), Object.defineProperty(_this, 'directions', {
31
+ enumerable: true,
32
+ writable: true,
33
+ value: {
34
+ top: 'bottom',
35
+ left: 'right',
36
+ bottom: 'top',
37
+ right: 'left'
38
+ }
39
+ }), Object.defineProperty(_this, 'oldDirections', {
40
+ enumerable: true,
41
+ writable: true,
42
+ value: {
43
+ 'top': 'left bottom, left top',
44
+ 'left': 'right top, left top',
45
+ 'bottom': 'left top, left bottom',
46
+ 'right': 'left top, right top',
47
+
48
+ 'top right': 'left bottom, right top',
49
+ 'top left': 'right bottom, left top',
50
+ 'right top': 'left bottom, right top',
51
+ 'right bottom': 'left top, right bottom',
52
+ 'bottom right': 'left top, right bottom',
53
+ 'bottom left': 'right top, left bottom',
54
+ 'left top': 'right bottom, left top',
55
+ 'left bottom': 'right top, left bottom'
56
+ }
57
+ }), _temp), _possibleConstructorReturn(_this, _ret);
26
58
  }
27
59
 
28
- Gradient.names = ['linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient'];
29
-
30
- Gradient.prototype.replace = function(string, prefix) {
31
- var ast, changes, j, len, node, ref;
32
- ast = parser(string);
33
- ref = ast.nodes;
34
- for (j = 0, len = ref.length; j < len; j++) {
35
- node = ref[j];
36
- if (node.type === 'function' && node.value === this.name) {
37
- node.nodes = this.newDirection(node.nodes);
38
- node.nodes = this.normalize(node.nodes);
39
- if (prefix === '-webkit- old') {
40
- changes = this.oldWebkit(node);
41
- if (!changes) {
42
- return;
60
+ // Direction to replace
61
+
62
+
63
+ // Direction to replace
64
+
65
+
66
+ /**
67
+ * Change degrees for webkit prefix
68
+ */
69
+ Gradient.prototype.replace = function replace(string, prefix) {
70
+ var ast = parser(string);
71
+ for (var _iterator = ast.nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
72
+ var _ref;
73
+
74
+ if (_isArray) {
75
+ if (_i >= _iterator.length) break;
76
+ _ref = _iterator[_i++];
77
+ } else {
78
+ _i = _iterator.next();
79
+ if (_i.done) break;
80
+ _ref = _i.value;
81
+ }
82
+
83
+ var node = _ref;
84
+
85
+ if (node.type === 'function' && node.value === this.name) {
86
+ node.nodes = this.newDirection(node.nodes);
87
+ node.nodes = this.normalize(node.nodes);
88
+ if (prefix === '-webkit- old') {
89
+ var changes = this.oldWebkit(node);
90
+ if (!changes) {
91
+ return undefined;
92
+ }
93
+ } else {
94
+ node.nodes = this.convertDirection(node.nodes);
95
+ node.value = prefix + node.value;
96
+ }
43
97
  }
44
- } else {
45
- node.nodes = this.convertDirection(node.nodes);
46
- node.value = prefix + node.value;
47
- }
48
98
  }
49
- }
50
- return ast.toString();
99
+ return ast.toString();
51
100
  };
52
101
 
53
- Gradient.prototype.directions = {
54
- top: 'bottom',
55
- left: 'right',
56
- bottom: 'top',
57
- right: 'left'
58
- };
102
+ /**
103
+ * Replace first token
104
+ */
59
105
 
60
- Gradient.prototype.oldDirections = {
61
- 'top': 'left bottom, left top',
62
- 'left': 'right top, left top',
63
- 'bottom': 'left top, left bottom',
64
- 'right': 'left top, right top',
65
- 'top right': 'left bottom, right top',
66
- 'top left': 'right bottom, left top',
67
- 'right top': 'left bottom, right top',
68
- 'right bottom': 'left top, right bottom',
69
- 'bottom right': 'left top, right bottom',
70
- 'bottom left': 'right top, left bottom',
71
- 'left top': 'right bottom, left top',
72
- 'left bottom': 'right top, left bottom'
73
- };
74
106
 
75
- Gradient.prototype.replaceFirst = function() {
76
- var params, prefix, words;
77
- params = arguments[0], words = 2 <= arguments.length ? slice.call(arguments, 1) : [];
78
- prefix = words.map(function(i) {
79
- if (i === ' ') {
80
- return {
81
- type: 'space',
82
- value: i
83
- };
84
- } else {
85
- return {
86
- type: 'word',
87
- value: i
88
- };
107
+ Gradient.prototype.replaceFirst = function replaceFirst(params) {
108
+ for (var _len2 = arguments.length, words = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
109
+ words[_key2 - 1] = arguments[_key2];
89
110
  }
90
- });
91
- return prefix.concat(params.slice(1));
92
- };
93
111
 
94
- Gradient.prototype.normalizeUnit = function(str, full) {
95
- var deg, num;
96
- num = parseFloat(str);
97
- deg = (num / full) * 360;
98
- return deg + "deg";
112
+ var prefix = words.map(function (i) {
113
+ if (i === ' ') {
114
+ return { type: 'space', value: i };
115
+ } else {
116
+ return { type: 'word', value: i };
117
+ }
118
+ });
119
+ return prefix.concat(params.slice(1));
99
120
  };
100
121
 
101
- Gradient.prototype.normalize = function(nodes) {
102
- var num;
103
- if (!nodes[0]) {
104
- return nodes;
105
- }
106
- if (/-?\d+(.\d+)?grad/.test(nodes[0].value)) {
107
- nodes[0].value = this.normalizeUnit(nodes[0].value, 400);
108
- } else if (/-?\d+(.\d+)?rad/.test(nodes[0].value)) {
109
- nodes[0].value = this.normalizeUnit(nodes[0].value, 2 * Math.PI);
110
- } else if (/-?\d+(.\d+)?turn/.test(nodes[0].value)) {
111
- nodes[0].value = this.normalizeUnit(nodes[0].value, 1);
112
- } else if (nodes[0].value.indexOf('deg') !== -1) {
113
- num = parseFloat(nodes[0].value);
114
- num = range.wrap(0, 360, num);
115
- nodes[0].value = num + "deg";
116
- }
117
- if (nodes[0].value === '0deg') {
118
- nodes = this.replaceFirst(nodes, 'to', ' ', 'top');
119
- } else if (nodes[0].value === '90deg') {
120
- nodes = this.replaceFirst(nodes, 'to', ' ', 'right');
121
- } else if (nodes[0].value === '180deg') {
122
- nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom');
123
- } else if (nodes[0].value === '270deg') {
124
- nodes = this.replaceFirst(nodes, 'to', ' ', 'left');
125
- }
126
- return nodes;
122
+ /**
123
+ * Convert angle unit to deg
124
+ */
125
+
126
+
127
+ Gradient.prototype.normalizeUnit = function normalizeUnit(str, full) {
128
+ var num = parseFloat(str);
129
+ var deg = num / full * 360;
130
+ return deg + 'deg';
127
131
  };
128
132
 
129
- Gradient.prototype.newDirection = function(params) {
130
- var i, j, ref;
131
- if (params[0].value === 'to') {
132
- return params;
133
- }
134
- if (!isDirection.test(params[0].value)) {
135
- return params;
136
- }
137
- params.unshift({
138
- type: 'word',
139
- value: 'to'
140
- }, {
141
- type: 'space',
142
- value: ' '
143
- });
144
- for (i = j = 2, ref = params.length; 2 <= ref ? j < ref : j > ref; i = 2 <= ref ? ++j : --j) {
145
- if (params[i].type === 'div') {
146
- break;
133
+ /**
134
+ * Normalize angle
135
+ */
136
+
137
+
138
+ Gradient.prototype.normalize = function normalize(nodes) {
139
+ if (!nodes[0]) {
140
+ return nodes;
141
+ }
142
+
143
+ if (/-?\d+(.\d+)?grad/.test(nodes[0].value)) {
144
+ nodes[0].value = this.normalizeUnit(nodes[0].value, 400);
145
+ } else if (/-?\d+(.\d+)?rad/.test(nodes[0].value)) {
146
+ nodes[0].value = this.normalizeUnit(nodes[0].value, 2 * Math.PI);
147
+ } else if (/-?\d+(.\d+)?turn/.test(nodes[0].value)) {
148
+ nodes[0].value = this.normalizeUnit(nodes[0].value, 1);
149
+ } else if (nodes[0].value.indexOf('deg') !== -1) {
150
+ var num = parseFloat(nodes[0].value);
151
+ num = range.wrap(0, 360, num);
152
+ nodes[0].value = num + 'deg';
147
153
  }
148
- if (params[i].type === 'word') {
149
- params[i].value = this.revertDirection(params[i].value);
154
+
155
+ if (nodes[0].value === '0deg') {
156
+ nodes = this.replaceFirst(nodes, 'to', ' ', 'top');
157
+ } else if (nodes[0].value === '90deg') {
158
+ nodes = this.replaceFirst(nodes, 'to', ' ', 'right');
159
+ } else if (nodes[0].value === '180deg') {
160
+ nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom');
161
+ } else if (nodes[0].value === '270deg') {
162
+ nodes = this.replaceFirst(nodes, 'to', ' ', 'left');
150
163
  }
151
- }
152
- return params;
164
+
165
+ return nodes;
153
166
  };
154
167
 
155
- Gradient.prototype.convertDirection = function(params) {
156
- if (params.length > 0) {
168
+ /**
169
+ * Replace old direction to new
170
+ */
171
+
172
+
173
+ Gradient.prototype.newDirection = function newDirection(params) {
157
174
  if (params[0].value === 'to') {
158
- this.fixDirection(params);
159
- } else if (params[0].value.indexOf('deg') !== -1) {
160
- this.fixAngle(params);
161
- } else if (params[2].value === 'at') {
162
- this.fixRadial(params);
175
+ return params;
176
+ }
177
+ if (!isDirection.test(params[0].value)) {
178
+ return params;
163
179
  }
164
- }
165
- return params;
180
+
181
+ params.unshift({
182
+ type: 'word',
183
+ value: 'to'
184
+ }, {
185
+ type: 'space',
186
+ value: ' '
187
+ });
188
+
189
+ for (var i = 2; i < params.length; i++) {
190
+ if (params[i].type === 'div') {
191
+ break;
192
+ }
193
+ if (params[i].type === 'word') {
194
+ params[i].value = this.revertDirection(params[i].value);
195
+ }
196
+ }
197
+
198
+ return params;
166
199
  };
167
200
 
168
- Gradient.prototype.fixDirection = function(params) {
169
- var i, j, ref, results;
170
- params.splice(0, 2);
171
- results = [];
172
- for (i = j = 0, ref = params.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
173
- if (params[i].type === 'div') {
174
- break;
201
+ /**
202
+ * Change new direction to old
203
+ */
204
+
205
+
206
+ Gradient.prototype.convertDirection = function convertDirection(params) {
207
+ if (params.length > 0) {
208
+ if (params[0].value === 'to') {
209
+ this.fixDirection(params);
210
+ } else if (params[0].value.indexOf('deg') !== -1) {
211
+ this.fixAngle(params);
212
+ } else if (params[2].value === 'at') {
213
+ this.fixRadial(params);
214
+ }
175
215
  }
176
- if (params[i].type === 'word') {
177
- results.push(params[i].value = this.revertDirection(params[i].value));
178
- } else {
179
- results.push(void 0);
216
+ return params;
217
+ };
218
+
219
+ /**
220
+ * Replace `to top left` to `bottom right`
221
+ */
222
+
223
+
224
+ Gradient.prototype.fixDirection = function fixDirection(params) {
225
+ params.splice(0, 2);
226
+
227
+ for (var _iterator2 = params, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
228
+ var _ref2;
229
+
230
+ if (_isArray2) {
231
+ if (_i2 >= _iterator2.length) break;
232
+ _ref2 = _iterator2[_i2++];
233
+ } else {
234
+ _i2 = _iterator2.next();
235
+ if (_i2.done) break;
236
+ _ref2 = _i2.value;
237
+ }
238
+
239
+ var param = _ref2;
240
+
241
+ if (param.type === 'div') {
242
+ break;
243
+ }
244
+ if (param.type === 'word') {
245
+ param.value = this.revertDirection(param.value);
246
+ }
180
247
  }
181
- }
182
- return results;
183
248
  };
184
249
 
185
- Gradient.prototype.fixAngle = function(params) {
186
- var first;
187
- first = params[0].value;
188
- first = parseFloat(first);
189
- first = Math.abs(450 - first) % 360;
190
- first = this.roundFloat(first, 3);
191
- return params[0].value = first + "deg";
250
+ /**
251
+ * Add 90 degrees
252
+ */
253
+
254
+
255
+ Gradient.prototype.fixAngle = function fixAngle(params) {
256
+ var first = params[0].value;
257
+ first = parseFloat(first);
258
+ first = Math.abs(450 - first) % 360;
259
+ first = this.roundFloat(first, 3);
260
+ params[0].value = first + 'deg';
192
261
  };
193
262
 
194
- Gradient.prototype.fixRadial = function(params) {
195
- var first, i, j, ref, second;
196
- first = params[0];
197
- second = [];
198
- for (i = j = 4, ref = params.length; 4 <= ref ? j < ref : j > ref; i = 4 <= ref ? ++j : --j) {
199
- if (params[i].type === 'div') {
200
- break;
201
- } else {
202
- second.push(params[i]);
263
+ /**
264
+ * Fix radial direction syntax
265
+ */
266
+
267
+
268
+ Gradient.prototype.fixRadial = function fixRadial(params) {
269
+ var first = params[0];
270
+ var second = [];
271
+ var i = void 0;
272
+
273
+ for (i = 4; i < params.length; i++) {
274
+ if (params[i].type === 'div') {
275
+ break;
276
+ } else {
277
+ second.push(params[i]);
278
+ }
203
279
  }
204
- }
205
- return params.splice.apply(params, [0, i].concat(slice.call(second), [params[i + 2]], [first]));
280
+
281
+ params.splice.apply(params, [0, i].concat(second, [params[i + 2], first]));
206
282
  };
207
283
 
208
- Gradient.prototype.revertDirection = function(word) {
209
- return this.directions[word.toLowerCase()] || word;
284
+ Gradient.prototype.revertDirection = function revertDirection(word) {
285
+ return this.directions[word.toLowerCase()] || word;
210
286
  };
211
287
 
212
- Gradient.prototype.roundFloat = function(float, digits) {
213
- return parseFloat(float.toFixed(digits));
288
+ /**
289
+ * Round float and save digits under dot
290
+ */
291
+
292
+
293
+ Gradient.prototype.roundFloat = function roundFloat(float, digits) {
294
+ return parseFloat(float.toFixed(digits));
214
295
  };
215
296
 
216
- Gradient.prototype.oldWebkit = function(node) {
217
- var i, j, k, len, len1, nodes, param, params, string;
218
- nodes = node.nodes;
219
- string = parser.stringify(node.nodes);
220
- if (this.name !== 'linear-gradient') {
221
- return false;
222
- }
223
- if (nodes[0] && nodes[0].value.indexOf('deg') !== -1) {
224
- return false;
225
- }
226
- if (string.indexOf('px') !== -1) {
227
- return false;
228
- }
229
- if (string.indexOf('-corner') !== -1) {
230
- return false;
231
- }
232
- if (string.indexOf('-side') !== -1) {
233
- return false;
234
- }
235
- params = [[]];
236
- for (j = 0, len = nodes.length; j < len; j++) {
237
- i = nodes[j];
238
- params[params.length - 1].push(i);
239
- if (i.type === 'div' && i.value === ',') {
240
- params.push([]);
297
+ /**
298
+ * Convert to old webkit syntax
299
+ */
300
+
301
+
302
+ Gradient.prototype.oldWebkit = function oldWebkit(node) {
303
+ var nodes = node.nodes;
304
+
305
+ var string = parser.stringify(node.nodes);
306
+
307
+ if (this.name !== 'linear-gradient') {
308
+ return false;
309
+ }
310
+ if (nodes[0] && nodes[0].value.indexOf('deg') !== -1) {
311
+ return false;
312
+ }
313
+ if (string.indexOf('px') !== -1) {
314
+ return false;
315
+ }
316
+ if (string.indexOf('-corner') !== -1) {
317
+ return false;
318
+ }
319
+ if (string.indexOf('-side') !== -1) {
320
+ return false;
241
321
  }
242
- }
243
- this.oldDirection(params);
244
- this.colorStops(params);
245
- node.nodes = [];
246
- for (k = 0, len1 = params.length; k < len1; k++) {
247
- param = params[k];
248
- node.nodes = node.nodes.concat(param);
249
- }
250
- node.nodes.unshift({
251
- type: 'word',
252
- value: 'linear'
253
- }, this.cloneDiv(node.nodes));
254
- node.value = '-webkit-gradient';
255
- return true;
256
- };
257
322
 
258
- Gradient.prototype.oldDirection = function(params) {
259
- var div, j, len, node, old, ref, words;
260
- div = this.cloneDiv(params[0]);
261
- if (params[0][0].value !== 'to') {
262
- return params.unshift([
263
- {
264
- type: 'word',
265
- value: this.oldDirections.bottom
266
- }, div
267
- ]);
268
- } else {
269
- words = [];
270
- ref = params[0].slice(2);
271
- for (j = 0, len = ref.length; j < len; j++) {
272
- node = ref[j];
273
- if (node.type === 'word') {
274
- words.push(node.value.toLowerCase());
275
- }
323
+ var params = [[]];
324
+ for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
325
+ var _ref3;
326
+
327
+ if (_isArray3) {
328
+ if (_i3 >= _iterator3.length) break;
329
+ _ref3 = _iterator3[_i3++];
330
+ } else {
331
+ _i3 = _iterator3.next();
332
+ if (_i3.done) break;
333
+ _ref3 = _i3.value;
334
+ }
335
+
336
+ var i = _ref3;
337
+
338
+ params[params.length - 1].push(i);
339
+ if (i.type === 'div' && i.value === ',') {
340
+ params.push([]);
341
+ }
276
342
  }
277
- words = words.join(' ');
278
- old = this.oldDirections[words] || words;
279
- return params[0] = [
280
- {
281
- type: 'word',
282
- value: old
283
- }, div
284
- ];
285
- }
343
+
344
+ this.oldDirection(params);
345
+ this.colorStops(params);
346
+
347
+ node.nodes = [];
348
+ for (var _iterator4 = params, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
349
+ var _ref4;
350
+
351
+ if (_isArray4) {
352
+ if (_i4 >= _iterator4.length) break;
353
+ _ref4 = _iterator4[_i4++];
354
+ } else {
355
+ _i4 = _iterator4.next();
356
+ if (_i4.done) break;
357
+ _ref4 = _i4.value;
358
+ }
359
+
360
+ var param = _ref4;
361
+
362
+ node.nodes = node.nodes.concat(param);
363
+ }
364
+
365
+ node.nodes.unshift({ type: 'word', value: 'linear' }, this.cloneDiv(node.nodes));
366
+ node.value = '-webkit-gradient';
367
+
368
+ return true;
286
369
  };
287
370
 
288
- Gradient.prototype.cloneDiv = function(params) {
289
- var i, j, len;
290
- for (j = 0, len = params.length; j < len; j++) {
291
- i = params[j];
292
- if (i.type === 'div' && i.value === ',') {
293
- return i;
371
+ /**
372
+ * Change direction syntax to old webkit
373
+ */
374
+
375
+
376
+ Gradient.prototype.oldDirection = function oldDirection(params) {
377
+ var div = this.cloneDiv(params[0]);
378
+
379
+ if (params[0][0].value !== 'to') {
380
+ return params.unshift([{ type: 'word', value: this.oldDirections.bottom }, div]);
381
+ } else {
382
+ var _words = [];
383
+ for (var _iterator5 = params[0].slice(2), _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
384
+ var _ref5;
385
+
386
+ if (_isArray5) {
387
+ if (_i5 >= _iterator5.length) break;
388
+ _ref5 = _iterator5[_i5++];
389
+ } else {
390
+ _i5 = _iterator5.next();
391
+ if (_i5.done) break;
392
+ _ref5 = _i5.value;
393
+ }
394
+
395
+ var node = _ref5;
396
+
397
+ if (node.type === 'word') {
398
+ _words.push(node.value.toLowerCase());
399
+ }
400
+ }
401
+
402
+ _words = _words.join(' ');
403
+ var old = this.oldDirections[_words] || _words;
404
+
405
+ params[0] = [{ type: 'word', value: old }, div];
406
+ return params[0];
294
407
  }
295
- }
296
- return {
297
- type: 'div',
298
- value: ',',
299
- after: ' '
300
- };
301
408
  };
302
409
 
303
- Gradient.prototype.colorStops = function(params) {
304
- var color, div, i, j, len, param, pos, results, stop;
305
- results = [];
306
- for (i = j = 0, len = params.length; j < len; i = ++j) {
307
- param = params[i];
308
- if (i === 0) {
309
- continue;
410
+ /**
411
+ * Get div token from exists parameters
412
+ */
413
+
414
+
415
+ Gradient.prototype.cloneDiv = function cloneDiv(params) {
416
+ for (var _iterator6 = params, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
417
+ var _ref6;
418
+
419
+ if (_isArray6) {
420
+ if (_i6 >= _iterator6.length) break;
421
+ _ref6 = _iterator6[_i6++];
422
+ } else {
423
+ _i6 = _iterator6.next();
424
+ if (_i6.done) break;
425
+ _ref6 = _i6.value;
426
+ }
427
+
428
+ var i = _ref6;
429
+
430
+ if (i.type === 'div' && i.value === ',') {
431
+ return i;
432
+ }
310
433
  }
311
- color = parser.stringify(param[0]);
312
- if (param[1] && param[1].type === 'word') {
313
- pos = param[1].value;
314
- } else if (param[2] && param[2].type === 'word') {
315
- pos = param[2].value;
434
+ return { type: 'div', value: ',', after: ' ' };
435
+ };
436
+
437
+ /**
438
+ * Change colors syntax to old webkit
439
+ */
440
+
441
+
442
+ Gradient.prototype.colorStops = function colorStops(params) {
443
+ var result = [];
444
+ for (var i = 0; i < params.length; i++) {
445
+ var pos = void 0;
446
+ var param = params[i];
447
+ var item = void 0;
448
+ if (i === 0) {
449
+ continue;
450
+ }
451
+
452
+ var color = parser.stringify(param[0]);
453
+ if (param[1] && param[1].type === 'word') {
454
+ pos = param[1].value;
455
+ } else if (param[2] && param[2].type === 'word') {
456
+ pos = param[2].value;
457
+ }
458
+
459
+ var stop = void 0;
460
+ if (i === 1 && (!pos || pos === '0%')) {
461
+ stop = 'from(' + color + ')';
462
+ } else if (i === params.length - 1 && (!pos || pos === '100%')) {
463
+ stop = 'to(' + color + ')';
464
+ } else if (pos) {
465
+ stop = 'color-stop(' + pos + ', ' + color + ')';
466
+ } else {
467
+ stop = 'color-stop(' + color + ')';
468
+ }
469
+
470
+ var div = param[param.length - 1];
471
+ params[i] = [{ type: 'word', value: stop }];
472
+ if (div.type === 'div' && div.value === ',') {
473
+ item = params[i].push(div);
474
+ }
475
+ result.push(item);
316
476
  }
317
- stop = i === 1 && (!pos || pos === '0%') ? "from(" + color + ")" : i === params.length - 1 && (!pos || pos === '100%') ? "to(" + color + ")" : pos ? "color-stop(" + pos + ", " + color + ")" : "color-stop(" + color + ")";
318
- div = param[param.length - 1];
319
- params[i] = [
320
- {
321
- type: 'word',
322
- value: stop
323
- }
324
- ];
325
- if (div.type === 'div' && div.value === ',') {
326
- results.push(params[i].push(div));
477
+ return result;
478
+ };
479
+
480
+ /**
481
+ * Remove old WebKit gradient too
482
+ */
483
+
484
+
485
+ Gradient.prototype.old = function old(prefix) {
486
+ if (prefix === '-webkit-') {
487
+ var type = this.name === 'linear-gradient' ? 'linear' : 'radial';
488
+ var string = '-gradient';
489
+ var regexp = utils.regexp('-webkit-(' + type + '-gradient|gradient\\(\\s*' + type + ')', false);
490
+
491
+ return new OldValue(this.name, prefix + this.name, string, regexp);
327
492
  } else {
328
- results.push(void 0);
493
+ return _Value.prototype.old.call(this, prefix);
329
494
  }
330
- }
331
- return results;
332
495
  };
333
496
 
334
- Gradient.prototype.old = function(prefix) {
335
- var regexp, string, type;
336
- if (prefix === '-webkit-') {
337
- type = this.name === 'linear-gradient' ? 'linear' : 'radial';
338
- string = '-gradient';
339
- regexp = utils.regexp("-webkit-(" + type + "-gradient|gradient\\(\\s*" + type + ")", false);
340
- return new OldValue(this.name, prefix + this.name, string, regexp);
341
- } else {
342
- return Gradient.__super__.old.apply(this, arguments);
343
- }
344
- };
497
+ /**
498
+ * Do not add non-webkit prefixes for list-style and object
499
+ */
345
500
 
346
- Gradient.prototype.add = function(decl, prefix) {
347
- var p;
348
- p = decl.prop;
349
- if (p.indexOf('mask') !== -1) {
350
- if (prefix === '-webkit-' || prefix === '-webkit- old') {
351
- return Gradient.__super__.add.apply(this, arguments);
352
- }
353
- } else if (p === 'list-style' || p === 'list-style-image' || p === 'content') {
354
- if (prefix === '-webkit-' || prefix === '-webkit- old') {
355
- return Gradient.__super__.add.apply(this, arguments);
501
+
502
+ Gradient.prototype.add = function add(decl, prefix) {
503
+ var p = decl.prop;
504
+ if (p.indexOf('mask') !== -1) {
505
+ if (prefix === '-webkit-' || prefix === '-webkit- old') {
506
+ return _Value.prototype.add.call(this, decl, prefix);
507
+ }
508
+ } else if (p === 'list-style' || p === 'list-style-image' || p === 'content') {
509
+ if (prefix === '-webkit-' || prefix === '-webkit- old') {
510
+ return _Value.prototype.add.call(this, decl, prefix);
511
+ }
512
+ } else {
513
+ return _Value.prototype.add.call(this, decl, prefix);
356
514
  }
357
- } else {
358
- return Gradient.__super__.add.apply(this, arguments);
359
- }
515
+ return undefined;
360
516
  };
361
517
 
362
518
  return Gradient;
519
+ }(Value);
363
520
 
364
- })(Value);
521
+ Object.defineProperty(Gradient, 'names', {
522
+ enumerable: true,
523
+ writable: true,
524
+ value: ['linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient']
525
+ });
365
526
 
366
- module.exports = Gradient;
367
527
 
368
- }).call(this);
528
+ module.exports = Gradient;