autoprefixer 8.2.0 → 8.5.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.
package/AUTHORS CHANGED
@@ -46,6 +46,7 @@ Darius
46
46
  David Narbutovich <vamnemne@gmail.com>
47
47
  David Pike <david@evolution7.com.au>
48
48
  Denis Sokolov <denis@sokolov.cc>
49
+ Diablohu <https://github.com/Diablohu>
49
50
  Dominik Porada <dominik@porada.co>
50
51
  Dominik Schilling <dominikschilling+git@gmail.com>
51
52
  dotch <ch.weiss@hotmail.de>
@@ -61,10 +62,13 @@ Forrest York <https://github.com/badisa>
61
62
  Google Inc.
62
63
  Gregory Eremin <magnolia_fan@me.com>
63
64
  GU Yiling <justice360@gmail.com>
65
+ Gustavo Real <https://github.com/kotfire>
64
66
  Hallvord R. M. Steen <hallvord@hallvord.com>
65
67
  heady <https://github.com/heady>
68
+ Huáng Jùnliàng <https://github.com/JLHwung>
66
69
  Iain Beeston <iain.beeston@gmail.com>
67
70
  Igor Adamenko <https://github.com/igoradamenko>
71
+ Filipe W. Lima <fwl.ufpe@gmail.com>
68
72
  Jack Moore <hello@jacklmoore.com>
69
73
  Jason Kuhrt <jasonkuhrt@me.com>
70
74
  Jeff Escalante <hello@jenius.me>
@@ -98,15 +102,19 @@ Morton Fox <github@qslw.com>
98
102
  mvasilkov <mvasilkov@gmail.com>
99
103
  Nick Howes <nick@nickhowes.co.uk>
100
104
  Nick Marchenko <n30n1ck@gmail.com>
105
+ Nic Nilov <https://github.com/nicnilov>
101
106
  Nick Schonning <nschonni@gmail.com>
102
107
  nickspielgist <dev@nickspiel.me>
103
108
  Niels Dequeker <niels.dequeker@gmail.com>
104
109
  Nikolay Burlov <kohgpat@gmail.com>
110
+ Oleh Aloshkin <olegaleshkin@gmail.com>
105
111
  Oleksandr Sergiienko <sigerello@gmail.com>
106
112
  Pavel Pustovalov <pustovalov.pavel@gmail.com>
113
+ Pavel Vostrikov <mail@vostrik.com>
107
114
  Paul Statezny <Paulstatezny@gmail.com>
108
115
  Peter van Westen <info@regularlabs.com>
109
116
  Peter Zotov <whitequark@whitequark.org>
117
+ Phani Kandula <phani.kandula@gmail.com>
110
118
  Phil Dokas <phil@jetless.org>
111
119
  Rafael Silva <rafael@rafaelsilva.net>
112
120
  Ray Lehnhoff <raymond.lehnhoff@gmail.com>
@@ -117,16 +125,18 @@ Richard Wang <richardwa@google.com>
117
125
  Rob Howell <rob@robhowell.com>
118
126
  Roland Warmerdam <rowno@webspirited.com>
119
127
  Roman Dvornov <rdvornov@gmail.com>
120
- Ryan Zimmerman
128
+ Ryan Zimmerman <https://github.com/RyanZim>
121
129
  Sami Suo-Heikki <suoheikki.sami@gmail.com>
122
130
  Sasha Koss <koss@nocorp.me>
123
131
  Sean Anderson <Sean.Palmer.Anderson@gmail.com>
124
132
  Sergey Belov <peimei@ya.ru>
125
133
  Sergey Leschina <mail@putnik.ws>
134
+ Sergey Lysenko <soulwish.ls@gmail.com>
126
135
  sethjgore <sethjgore@gmail.com>
127
136
  Šime Vidas <sime.vidas@gmail.com>
128
137
  Simon Lydell <simon.lydell@gmail.com>
129
138
  Sindre Sorhus <sindresorhus@gmail.com>
139
+ Stanislav <botev.st@gmail.com>
130
140
  Stephen Edgar <stephen@netweb.com.au>
131
141
  Steve Mao <https://github.com/stevemao>
132
142
  Stig Otnes Kolstad <stig@stigok.net>
@@ -141,6 +151,7 @@ Vishnu Ravi <vishnu@vishnu.io>
141
151
  Vladimir Pouzanov <farcaller@gmail.com>
142
152
  vladkens <vladkens@yandex.ru>
143
153
  Yet Another Minion <yam@thinkalexandria.com>
154
+ Yuriy Alekseyev <dev.yuriy.a@gmail.com>
144
155
  Даниил Пронин <mail@grawl.ru>
145
156
  一丝 <jie.lijie@alibaba-inc.com>
146
157
  刘祺 <gucong@gmail.com>
package/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 8.5 “Muito Nobre e Sempre Leal”
5
+ * Add `grid-gap` support (by Evgeny Petukhov).
6
+ * Fix radial gradients direction fix.
7
+ * Fix docs (by Phani Kandula and Huáng Jùnliàng).
8
+
9
+ ## 8.4.1
10
+ * Fix working in old PostCSS versions (by Diablohu).
11
+
12
+ ## 8.4 “Non in aves, sed in angues”
13
+ * Add `/* autoprefixer: ignore next */` control comment (by Pavel Vostrikov).
14
+
15
+ ## 8.3 “Benigno Numine”
16
+ * Add `@media` support to `grid-template` (by Evgeny Petukhov).
17
+ * Fix `radial-gradient` direction warning (by Gustavo Real).
18
+
4
19
  ## 8.2 “Ad Astra per Aspera”
5
20
  * Add `color-adjust` (by Sergey Lysenko, Stanislav Botev, and Yuriy Alekseyev).
6
21
 
package/README.md CHANGED
@@ -95,8 +95,8 @@ a {
95
95
  ## Browsers
96
96
 
97
97
  Autoprefixer uses [Browserslist], so you can specify the browsers
98
- you want to target in your project by queries like `last 2 versions`
99
- or `> 5%`.
98
+ you want to target in your project by queries like `> 5%`
99
+ (see [Best Practises]).
100
100
 
101
101
  The best way to provide browsers is `.browserslistrc` config
102
102
  or `package.json` with `browserslist` key. Put it in your project root.
@@ -110,6 +110,7 @@ and default value.
110
110
 
111
111
  [Browserslist docs]: https://github.com/ai/browserslist#queries
112
112
  [babel-preset-env]: https://github.com/babel/babel-preset-env
113
+ [Best Practises]: https://github.com/browserslist/browserslist#best-practices
113
114
  [Browserslist]: https://github.com/ai/browserslist
114
115
  [Stylelint]: http://stylelint.io/
115
116
 
@@ -501,7 +502,7 @@ You can use these plugin options to disable some of the Autoprefixer's features.
501
502
  versions of specification.
502
503
  * `remove: false` will disable cleaning outdated prefixes.
503
504
 
504
- You shoud set them to the plugin:
505
+ You should set them to the plugin:
505
506
 
506
507
  ```js
507
508
  autoprefixer({ grid: true });
@@ -514,19 +515,27 @@ If you do not need Autoprefixer in some part of your CSS,
514
515
  you can use control comments to disable Autoprefixer.
515
516
 
516
517
  ```css
517
- a {
518
+ .a {
518
519
  transition: 1s; /* it will be prefixed */
519
520
  }
520
521
 
521
- b {
522
+ .b {
522
523
  /* autoprefixer: off */
523
524
  transition: 1s; /* it will not be prefixed */
524
525
  }
526
+
527
+ .c {
528
+ /* autoprefixer: ignore next */
529
+ transition: 1s; /* it will not be prefixed */
530
+ mask: url(image.png); /* it will be prefixed */
531
+ }
525
532
  ```
526
533
 
527
- Control comments disable Autoprefixer within the whole rule in which
528
- you place it. In the above example, Autoprefixer will be disabled
529
- in the entire `b` rule scope, not only after the comment.
534
+ There are two types of control comments:
535
+
536
+ * `/* autoprefixer: off */` disable the whole block *before* and after comment.
537
+ * `/* autoprefixer: ignore next */` disable only next property
538
+ or next rule selector or at-rule parameters (but not rule/at‑rule body).
530
539
 
531
540
  You can also use comments recursively:
532
541
 
@@ -541,7 +550,11 @@ You can also use comments recursively:
541
550
  ```
542
551
 
543
552
  In Sass/SCSS you can use all the disable options above, add an exclamation mark
544
- in the start of comment: `/*! autoprefixer: off */`.
553
+ in the start of comment:
554
+
555
+ ```scss
556
+ /*! autoprefixer: off */
557
+ ```
545
558
 
546
559
 
547
560
  ## Options
@@ -555,11 +568,6 @@ autoprefixer({ cascade: false })
555
568
 
556
569
  Available options are:
557
570
 
558
- * `browsers` (array): list of browsers query (like `last 2 versions`),
559
- which are supported in your project. We recommend to use `browserslist`
560
- config or `browserslist` key in `package.json`, rather than this option
561
- to share browsers with other tools. See [Browserslist docs] for available
562
- queries and default value.
563
571
  * `env` (string): environment for Browserslist.
564
572
  * `cascade` (boolean): should Autoprefixer use Visual Cascade,
565
573
  if CSS is uncompressed. Default: `true`
@@ -575,6 +583,11 @@ Available options are:
575
583
  properties. Default is `false`.
576
584
  * `stats` (object): custom [usage statistics] for `> 10% in my stats`
577
585
  browsers query.
586
+ * `browsers` (array): list of queries for target browsers. Try to not use it.
587
+  The best practice is to use `.browserslistrc` config
588
+ or `browserslist` key in `package.json` to share target browsers
589
+ with Babel, ESLint and Stylelint. See [Browserslist docs]
590
+ for available queries and default value.
578
591
 
579
592
  Plugin object has `info()` method for debugging purpose.
580
593
 
@@ -199,6 +199,42 @@ var Gradient = function (_Value) {
199
199
  return params;
200
200
  };
201
201
 
202
+ /**
203
+ * Look for at word
204
+ */
205
+
206
+
207
+ Gradient.prototype.isRadial = function isRadial(params) {
208
+ var state = 'before';
209
+ for (var _iterator2 = params, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
210
+ var _ref2;
211
+
212
+ if (_isArray2) {
213
+ if (_i2 >= _iterator2.length) break;
214
+ _ref2 = _iterator2[_i2++];
215
+ } else {
216
+ _i2 = _iterator2.next();
217
+ if (_i2.done) break;
218
+ _ref2 = _i2.value;
219
+ }
220
+
221
+ var param = _ref2;
222
+
223
+ if (state === 'before' && param.type === 'space') {
224
+ state = 'at';
225
+ } else if (state === 'at' && param.value === 'at') {
226
+ state = 'after';
227
+ } else if (state === 'after' && param.type === 'space') {
228
+ return true;
229
+ } else if (param.type === 'div') {
230
+ break;
231
+ } else {
232
+ state = 'before';
233
+ }
234
+ }
235
+ return false;
236
+ };
237
+
202
238
  /**
203
239
  * Change new direction to old
204
240
  */
@@ -210,7 +246,7 @@ var Gradient = function (_Value) {
210
246
  this.fixDirection(params);
211
247
  } else if (params[0].value.indexOf('deg') !== -1) {
212
248
  this.fixAngle(params);
213
- } else if (params[2] && params[2].value === 'at') {
249
+ } else if (this.isRadial(params)) {
214
250
  this.fixRadial(params);
215
251
  }
216
252
  }
@@ -225,19 +261,19 @@ var Gradient = function (_Value) {
225
261
  Gradient.prototype.fixDirection = function fixDirection(params) {
226
262
  params.splice(0, 2);
227
263
 
228
- for (var _iterator2 = params, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
229
- var _ref2;
264
+ for (var _iterator3 = params, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
265
+ var _ref3;
230
266
 
231
- if (_isArray2) {
232
- if (_i2 >= _iterator2.length) break;
233
- _ref2 = _iterator2[_i2++];
267
+ if (_isArray3) {
268
+ if (_i3 >= _iterator3.length) break;
269
+ _ref3 = _iterator3[_i3++];
234
270
  } else {
235
- _i2 = _iterator2.next();
236
- if (_i2.done) break;
237
- _ref2 = _i2.value;
271
+ _i3 = _iterator3.next();
272
+ if (_i3.done) break;
273
+ _ref3 = _i3.value;
238
274
  }
239
275
 
240
- var param = _ref2;
276
+ var param = _ref3;
241
277
 
242
278
  if (param.type === 'div') {
243
279
  break;
@@ -267,12 +303,28 @@ var Gradient = function (_Value) {
267
303
 
268
304
 
269
305
  Gradient.prototype.fixRadial = function fixRadial(params) {
270
- var first = params[0];
306
+ var first = [];
271
307
  var second = [];
272
- var i = void 0;
308
+ var a = void 0,
309
+ b = void 0,
310
+ c = void 0,
311
+ i = void 0,
312
+ next = void 0;
313
+
314
+ for (i = 0; i < params.length - 2; i++) {
315
+ a = params[i];
316
+ b = params[i + 1];
317
+ c = params[i + 2];
318
+ if (a.type === 'space' && b.value === 'at' && c.type === 'space') {
319
+ next = i + 3;
320
+ break;
321
+ } else {
322
+ first.push(a);
323
+ }
324
+ }
273
325
 
274
326
  var div = void 0;
275
- for (i = 4; i < params.length; i++) {
327
+ for (i = next; i < params.length; i++) {
276
328
  if (params[i].type === 'div') {
277
329
  div = params[i];
278
330
  break;
@@ -281,7 +333,7 @@ var Gradient = function (_Value) {
281
333
  }
282
334
  }
283
335
 
284
- params.splice.apply(params, [0, i].concat(second, [div, first]));
336
+ params.splice.apply(params, [0, i].concat(second, [div], first));
285
337
  };
286
338
 
287
339
  Gradient.prototype.revertDirection = function revertDirection(word) {
@@ -318,19 +370,19 @@ var Gradient = function (_Value) {
318
370
  }
319
371
 
320
372
  var params = [[]];
321
- for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
322
- var _ref3;
373
+ for (var _iterator4 = nodes, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
374
+ var _ref4;
323
375
 
324
- if (_isArray3) {
325
- if (_i3 >= _iterator3.length) break;
326
- _ref3 = _iterator3[_i3++];
376
+ if (_isArray4) {
377
+ if (_i4 >= _iterator4.length) break;
378
+ _ref4 = _iterator4[_i4++];
327
379
  } else {
328
- _i3 = _iterator3.next();
329
- if (_i3.done) break;
330
- _ref3 = _i3.value;
380
+ _i4 = _iterator4.next();
381
+ if (_i4.done) break;
382
+ _ref4 = _i4.value;
331
383
  }
332
384
 
333
- var i = _ref3;
385
+ var i = _ref4;
334
386
 
335
387
  params[params.length - 1].push(i);
336
388
  if (i.type === 'div' && i.value === ',') {
@@ -342,19 +394,19 @@ var Gradient = function (_Value) {
342
394
  this.colorStops(params);
343
395
 
344
396
  node.nodes = [];
345
- for (var _iterator4 = params, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
346
- var _ref4;
397
+ for (var _iterator5 = params, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
398
+ var _ref5;
347
399
 
348
- if (_isArray4) {
349
- if (_i4 >= _iterator4.length) break;
350
- _ref4 = _iterator4[_i4++];
400
+ if (_isArray5) {
401
+ if (_i5 >= _iterator5.length) break;
402
+ _ref5 = _iterator5[_i5++];
351
403
  } else {
352
- _i4 = _iterator4.next();
353
- if (_i4.done) break;
354
- _ref4 = _i4.value;
404
+ _i5 = _iterator5.next();
405
+ if (_i5.done) break;
406
+ _ref5 = _i5.value;
355
407
  }
356
408
 
357
- var param = _ref4;
409
+ var param = _ref5;
358
410
 
359
411
  node.nodes = node.nodes.concat(param);
360
412
  }
@@ -377,19 +429,19 @@ var Gradient = function (_Value) {
377
429
  return params.unshift([{ type: 'word', value: this.oldDirections.bottom }, div]);
378
430
  } else {
379
431
  var _words = [];
380
- for (var _iterator5 = params[0].slice(2), _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
381
- var _ref5;
432
+ for (var _iterator6 = params[0].slice(2), _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
433
+ var _ref6;
382
434
 
383
- if (_isArray5) {
384
- if (_i5 >= _iterator5.length) break;
385
- _ref5 = _iterator5[_i5++];
435
+ if (_isArray6) {
436
+ if (_i6 >= _iterator6.length) break;
437
+ _ref6 = _iterator6[_i6++];
386
438
  } else {
387
- _i5 = _iterator5.next();
388
- if (_i5.done) break;
389
- _ref5 = _i5.value;
439
+ _i6 = _iterator6.next();
440
+ if (_i6.done) break;
441
+ _ref6 = _i6.value;
390
442
  }
391
443
 
392
- var node = _ref5;
444
+ var node = _ref6;
393
445
 
394
446
  if (node.type === 'word') {
395
447
  _words.push(node.value.toLowerCase());
@@ -410,19 +462,19 @@ var Gradient = function (_Value) {
410
462
 
411
463
 
412
464
  Gradient.prototype.cloneDiv = function cloneDiv(params) {
413
- for (var _iterator6 = params, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
414
- var _ref6;
465
+ for (var _iterator7 = params, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
466
+ var _ref7;
415
467
 
416
- if (_isArray6) {
417
- if (_i6 >= _iterator6.length) break;
418
- _ref6 = _iterator6[_i6++];
468
+ if (_isArray7) {
469
+ if (_i7 >= _iterator7.length) break;
470
+ _ref7 = _iterator7[_i7++];
419
471
  } else {
420
- _i6 = _iterator6.next();
421
- if (_i6.done) break;
422
- _ref6 = _i6.value;
472
+ _i7 = _iterator7.next();
473
+ if (_i7.done) break;
474
+ _ref7 = _i7.value;
423
475
  }
424
476
 
425
- var i = _ref6;
477
+ var i = _ref7;
426
478
 
427
479
  if (i.type === 'div' && i.value === ',') {
428
480
  return i;
@@ -9,7 +9,10 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
9
9
  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) : _defaults(subClass, superClass); }
10
10
 
11
11
  var Declaration = require('../declaration');
12
- var utils = require('./grid-utils');
12
+
13
+ var _require = require('./grid-utils'),
14
+ prefixTrackProp = _require.prefixTrackProp,
15
+ prefixTrackValue = _require.prefixTrackValue;
13
16
 
14
17
  var GridRowsColumns = function (_Declaration) {
15
18
  _inherits(GridRowsColumns, _Declaration);
@@ -25,7 +28,7 @@ var GridRowsColumns = function (_Declaration) {
25
28
  */
26
29
  GridRowsColumns.prototype.prefixed = function prefixed(prop, prefix) {
27
30
  if (prefix === '-ms-') {
28
- return prefix + prop.replace('template-', '');
31
+ return prefixTrackProp({ prop: prop, prefix: prefix });
29
32
  } else {
30
33
  return _Declaration.prototype.prefixed.call(this, prop, prefix);
31
34
  }
@@ -47,7 +50,7 @@ var GridRowsColumns = function (_Declaration) {
47
50
 
48
51
  GridRowsColumns.prototype.set = function set(decl, prefix) {
49
52
  if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
50
- decl.value = utils.changeRepeat(decl.value);
53
+ decl.value = prefixTrackValue({ value: decl.value });
51
54
  }
52
55
  return _Declaration.prototype.set.call(this, decl, prefix);
53
56
  };
@@ -12,7 +12,11 @@ var Declaration = require('../declaration');
12
12
 
13
13
  var _require = require('./grid-utils'),
14
14
  parseGridAreas = _require.parseGridAreas,
15
- insertAreas = _require.insertAreas;
15
+ insertAreas = _require.insertAreas,
16
+ prefixTrackProp = _require.prefixTrackProp,
17
+ prefixTrackValue = _require.prefixTrackValue,
18
+ getGridGap = _require.getGridGap,
19
+ warnGridGap = _require.warnGridGap;
16
20
 
17
21
  function getGridRows(tpl) {
18
22
  return tpl.trim().slice(1, -1).split(/['"]\s*['"]?/g);
@@ -33,7 +37,65 @@ var GridTemplateAreas = function (_Declaration) {
33
37
  GridTemplateAreas.prototype.insert = function insert(decl, prefix, prefixes, result) {
34
38
  if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
35
39
 
36
- var areas = parseGridAreas(getGridRows(decl.value));
40
+ var hasColumns = false;
41
+ var hasRows = false;
42
+ var parent = decl.parent;
43
+ var gap = getGridGap(decl);
44
+
45
+ // remove already prefixed rows and columns
46
+ // without gutter to prevent doubling prefixes
47
+ parent.walkDecls(/-ms-grid-(rows|columns)/, function (i) {
48
+ return i.remove();
49
+ });
50
+
51
+ // add empty tracks to rows and columns
52
+ parent.walkDecls(/grid-template-(rows|columns)/, function (trackDecl) {
53
+ if (trackDecl.prop === 'grid-template-rows') {
54
+ hasRows = true;
55
+ var prop = trackDecl.prop,
56
+ value = trackDecl.value;
57
+
58
+ trackDecl.cloneBefore({
59
+ prop: prefixTrackProp({ prop: prop, prefix: prefix }),
60
+ value: prefixTrackValue({ value: value, gap: gap.row })
61
+ });
62
+ } else {
63
+ hasColumns = true;
64
+ var _prop = trackDecl.prop,
65
+ _value = trackDecl.value;
66
+
67
+ trackDecl.cloneBefore({
68
+ prop: prefixTrackProp({ prop: _prop, prefix: prefix }),
69
+ value: prefixTrackValue({ value: _value, gap: gap.column })
70
+ });
71
+ }
72
+ });
73
+
74
+ var gridRows = getGridRows(decl.value);
75
+
76
+ if (hasColumns && !hasRows && gap.row && gridRows.length > 1) {
77
+ decl.cloneBefore({
78
+ prop: '-ms-grid-rows',
79
+ value: prefixTrackValue({
80
+ value: 'repeat(' + gridRows.length + ', auto)',
81
+ gap: gap.row
82
+ }),
83
+ raws: {}
84
+ });
85
+ }
86
+
87
+ // warnings
88
+ warnGridGap({
89
+ gap: gap,
90
+ hasColumns: hasColumns,
91
+ decl: decl,
92
+ result: result
93
+ });
94
+
95
+ var areas = parseGridAreas({
96
+ rows: gridRows,
97
+ gap: gap
98
+ });
37
99
 
38
100
  insertAreas(areas, decl, result);
39
101
 
@@ -12,7 +12,9 @@ var Declaration = require('../declaration');
12
12
 
13
13
  var _require = require('./grid-utils'),
14
14
  parseTemplate = _require.parseTemplate,
15
- insertAreas = _require.insertAreas;
15
+ insertAreas = _require.insertAreas,
16
+ getGridGap = _require.getGridGap,
17
+ warnGridGap = _require.warnGridGap;
16
18
 
17
19
  var GridTemplate = function (_Declaration) {
18
20
  _inherits(GridTemplate, _Declaration);
@@ -35,24 +37,40 @@ var GridTemplate = function (_Declaration) {
35
37
  return undefined;
36
38
  }
37
39
 
38
- var _parseTemplate = parseTemplate(decl),
40
+ var gap = getGridGap(decl);
41
+
42
+ var _parseTemplate = parseTemplate({
43
+ decl: decl,
44
+ gap: gap
45
+ }),
39
46
  rows = _parseTemplate.rows,
40
47
  columns = _parseTemplate.columns,
41
48
  areas = _parseTemplate.areas;
42
49
 
43
50
  var hasAreas = Object.keys(areas).length > 0;
51
+ var hasRows = Boolean(rows);
52
+ var hasColumns = Boolean(columns);
53
+
54
+ warnGridGap({
55
+ gap: gap,
56
+ hasColumns: hasColumns,
57
+ decl: decl,
58
+ result: result
59
+ });
44
60
 
45
- if (rows && columns || hasAreas) {
61
+ if (hasRows && hasColumns || hasAreas) {
46
62
  decl.cloneBefore({
47
63
  prop: '-ms-grid-rows',
48
- value: rows
64
+ value: rows,
65
+ raws: {}
49
66
  });
50
67
  }
51
68
 
52
- if (columns) {
69
+ if (hasColumns) {
53
70
  decl.cloneBefore({
54
71
  prop: '-ms-grid-columns',
55
- value: columns
72
+ value: columns,
73
+ raws: {}
56
74
  });
57
75
  }
58
76
 
@@ -92,36 +92,71 @@ function insertDecl(decl, prop, value) {
92
92
  }
93
93
  }
94
94
 
95
- // Transform repeat
95
+ // Track transforms
96
96
 
97
- function transformRepeat(_ref2) {
98
- var nodes = _ref2.nodes;
97
+ function prefixTrackProp(_ref2) {
98
+ var prop = _ref2.prop,
99
+ prefix = _ref2.prefix;
99
100
 
100
- var repeat = nodes.reduce(function (result, node) {
101
+ return prefix + prop.replace('template-', '');
102
+ }
103
+
104
+ function transformRepeat(_ref3, _ref4) {
105
+ var nodes = _ref3.nodes;
106
+ var gap = _ref4.gap;
107
+
108
+ var _nodes$reduce = nodes.reduce(function (result, node) {
101
109
  if (node.type === 'div' && node.value === ',') {
102
- result.key = 'function';
110
+ result.key = 'size';
103
111
  } else {
104
112
  result[result.key].push(parser.stringify(node));
105
113
  }
106
114
  return result;
107
115
  }, {
108
116
  key: 'count',
109
- function: [],
117
+ size: [],
110
118
  count: []
111
- });
112
- return '(' + repeat.function.join('') + ')[' + repeat.count.join('') + ']';
119
+ }),
120
+ count = _nodes$reduce.count,
121
+ size = _nodes$reduce.size;
122
+
123
+ if (gap) {
124
+ var val = [];
125
+ for (var i = 1; i <= count; i++) {
126
+ if (gap && i > 1) {
127
+ val.push(gap);
128
+ }
129
+ val.push(size.join());
130
+ }
131
+ return val.join(' ');
132
+ }
133
+
134
+ return '(' + size.join('') + ')[' + count.join('') + ']';
113
135
  }
114
136
 
115
- function changeRepeat(value) {
116
- var result = parser(value).nodes.map(function (i) {
117
- if (i.type === 'function' && i.value === 'repeat') {
118
- return {
137
+ function prefixTrackValue(_ref5) {
138
+ var value = _ref5.value,
139
+ gap = _ref5.gap;
140
+
141
+ var result = parser(value).nodes.reduce(function (nodes, node) {
142
+ if (node.type === 'function' && node.value === 'repeat') {
143
+ return nodes.concat({
119
144
  type: 'word',
120
- value: transformRepeat(i)
121
- };
145
+ value: transformRepeat(node, { gap: gap })
146
+ });
122
147
  }
123
- return i;
124
- });
148
+ if (gap && node.type === 'space') {
149
+ return nodes.concat({
150
+ type: 'space',
151
+ value: ' '
152
+ }, {
153
+ type: 'word',
154
+ value: gap
155
+ }, node);
156
+ }
157
+ return nodes.concat(node);
158
+ }, []);
159
+
125
160
  return parser.stringify(result);
126
161
  }
127
162
 
@@ -137,12 +172,24 @@ function getColumns(line) {
137
172
  return line.trim().split(/\s+/g);
138
173
  }
139
174
 
140
- function parseGridAreas(rows) {
175
+ function parseGridAreas(_ref6) {
176
+ var rows = _ref6.rows,
177
+ gap = _ref6.gap;
178
+
141
179
  return rows.reduce(function (areas, line, rowIndex) {
180
+
181
+ if (gap.row) rowIndex *= 2;
182
+
142
183
  if (line.trim() === '') return areas;
184
+
143
185
  getColumns(line).forEach(function (area, columnIndex) {
186
+
144
187
  if (DOTS.test(area)) return;
188
+
189
+ if (gap.column) columnIndex *= 2;
190
+
145
191
  if (typeof areas[area] === 'undefined') {
192
+
146
193
  areas[area] = {
147
194
  column: track(columnIndex + 1, columnIndex + 2),
148
195
  row: track(rowIndex + 1, rowIndex + 2)
@@ -162,6 +209,7 @@ function parseGridAreas(rows) {
162
209
  row.span = row.end - row.start;
163
210
  }
164
211
  });
212
+
165
213
  return areas;
166
214
  }, {});
167
215
  }
@@ -172,7 +220,10 @@ function testTrack(node) {
172
220
  return node.type === 'word' && /^\[.+\]$/.test(node.value);
173
221
  }
174
222
 
175
- function parseTemplate(decl) {
223
+ function parseTemplate(_ref7) {
224
+ var decl = _ref7.decl,
225
+ gap = _ref7.gap;
226
+
176
227
  var gridTemplate = parser(decl.value).nodes.reduce(function (result, node) {
177
228
  var type = node.type,
178
229
  value = node.value;
@@ -187,11 +238,7 @@ function parseTemplate(decl) {
187
238
 
188
239
  // values and function
189
240
  if (type === 'word' || type === 'function') {
190
- if (type === 'function' && value === 'repeat') {
191
- result[result.key].push(transformRepeat(node));
192
- } else {
193
- result[result.key].push(parser.stringify(node));
194
- }
241
+ result[result.key].push(parser.stringify(node));
195
242
  }
196
243
 
197
244
  // devider(/)
@@ -206,26 +253,57 @@ function parseTemplate(decl) {
206
253
  rows: [],
207
254
  areas: []
208
255
  });
256
+
209
257
  return {
210
- areas: parseGridAreas(gridTemplate.areas),
211
- columns: gridTemplate.columns.join(' '),
212
- rows: gridTemplate.rows.join(' ')
258
+ areas: parseGridAreas({
259
+ rows: gridTemplate.areas,
260
+ gap: gap
261
+ }),
262
+ columns: prefixTrackValue({
263
+ value: gridTemplate.columns.join(' '),
264
+ gap: gap.column
265
+ }),
266
+ rows: prefixTrackValue({
267
+ value: gridTemplate.rows.join(' '),
268
+ gap: gap.row
269
+ })
213
270
  };
214
271
  }
215
272
 
216
273
  // Insert parsed grid areas
217
274
 
218
- function getRoot(parent) {
219
- if (parent.type === 'atrule' || !parent.parent) {
275
+ function getMSDecls(area) {
276
+ return [].concat({
277
+ prop: '-ms-grid-row',
278
+ value: String(area.row.start)
279
+ }, area.row.span > 1 ? {
280
+ prop: '-ms-grid-row-span',
281
+ value: String(area.row.span)
282
+ } : [], {
283
+ prop: '-ms-grid-column',
284
+ value: String(area.column.start)
285
+ }, area.column.span > 1 ? {
286
+ prop: '-ms-grid-column-span',
287
+ value: String(area.column.span)
288
+ } : []);
289
+ }
290
+
291
+ function getParentMedia(parent) {
292
+ if (parent.type === 'atrule' && parent.name === 'media') {
220
293
  return parent;
294
+ } else if (!parent.parent) {
295
+ return false;
221
296
  }
222
- return getRoot(parent.parent);
297
+ return getParentMedia(parent.parent);
223
298
  }
224
299
 
225
300
  function insertAreas(areas, decl, result) {
226
301
  var missed = Object.keys(areas);
227
302
 
228
- getRoot(decl.parent).walkDecls('grid-area', function (gridArea) {
303
+ var parentMedia = getParentMedia(decl.parent);
304
+
305
+ decl.root().walkDecls('grid-area', function (gridArea) {
306
+
229
307
  var value = gridArea.value;
230
308
  var area = areas[value];
231
309
 
@@ -233,32 +311,47 @@ function insertAreas(areas, decl, result) {
233
311
  return e !== value;
234
312
  });
235
313
 
314
+ if (area && parentMedia) {
315
+
316
+ // skip if grid-template-areas already prefixed in media
317
+ if (parentMedia.some(function (i) {
318
+ return i.selector === gridArea.parent.selector;
319
+ })) {
320
+ return undefined;
321
+ }
322
+
323
+ // create new rule
324
+ var rule = decl.parent.clone({
325
+ selector: gridArea.parent.selector
326
+ });
327
+ rule.removeAll();
328
+
329
+ // insert prefixed decls in new rule
330
+ getMSDecls(area).forEach(function (i) {
331
+ return rule.append(Object.assign(i, {
332
+ raws: {
333
+ between: gridArea.raws.between
334
+ }
335
+ }));
336
+ });
337
+
338
+ // insert new rule with prefixed decl to existing media
339
+ parentMedia.append(rule);
340
+
341
+ return undefined;
342
+ }
343
+
236
344
  if (area) {
237
345
  gridArea.parent.walkDecls(/-ms-grid-(row|column)/, function (d) {
238
346
  d.remove();
239
347
  });
240
348
 
241
- gridArea.cloneBefore({
242
- prop: '-ms-grid-row',
243
- value: String(area.row.start)
349
+ // insert prefixed decls before grid-area
350
+ getMSDecls(area).forEach(function (i) {
351
+ return gridArea.cloneBefore(i);
244
352
  });
245
- if (area.row.span > 1) {
246
- gridArea.cloneBefore({
247
- prop: '-ms-grid-row-span',
248
- value: String(area.row.span)
249
- });
250
- }
251
- gridArea.cloneBefore({
252
- prop: '-ms-grid-column',
253
- value: String(area.column.start)
254
- });
255
- if (area.column.span > 1) {
256
- gridArea.cloneBefore({
257
- prop: '-ms-grid-column-span',
258
- value: String(area.column.span)
259
- });
260
- }
261
353
  }
354
+
262
355
  return undefined;
263
356
  });
264
357
 
@@ -267,12 +360,50 @@ function insertAreas(areas, decl, result) {
267
360
  }
268
361
  }
269
362
 
363
+ // Gap utils
364
+
365
+ function getGridGap(decl) {
366
+
367
+ var gap = {};
368
+
369
+ // try to find gap
370
+ decl.parent.walkDecls(/grid(-(row|column))?-gap/, function (_ref8) {
371
+ var prop = _ref8.prop,
372
+ value = _ref8.value;
373
+
374
+ if (prop === 'grid-gap') {
375
+ gap.column = value;
376
+ gap.row = value;
377
+ }
378
+ if (prop === 'grid-row-gap') gap.row = value;
379
+ if (prop === 'grid-column-gap') gap.column = value;
380
+ });
381
+
382
+ return gap;
383
+ }
384
+
385
+ function warnGridGap(_ref9) {
386
+ var gap = _ref9.gap,
387
+ hasColumns = _ref9.hasColumns,
388
+ decl = _ref9.decl,
389
+ result = _ref9.result;
390
+
391
+ var hasBothGaps = gap.row && gap.column;
392
+ if (!hasColumns && (hasBothGaps || gap.column && !gap.row)) {
393
+ delete gap.column;
394
+ decl.warn(result, 'Can not impliment grid-gap without grid-tamplate-columns');
395
+ }
396
+ }
397
+
270
398
  module.exports = {
271
399
  parse: parse,
272
400
  translate: translate,
273
- changeRepeat: changeRepeat,
274
401
  parseTemplate: parseTemplate,
275
402
  parseGridAreas: parseGridAreas,
276
403
  insertAreas: insertAreas,
277
- insertDecl: insertDecl
404
+ insertDecl: insertDecl,
405
+ prefixTrackProp: prefixTrackProp,
406
+ prefixTrackValue: prefixTrackValue,
407
+ getGridGap: getGridGap,
408
+ warnGridGap: warnGridGap
278
409
  };
package/lib/processor.js CHANGED
@@ -6,6 +6,8 @@ var Value = require('./value');
6
6
 
7
7
  var OLD_LINEAR = /(^|[^-])linear-gradient\(\s*(top|left|right|bottom)/i;
8
8
  var OLD_RADIAL = /(^|[^-])radial-gradient\(\s*\d+(\w*|%)\s+\d+(\w*|%)\s*,/i;
9
+ var RADIAL_BLOCK = /\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/i;
10
+ var IGNORE_NEXT = /(!\s*)?autoprefixer:\s*ignore\s+next/i;
9
11
 
10
12
  var SIZES = ['width', 'height', 'min-width', 'max-width', 'min-height', 'max-height', 'inline-size', 'min-inline-size', 'max-inline-size', 'block-size', 'min-block-size', 'max-block-size'];
11
13
 
@@ -76,10 +78,16 @@ var Processor = function () {
76
78
  if (decl.value.indexOf('radial-gradient') !== -1) {
77
79
  if (OLD_RADIAL.test(decl.value)) {
78
80
  result.warn('Gradient has outdated direction syntax. ' + 'New syntax is like `closest-side at 0 0` ' + 'instead of `0 0, closest-side`.', { node: decl });
79
- } else if (/[^-]cover/.test(decl.value)) {
80
- result.warn('Gradient has outdated direction syntax. ' + 'Replace `cover` to `farthest-corner`.', { node: decl });
81
- } else if (/[^-]contain/.test(decl.value)) {
82
- result.warn('Gradient has outdated direction syntax. ' + 'Replace `contain` to `closest-side`.', { node: decl });
81
+ } else {
82
+ var match = decl.value.match(RADIAL_BLOCK);
83
+
84
+ if (match) {
85
+ if (/cover/.test(match[1])) {
86
+ result.warn('Gradient has outdated direction syntax. ' + 'Replace `cover` to `farthest-corner`.', { node: decl });
87
+ } else if (/contain/.test(match[1])) {
88
+ result.warn('Gradient has outdated direction syntax. ' + 'Replace `contain` to `closest-side`.', { node: decl });
89
+ }
90
+ }
83
91
  }
84
92
  }
85
93
  if (decl.prop === 'text-emphasis-position') {
@@ -330,10 +338,21 @@ var Processor = function () {
330
338
 
331
339
  Processor.prototype.disabled = function disabled(node, result) {
332
340
  if (!node) return false;
341
+
333
342
  if (node._autoprefixerDisabled !== undefined) {
334
343
  return node._autoprefixerDisabled;
335
344
  }
336
345
 
346
+ if (node.parent) {
347
+ var p = node.prev();
348
+ if (p && p.type === 'comment' && IGNORE_NEXT.test(p.text)) {
349
+ node._autoprefixerDisabled = true;
350
+ node._autoprefixerSelfDisabled = true;
351
+ return true;
352
+ }
353
+ }
354
+
355
+ var value = null;
337
356
  if (node.nodes) {
338
357
  var status = undefined;
339
358
  node.each(function (i) {
@@ -347,19 +366,24 @@ var Processor = function () {
347
366
  }
348
367
  });
349
368
 
350
- var value = false;
351
369
  if (status !== undefined) {
352
370
  value = !status;
353
- } else if (node.parent) {
354
- value = this.disabled(node.parent, result);
355
371
  }
356
-
357
- node._autoprefixerDisabled = value;
358
- return node._autoprefixerDisabled;
359
- } else {
360
- node._autoprefixerDisabled = this.disabled(node.parent, result);
361
- return node._autoprefixerDisabled;
362
372
  }
373
+ if (!node.nodes || value === null) {
374
+ if (node.parent) {
375
+ var isParentDisabled = this.disabled(node.parent, result);
376
+ if (node.parent._autoprefixerSelfDisabled === true) {
377
+ value = false;
378
+ } else {
379
+ value = isParentDisabled;
380
+ }
381
+ } else {
382
+ value = false;
383
+ }
384
+ }
385
+ node._autoprefixerDisabled = value;
386
+ return value;
363
387
  };
364
388
 
365
389
  /**
package/package.json CHANGED
@@ -1,23 +1,17 @@
1
1
  {
2
2
  "name": "autoprefixer",
3
- "version": "8.2.0",
3
+ "version": "8.5.0",
4
4
  "description": "Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website",
5
- "keywords": [
6
- "autoprefixer",
7
- "css",
8
- "prefix",
9
- "postcss",
10
- "postcss-plugin"
11
- ],
5
+ "keywords": ["autoprefixer", "css", "prefix", "postcss", "postcss-plugin"],
12
6
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
13
7
  "license": "MIT",
14
8
  "repository": "postcss/autoprefixer",
15
9
  "dependencies": {
16
- "browserslist": "^3.2.0",
17
- "caniuse-lite": "^1.0.30000817",
10
+ "browserslist": "^3.2.7",
11
+ "caniuse-lite": "^1.0.30000839",
18
12
  "normalize-range": "^0.1.2",
19
13
  "num2fraction": "^1.2.2",
20
- "postcss": "^6.0.20",
14
+ "postcss": "^6.0.22",
21
15
  "postcss-value-parser": "^3.2.3"
22
16
  },
23
17
  "bin": {