autoprefixer 9.3.0 → 9.4.2

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/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 9.4.2
5
+ * Fix Grid autoplacment warning.
6
+
7
+ ## 9.4.1
8
+ * Fix unnecessary Flexbox prefixes in Grid elements.
9
+
10
+ ## 9.4 “Advance Australia”
11
+ * Add Grid autoplacment for `-ms-` (by Bogdan Dolin).
12
+ * Improve docs and warnings (by Daniel Tonon).
13
+ * Remove some unnecessary warnings for Grid (by Andrey Alexandrov).
14
+
15
+ ## 9.3.1
16
+ * Fix Grid prefixes with `repeat()` value (by Bogdan Dolin).
17
+
4
18
  ## 9.3 “Labor omnia vincit”
5
19
  * Add `place-self` support (by Bogdan Dolin).
6
20
  * Fix Grid row/column span inheritance bug (by Bogdan Dolin).
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  title="Autoprefixer logo by Anton Lovchikov">
6
6
 
7
7
  [PostCSS] plugin to parse CSS and add vendor prefixes to CSS rules using values
8
- from [Can I Use]. It is [recommended] by Google and used in Twitter and Taobao.
8
+ from [Can I Use]. It is [recommended] by Google and used in Twitter and Alibaba.
9
9
 
10
10
  Write your CSS rules without vendor prefixes (in fact, forget about them
11
11
  entirely):
@@ -50,6 +50,33 @@ Twitter account for news and releases: [@autoprefixer].
50
50
  [cult]: http://cultofmartians.com/tasks/autoprefixer-grid.html
51
51
 
52
52
 
53
+ ## Contents
54
+
55
+ - [Browsers](#browsers)
56
+ - [FAQ](#faq)
57
+ - [Does Autoprefixer polyfill Grid Layout for IE?](#does-autoprefixer-polyfill-grid-layout-for-ie)
58
+ - [No prefixes in production](#no-prefixes-in-production)
59
+ - [What is the unprefixed version of `-webkit-min-device-pixel-ratio`?](#what-is-the-unprefixed-version-of--webkit-min-device-pixel-ratio)
60
+ - [Does it add polyfills?](#does-it-add-polyfills)
61
+ - [Why doesn’t Autoprefixer add prefixes to `border-radius`?](#why-doesnt-autoprefixer-add-prefixes-to-border-radius)
62
+ - [Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?](#why-does-autoprefixer-use-unprefixed-properties-in--webkit-keyframes)
63
+ - [How to work with legacy `-webkit-` only code?](#how-to-work-with-legacy--webkit--only-code)
64
+ - [Does Autoprefixer add `-epub-` prefix?](#does-autoprefixer-add--epub--prefix)
65
+ - [Why doesn’t Autoprefixer transform generic font-family `system-ui`?](#why-doesnt-autoprefixer-transform-generic-font-family-system-ui)
66
+ - [Usage](#usage)
67
+ - [Gulp](#gulp)
68
+ - [Webpack](#webpack)
69
+ - [CSS-in-JS](#css-in-js)
70
+ - [CLI](#cli)
71
+ - [Other Build Tools](#other-build-tools)
72
+ - [JavaScript](#javascript)
73
+ - [Text Editors and IDE](#text-editors-and-ide)
74
+ - [Warnings](#warnings)
75
+ - [Disabling](#disabling)
76
+ - [Options](#options)
77
+ - [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie)
78
+ - [Debug](#debug)
79
+
53
80
  ## Browsers
54
81
 
55
82
  Autoprefixer uses [Browserslist], so you can specify the browsers
@@ -74,20 +101,20 @@ See [Browserslist docs] for queries, browser names, config format, and defaults.
74
101
 
75
102
  ## FAQ
76
103
 
77
- #### Does Autoprefixer polyfill Grid Layout for IE?
104
+ ### Does Autoprefixer polyfill Grid Layout for IE?
78
105
 
79
- Autoprefixer can be used to use Grid Layout for IE 10 and IE 11, but this
80
- polyfill will not work in 100% of cases. This is why it is disabled by default.
106
+ Autoprefixer can be used to translate modern CSS Grid syntax into IE 10 and IE 11 syntax,
107
+ but this polyfill will not work in 100% of cases. This is why it is disabled by default.
81
108
 
82
- First, you need to enable Grid prefixes by `grid: true` option or `/* autoprefixer grid: on */` comment.
109
+ First, you need to enable Grid prefixes by using either the `grid: "autoplace"` option or the `/* autoprefixer grid: autoplace */` control comment.
83
110
 
84
111
  Second, you need to test every fix with Grid in IE. It is not an enable and
85
112
  forget feature, but it is still very useful.
86
113
  Financial Times and Yandex use it in production.
87
114
 
88
- Third, there is no auto placement, so all grid cell positions must be set
89
- explicitly. Autoprefixer _can_ covert `grid-template` and `grid-gap`, but only
90
- when both are used together.
115
+ Third, there is only very limited auto placement support. Read the [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie) section for more details.
116
+
117
+ Fourth, if you are not using the autoplacement feature, the best way to use Autoprefixer is by using `grid-template` or `grid-template-areas`.
91
118
 
92
119
  ```css
93
120
  .page {
@@ -119,13 +146,13 @@ See also:
119
146
  * [`postcss-gap-properties`] to use new `gap` property
120
147
  instead of old `grid-gap`.
121
148
  * [`postcss-grid-kiss`] has alternate “everything in one property” syntax,
122
- which make using Autoprefixer’s Grid safer.
149
+ which makes using Autoprefixer’s Grid translations safer.
123
150
 
124
151
  [The guide about Grids in IE and Autoprefixer]: https://css-tricks.com/css-grid-in-ie-css-grid-and-the-new-autoprefixer/
125
152
  [`postcss-gap-properties`]: https://github.com/jonathantneal/postcss-gap-properties
126
153
  [`postcss-grid-kiss`]: https://github.com/sylvainpolletvillard/postcss-grid-kiss
127
154
 
128
- #### No prefixes in production
155
+ ### No prefixes in production
129
156
 
130
157
  Many other tools contain Autoprefixer. For example, webpack uses Autoprefixer
131
158
  to minify CSS by cleaning unnecessary prefixes.
@@ -141,7 +168,7 @@ cssnano, doiuse, cssnext, etc) use the same browsers list.
141
168
  [browserslist config file]: https://github.com/ai/browserslist#config-file
142
169
 
143
170
 
144
- #### What is the unprefixed version of `-webkit-min-device-pixel-ratio`?
171
+ ### What is the unprefixed version of `-webkit-min-device-pixel-ratio`?
145
172
 
146
173
  ```css
147
174
  @media (min-resolution: 2dppx) {
@@ -164,7 +191,7 @@ Will be compiled to:
164
191
  ```
165
192
 
166
193
 
167
- #### Does it add polyfills?
194
+ ### Does it add polyfills?
168
195
 
169
196
  No. Autoprefixer only adds prefixes.
170
197
 
@@ -185,7 +212,7 @@ you might take a look at:
185
212
  [Oldie]: https://github.com/jonathantneal/oldie
186
213
 
187
214
 
188
- #### Why doesn’t Autoprefixer add prefixes to `border-radius`?
215
+ ### Why doesn’t Autoprefixer add prefixes to `border-radius`?
189
216
 
190
217
  Developers are often surprised by how few prefixes are required today.
191
218
  If Autoprefixer doesn’t add prefixes to your CSS, check if they’re still
@@ -194,13 +221,13 @@ required on [Can I Use].
194
221
  [Can I Use]: http://caniuse.com/
195
222
 
196
223
 
197
- #### Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?
224
+ ### Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?
198
225
 
199
226
  Browser teams can remove some prefixes before others, so we try to use all
200
227
  combinations of prefixed/unprefixed values.
201
228
 
202
229
 
203
- #### How to work with legacy `-webkit-` only code?
230
+ ### How to work with legacy `-webkit-` only code?
204
231
 
205
232
  Autoprefixer needs unprefixed property to add prefixes. So if you only
206
233
  wrote `-webkit-gradient` without W3C’s `gradient`,
@@ -212,7 +239,7 @@ Use [postcss-unprefix] before Autoprefixer.
212
239
  [postcss-unprefix]: https://github.com/gucong3000/postcss-unprefix
213
240
 
214
241
 
215
- #### Does Autoprefixer add `-epub-` prefix?
242
+ ### Does Autoprefixer add `-epub-` prefix?
216
243
 
217
244
  No, Autoprefixer works only with browsers prefixes from Can I Use.
218
245
  But you can use [postcss-epub]
@@ -221,7 +248,7 @@ for prefixing ePub3 properties.
221
248
  [postcss-epub]: https://github.com/Rycochet/postcss-epub
222
249
 
223
250
 
224
- #### Why doesn’t Autoprefixer transform generic font-family `system-ui`?
251
+ ### Why doesn’t Autoprefixer transform generic font-family `system-ui`?
225
252
 
226
253
  `system-ui` is technically not a prefix and the transformation is not
227
254
  future-proof. You can use [postcss-font-family-system-ui] to transform
@@ -290,41 +317,58 @@ module.exports = {
290
317
  [webpack]: http://webpack.github.io/
291
318
 
292
319
 
293
- ### Grunt
320
+ ### CSS-in-JS
294
321
 
295
- In Grunt you can use [grunt-postcss] with `autoprefixer` npm package.
322
+ The best way to use PostCSS with CSS-in-JS is [`astroturf`].
323
+ Add it’s loader to your `webpack.config.js`:
296
324
 
297
325
  ```js
298
- module.exports = function(grunt) {
299
- grunt.loadNpmTasks('grunt-postcss');
300
-
301
- grunt.initConfig({
302
- postcss: {
303
- options: {
304
- map: true,
305
- processors: [
306
- require('autoprefixer')
307
- ]
308
- },
309
- dist: {
310
- src: 'css/*.css'
311
- }
312
- }
313
- });
326
+ module.exports = {
327
+ module: {
328
+ rules: [
329
+ {
330
+ test: /\.css$/,
331
+ use: ['style-loader', 'postcss-loader'],
332
+ },
333
+ {
334
+ test: /\.jsx?$/,
335
+ use: ['babel-loader', 'astroturf/loader'],
336
+ }
337
+ ]
338
+ }
339
+ }
340
+ ```
314
341
 
315
- grunt.registerTask('default', ['postcss:dist']);
316
- };
342
+ Then create `postcss.config.js`:
343
+
344
+ ```js
345
+ module.exports = {
346
+ plugins: [
347
+ require('autoprefixer')
348
+ ]
349
+ }
317
350
  ```
318
351
 
319
- With `grunt-postcss` you also can combine Autoprefixer
320
- with [other PostCSS plugins].
352
+ [`astroturf`]: https://github.com/4Catalyzer/astroturf
321
353
 
322
- [other PostCSS plugins]: https://github.com/postcss/postcss#plugins
323
- [grunt-postcss]: https://github.com/nDmitry/grunt-postcss
354
+
355
+ ### CLI
356
+
357
+ You can use the [postcss-cli] to run Autoprefixer from CLI:
358
+
359
+ ```sh
360
+ npm install postcss-cli autoprefixer
361
+ npx postcss *.css --use autoprefixer -d build/
362
+ ```
363
+
364
+ See `postcss -h` for help.
365
+
366
+ [postcss-cli]: https://github.com/postcss/postcss-cli
324
367
 
325
368
 
326
- ### Other Build Tools:
369
+ ### Other Build Tools
327
370
 
371
+ * **Grunt:** [grunt-postcss]
328
372
  * **Ruby on Rails**: [autoprefixer-rails]
329
373
  * **Neutrino**: [neutrino-middleware-postcss]
330
374
  * **Jekyll**: add `autoprefixer-rails` and `jekyll-assets` to `Gemfile`
@@ -339,9 +383,10 @@ with [other PostCSS plugins].
339
383
  [autoprefixer-rails]: https://github.com/ai/autoprefixer-rails
340
384
  [broccoli-postcss]: https://github.com/jeffjewiss/broccoli-postcss
341
385
  [postcss-brunch]: https://github.com/iamvdo/postcss-brunch
386
+ [grunt-postcss]: https://github.com/nDmitry/grunt-postcss
342
387
 
343
388
 
344
- ### Preprocessors
389
+ #### Preprocessors
345
390
 
346
391
  * **Less**: [less-plugin-autoprefix]
347
392
  * **Stylus**: [autoprefixer-stylus]
@@ -352,42 +397,12 @@ with [other PostCSS plugins].
352
397
  [autoprefixer-rails#compass]: https://github.com/ai/autoprefixer-rails#compass
353
398
 
354
399
 
355
- ### CSS-in-JS
356
-
357
- There is [postcss-js] to use Autoprefixer in React Inline Styles, [Free Style],
358
- Radium and other CSS-in-JS solutions.
359
-
360
- ```js
361
- let prefixer = postcssJs.sync([ autoprefixer ]);
362
- let style = prefixer({
363
- display: 'flex'
364
- });
365
- ```
366
-
367
- [postcss-js]: https://github.com/postcss/postcss-js
368
- [Free Style]: https://github.com/blakeembrey/free-style
369
-
370
-
371
- ### GUI Tools
400
+ #### GUI Tools
372
401
 
373
402
  * [CodeKit](https://codekitapp.com/help/autoprefixer/)
374
403
  * [Prepros](https://prepros.io)
375
404
 
376
405
 
377
- ### CLI
378
-
379
- You can use the [postcss-cli] to run Autoprefixer from CLI:
380
-
381
- ```sh
382
- npm install postcss-cli autoprefixer
383
- npx postcss *.css --use autoprefixer -d build/
384
- ```
385
-
386
- See `postcss -h` for help.
387
-
388
- [postcss-cli]: https://github.com/postcss/postcss-cli
389
-
390
-
391
406
  ### JavaScript
392
407
 
393
408
  You can use Autoprefixer with [PostCSS] in your Node.js application
@@ -478,19 +493,20 @@ If some prefixes were generated incorrectly, please create an [issue on GitHub].
478
493
 
479
494
  ### Features
480
495
 
481
- You can use these plugin options to disable some of Autoprefixer’s features.
496
+ You can use these plugin options to control some of Autoprefixer’s features.
482
497
 
483
- * `grid: true` will enable `-ms-` prefixes for Grid Layout.
498
+ * `grid: "autoplace"` will enable `-ms-` prefixes for Grid Layout including some
499
+ [limited autoplacement support](#grid-autoplacement-support-in-ie).
484
500
  * `supports: false` will disable `@supports` parameters prefixing.
485
501
  * `flexbox: false` will disable flexbox properties prefixing.
486
502
  Or `flexbox: "no-2009"` will add prefixes only for final and IE
487
503
  versions of specification.
488
504
  * `remove: false` will disable cleaning outdated prefixes.
489
505
 
490
- You should set them to the plugin:
506
+ You should set them inside the plugin like so:
491
507
 
492
508
  ```js
493
- autoprefixer({ grid: true });
509
+ autoprefixer({ grid: "autoplace" });
494
510
  ```
495
511
 
496
512
 
@@ -518,10 +534,16 @@ you can use control comments to disable Autoprefixer.
518
534
 
519
535
  There are three types of control comments:
520
536
 
521
- * `/* autoprefixer: off */` disable the whole block *before* and after comment.
522
- * `/* autoprefixer: ignore next */` disable only next property
537
+ * `/* autoprefixer: (on|off) */`: enable/disable all Autoprefixer translations for the
538
+ whole block both *before* and *after* the comment.
539
+ * `/* autoprefixer: ignore next */`: disable Autoprefixer only for the next property
523
540
  or next rule selector or at-rule parameters (but not rule/at‑rule body).
524
- * `/* autoprefixer grid: on */` enable grid option. Use `off` to disable this option.
541
+ * `/* autoprefixer grid: (autoplace|no-autoplace|off) */`: control how Autoprefixer handles
542
+ grid translations for the whole block:
543
+ * `autoplace`: enable grid translations with autoplacement support.
544
+ * `no-autoplace`: enable grid translations with autoplacement support *disabled*.
545
+ (alias for deprecated value `on`)
546
+ * `off`: disable all grid translations.
525
547
 
526
548
  You can also use comments recursively:
527
549
 
@@ -535,6 +557,20 @@ You can also use comments recursively:
535
557
  }
536
558
  ```
537
559
 
560
+ Note that comments that disable the whole block should not be featured in the same
561
+ block twice:
562
+
563
+ ```css
564
+ /* How not to use block level control comments */
565
+
566
+ .do-not-do-this {
567
+ /* autoprefixer: off */
568
+ transition: 1s;
569
+ /* autoprefixer: on */
570
+ transform: rotate(20deg);
571
+ }
572
+ ```
573
+
538
574
 
539
575
  ## Options
540
576
 
@@ -558,9 +594,14 @@ Available options are:
558
594
  * `flexbox` (boolean|string): should Autoprefixer add prefixes for flexbox
559
595
  properties. With `"no-2009"` value Autoprefixer will add prefixes only
560
596
  for final and IE versions of specification. Default is `true`.
561
- * `grid` (boolean): should Autoprefixer add IE prefixes for Grid Layout
562
- properties. Default is `false`. You can also use `/* autoprefixer grid: on */`
563
- comment in CSS.
597
+ * `grid` (false|"autoplace"|"no-autoplace"): should Autoprefixer add IE prefixes for Grid Layout
598
+ properties?
599
+ * `false` (default): prevent Autoprefixer from outputting CSS Grid translations.
600
+ * `"autoplace"`: enable Autoprefixer grid translations and *include* autoplacement
601
+ support. You can also use `/* autoprefixer grid: autoplace */` in your CSS.
602
+ * `"no-autoplace"`: enable Autoprefixer grid translations but *exclude* autoplacement
603
+ support. You can also use `/* autoprefixer grid: no-autoplace */` in your CSS.
604
+ (alias for the deprecated `true` value)
564
605
  * `stats` (object): custom [usage statistics] for `> 10% in my stats`
565
606
  browsers query.
566
607
  * `browsers` (array): list of queries for target browsers. Try to not use it.
@@ -579,6 +620,377 @@ to increase performance.
579
620
  [usage statistics]: https://github.com/ai/browserslist#custom-usage-data
580
621
  [PostCSS API]: http://api.postcss.org
581
622
 
623
+ ## Grid Autoplacement support in IE
624
+
625
+ If the `grid` option is set to `"autoplace"`, limited autoplacement support is added to Autoprefixers grid translations. You can also use the `/* autoprefixer grid: autoplace */` control comment to enable autoplacement
626
+
627
+ Autoprefixer will only autoplace grid cells if both `grid-template-rows` and `grid-template-columns` has been set. If `grid-template` or `grid-template-areas` has been set, Autoprefixer will use area based cell placement instead.
628
+
629
+ Autoprefixer supports autoplacement by using `nth-child` CSS selectors. It creates [number of columns] x [number of rows] `nth-child` selectors. For this reason Autoplacement is only supported within the explicit grid.
630
+
631
+ ```css
632
+ /* Input CSS */
633
+
634
+ /* autoprefixer grid: autoplace */
635
+
636
+ .autoplacement-example {
637
+ display: grid;
638
+ grid-template-columns: 1fr 1fr;
639
+ grid-template-rows: auto auto;
640
+ grid-gap: 20px;
641
+ }
642
+ ```
643
+
644
+ ```css
645
+ /* Output CSS */
646
+
647
+ /* autoprefixer grid: autoplace */
648
+
649
+ .autoplacement-example {
650
+ display: -ms-grid;
651
+ display: grid;
652
+ -ms-grid-columns: 1fr 20px 1fr;
653
+ grid-template-columns: 1fr 1fr;
654
+ -ms-grid-rows: auto 20px auto;
655
+ grid-template-rows: auto auto;
656
+ grid-gap: 20px;
657
+ }
658
+
659
+ .autoplacement-example > *:nth-child(1) {
660
+ -ms-grid-row: 1;
661
+ -ms-grid-column: 1;
662
+ }
663
+
664
+ .autoplacement-example > *:nth-child(2) {
665
+ -ms-grid-row: 1;
666
+ -ms-grid-column: 3;
667
+ }
668
+
669
+ .autoplacement-example > *:nth-child(3) {
670
+ -ms-grid-row: 3;
671
+ -ms-grid-column: 1;
672
+ }
673
+
674
+ .autoplacement-example > *:nth-child(4) {
675
+ -ms-grid-row: 3;
676
+ -ms-grid-column: 3;
677
+ }
678
+ ```
679
+
680
+ ### Beware of enabling autoplacement in old projects
681
+
682
+ Be careful about enabling autoplacement in any already established projects that have
683
+ previously not used Autoprefixer's grid autoplacement feature before.
684
+
685
+ If this was your html:
686
+
687
+ ```html
688
+ <div class="grid">
689
+ <div class="grid-cell"></div>
690
+ </div>
691
+ ```
692
+
693
+ The following CSS will not work as expected with the autoplacement feature enabled:
694
+
695
+ ```css
696
+ /* Unsafe CSS when Autoplacement is enabled */
697
+
698
+ .grid-cell {
699
+ grid-column: 2;
700
+ grid-row: 2;
701
+ }
702
+
703
+ .grid {
704
+ display: grid;
705
+ grid-template-columns: repeat(3, 1fr);
706
+ grid-template-rows: repeat(3, 1fr);
707
+ }
708
+ ```
709
+
710
+ Swapping the rules around will not fix the issue either:
711
+
712
+ ```css
713
+ /* Also unsafe to use this CSS */
714
+
715
+ .grid {
716
+ display: grid;
717
+ grid-template-columns: repeat(3, 1fr);
718
+ grid-template-rows: repeat(3, 1fr);
719
+ }
720
+
721
+ .grid-cell {
722
+ grid-column: 2;
723
+ grid-row: 2;
724
+ }
725
+ ```
726
+
727
+ One way to deal with this issue is to disable autoplacement in the
728
+ grid-declaration rule:
729
+
730
+ ```css
731
+ /* Disable autoplacement to fix the issue */
732
+
733
+ .grid {
734
+ /* autoprefixer grid: no-autoplace */
735
+ display: grid;
736
+ grid-template-columns: repeat(3, 1fr);
737
+ grid-template-rows: repeat(3, 1fr);
738
+ }
739
+
740
+ .grid-cell {
741
+ grid-column: 2;
742
+ grid-row: 2;
743
+ }
744
+ ```
745
+
746
+ The absolute best way to integrate autoplacement into already existing projects though is
747
+ to leave autoplacement turned off by default and then use a control comment to enable it
748
+ when needed. This method is far less likely to cause something on the site to break.
749
+
750
+ ```css
751
+ /* Disable autoplacement by default in old projects */
752
+ /* autoprefixer grid: no-autoplace */
753
+
754
+ /* Old code will function the same way it always has */
755
+ .old-grid {
756
+ display: grid;
757
+ grid-template-columns: repeat(3, 1fr);
758
+ grid-template-rows: repeat(3, 1fr);
759
+ }
760
+ .old-grid-cell {
761
+ grid-column: 2;
762
+ grid-row: 2;
763
+ }
764
+
765
+ /* Enable autoplacement when you want to use it in new code */
766
+ .new-autoplace-friendly-grid {
767
+ /* autoprefixer grid: autoplace */
768
+ display: grid;
769
+ grid-template-columns: repeat(3, 1fr);
770
+ grid-template-rows: repeat(3, auto);
771
+ }
772
+ ```
773
+
774
+ Note that the `grid: "no-autoplace"` setting and the
775
+ `/* autoprefixer grid: no-autoplace */` control comment share identical functionality
776
+ to the `grid: true` setting and the `/* autoprefixer grid: on */` control comment.
777
+ There is no need to refactor old code to use `no-autoplace` in place of the old
778
+ `true` and `on` statements.
779
+
780
+ ### Autoplacement limitations
781
+
782
+ #### Both columns and rows must be defined
783
+
784
+ Autoplacement only works inside the explicit grid. The columns and rows need to be defined
785
+ so that Autoprefixer knows how many `nth-child` selectors to generate.
786
+
787
+ ```css
788
+ .not-allowed {
789
+ display: grid;
790
+ grid-template-columns: repeat(3, 1fr);
791
+ }
792
+
793
+ .is-allowed {
794
+ display: grid;
795
+ grid-template-columns: repeat(3, 1fr);
796
+ grid-template-rows: repeat(10, auto);
797
+ }
798
+ ```
799
+
800
+ #### Repeat auto-fit and auto-fill are not supported
801
+
802
+ The `repeat(auto-fit, ...)` and `repeat(auto-fill, ...)` grid functionality relies on
803
+ knowledge from the browser about screen dimensions and the number of available grid
804
+ items for it to work properly. Autoprefixer does not have access to this information
805
+ so unfortunately this little snippet will _never_ be IE friendly.
806
+
807
+ ```css
808
+ .grid {
809
+ /* This will never be IE friendly */
810
+ grid-template-columns: repeat(auto-fit, min-max(200px, 1fr))
811
+ }
812
+ ```
813
+
814
+ #### No manual cell placement or column/row spans allowed inside an autoplacement grid
815
+
816
+ Elements must not be manually placed or given column/row spans inside an autoplacement
817
+ grid. Only the most basic of autoplacement grids are supported. Grid cells can still be
818
+ placed manually outside the the explicit grid though. Support for manually placing
819
+ individual grid cells inside an explicit autoplacement grid is planned for a
820
+ future release.
821
+
822
+ ```css
823
+ .autoplacement-grid {
824
+ display: grid;
825
+ grid-template-columns: repeat(3, 1fr);
826
+ grid-template-rows: repeat(3, auto);
827
+ }
828
+
829
+ /*
830
+ grid cells placed inside the explicit grid
831
+ will break the layout in IE
832
+ */
833
+ .not-permitted-grid-cell {
834
+ grid-column: 1;
835
+ grid-row: 1;
836
+ }
837
+
838
+ /*
839
+ grid cells placed outside the
840
+ explicit grid will work in IE
841
+ */
842
+ .permitted-grid-cell {
843
+ grid-column: 1 / span 2;
844
+ grid-row: 4;
845
+ }
846
+ ```
847
+
848
+ If manual cell placement is required, we recommend using `grid-template` or
849
+ `grid-template-areas` instead:
850
+
851
+ ```css
852
+ .page {
853
+ display: grid;
854
+ grid-gap: 30px;
855
+ grid-template:
856
+ "head head"
857
+ "nav main" minmax(100px, 1fr)
858
+ "foot foot" /
859
+ 200px 1fr;
860
+ }
861
+ .page__head {
862
+ grid-area: head;
863
+ }
864
+ .page__nav {
865
+ grid-area: nav;
866
+ }
867
+ .page__main {
868
+ grid-area: main;
869
+ }
870
+ .page__footer {
871
+ grid-area: foot;
872
+ }
873
+ ```
874
+
875
+ #### Do not create `::before` and `::after` pseudo elements
876
+
877
+ Let's say you have this HTML:
878
+
879
+ ```html
880
+ <div class="grid">
881
+ <div class="grid-cell"></div>
882
+ </div>
883
+ ```
884
+
885
+ And you write this CSS:
886
+
887
+ ```css
888
+ .grid {
889
+ display: grid;
890
+ grid-template-columns: 1fr 1fr;
891
+ grid-template-rows: auto;
892
+ }
893
+
894
+ .grid::before {
895
+ content: 'before';
896
+ }
897
+
898
+ .grid::after {
899
+ content: 'after';
900
+ }
901
+ ```
902
+
903
+ This will be the output:
904
+
905
+ ```css
906
+ .grid {
907
+ display: -ms-grid;
908
+ display: grid;
909
+ -ms-grid-columns: 1fr 1fr;
910
+ grid-template-columns: 1fr 1fr;
911
+ -ms-grid-rows: auto;
912
+ grid-template-rows: auto;
913
+ }
914
+
915
+ .grid > *:nth-child(1) {
916
+ -ms-grid-row: 1;
917
+ -ms-grid-column: 1;
918
+ }
919
+
920
+
921
+ .grid > *:nth-child(2) {
922
+ -ms-grid-row: 1;
923
+ -ms-grid-column: 2;
924
+ }
925
+
926
+ .grid::before {
927
+ content: 'before';
928
+ }
929
+
930
+ .grid::after {
931
+ content: 'after';
932
+ }
933
+ ```
934
+
935
+ IE will place `.grid-cell`, `::before` and `::after` in row 1 column 1.
936
+ Modern browsers on the other hand will place `::before` in row 1 column 1,
937
+ `.grid-cell` in row 1 column 2, and `::after` in row 2 column 1.
938
+
939
+ See this [Code Pen](https://codepen.io/daniel-tonon/pen/gBymVw) to see a visualization
940
+ of the issue. View the Code Pen in both a modern browser and IE to see the difference.
941
+
942
+ Note that you can still create `::before` and `::after` elements as long as you manually
943
+ place them outside the explicit grid.
944
+
945
+ #### When changing the `grid gap` value, columns and rows must be re-declared
946
+
947
+ If you wish to change the size of a `grid-gap`, you will need to redeclare the grid columns and rows.
948
+
949
+ ```css
950
+ .grid {
951
+ display: grid;
952
+ grid-template-columns: 1fr 1fr;
953
+ grid-template-rows: auto;
954
+ grid-gap: 50px;
955
+ }
956
+
957
+ /* This will *NOT* work in IE */
958
+ @media (max-width: 600px) {
959
+ .grid {
960
+ grid-gap: 20px;
961
+ }
962
+ }
963
+
964
+ /* This will *NOT* work in IE */
965
+ .grid.small-gap {
966
+ grid-gap: 20px;
967
+ }
968
+ ```
969
+
970
+ ```css
971
+ .grid {
972
+ display: grid;
973
+ grid-template-columns: 1fr 1fr;
974
+ grid-template-rows: auto;
975
+ grid-gap: 50px;
976
+ }
977
+
978
+ /* This *WILL* work in IE */
979
+ @media (max-width: 600px) {
980
+ .grid {
981
+ grid-template-columns: 1fr 1fr;
982
+ grid-template-rows: auto;
983
+ grid-gap: 20px;
984
+ }
985
+ }
986
+
987
+ /* This *WILL* work in IE */
988
+ .grid.small-gap {
989
+ grid-template-columns: 1fr 1fr;
990
+ grid-template-rows: auto;
991
+ grid-gap: 20px;
992
+ }
993
+ ```
582
994
 
583
995
  ## Debug
584
996
 
@@ -21,6 +21,16 @@ function (_Declaration) {
21
21
 
22
22
  var _proto = AlignSelf.prototype;
23
23
 
24
+ _proto.check = function check(decl) {
25
+ return decl.parent && decl.parent.every(function (i) {
26
+ return !/^grid-/.test(i.prop);
27
+ });
28
+ };
29
+ /**
30
+ * Change property name for 2012 specs
31
+ */
32
+
33
+
24
34
  _proto.prefixed = function prefixed(prop, prefix) {
25
35
  var spec;
26
36
 
@@ -71,10 +81,6 @@ _defineProperty(AlignSelf, "names", ['align-self', 'flex-item-align']);
71
81
  _defineProperty(AlignSelf, "oldValues", {
72
82
  'flex-end': 'end',
73
83
  'flex-start': 'start'
74
- /**
75
- * Change property name for 2012 specs
76
- */
77
-
78
84
  });
79
85
 
80
86
  module.exports = AlignSelf;
@@ -10,7 +10,12 @@ var Declaration = require('../declaration');
10
10
 
11
11
  var _require = require('./grid-utils'),
12
12
  prefixTrackProp = _require.prefixTrackProp,
13
- prefixTrackValue = _require.prefixTrackValue;
13
+ prefixTrackValue = _require.prefixTrackValue,
14
+ autoplaceGridItems = _require.autoplaceGridItems,
15
+ getGridGap = _require.getGridGap,
16
+ inheritGridGap = _require.inheritGridGap;
17
+
18
+ var Processor = require('../processor');
14
19
 
15
20
  var GridRowsColumns =
16
21
  /*#__PURE__*/
@@ -44,19 +49,96 @@ function (_Declaration) {
44
49
  _proto.normalize = function normalize(prop) {
45
50
  return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
46
51
  };
47
- /**
48
- * Change repeating syntax for IE
49
- */
50
52
 
53
+ _proto.insert = function insert(decl, prefix, prefixes, result) {
54
+ if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
55
+ var parent = decl.parent,
56
+ prop = decl.prop,
57
+ value = decl.value;
58
+ var isRowProp = prop.includes('rows');
59
+ var isColumnProp = prop.includes('columns');
60
+ var hasGridTemplate = parent.some(function (i) {
61
+ return i.prop === 'grid-template' || i.prop === 'grid-template-areas';
62
+ });
63
+ /**
64
+ * Not to prefix rows declaration if grid-template(-areas) is present
65
+ */
66
+
67
+ if (hasGridTemplate && isRowProp) {
68
+ return false;
69
+ }
70
+
71
+ var processor = new Processor({});
72
+ var status = processor.gridStatus(parent, result);
73
+ var gap = getGridGap(decl);
74
+ gap = inheritGridGap(decl, gap) || gap;
75
+ var gapValue = isRowProp ? gap.row : gap.column;
51
76
 
52
- _proto.set = function set(decl, prefix) {
53
- if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
54
- decl.value = prefixTrackValue({
55
- value: decl.value
77
+ if ((status === 'no-autoplace' || status === true) && !hasGridTemplate) {
78
+ gapValue = null;
79
+ }
80
+
81
+ var prefixValue = prefixTrackValue({
82
+ value: value,
83
+ gap: gapValue
84
+ });
85
+ /**
86
+ * Insert prefixes
87
+ */
88
+
89
+ decl.cloneBefore({
90
+ prop: prefixTrackProp({
91
+ prop: prop,
92
+ prefix: prefix
93
+ }),
94
+ value: prefixValue
95
+ });
96
+ var autoflow = parent.nodes.find(function (i) {
97
+ return i.prop === 'grid-auto-flow';
98
+ });
99
+ var autoflowValue = 'row';
100
+
101
+ if (autoflow && !processor.disabled(autoflow, result)) {
102
+ autoflowValue = autoflow.value.trim();
103
+ }
104
+
105
+ if (status === 'autoplace') {
106
+ /**
107
+ * Show warning if grid-template-rows decl is not found
108
+ */
109
+ var rowDecl = parent.nodes.find(function (i) {
110
+ return i.prop === 'grid-template-rows';
56
111
  });
112
+
113
+ if (!rowDecl && hasGridTemplate) {
114
+ return undefined;
115
+ } else if (!rowDecl && !hasGridTemplate) {
116
+ decl.warn(result, "Autoplacement does not work without grid-template-rows property");
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Show warning if grid-template-columns decl is not found
121
+ */
122
+
123
+
124
+ var columnDecl = parent.nodes.find(function (i) {
125
+ return i.prop === 'grid-template-columns';
126
+ });
127
+
128
+ if (!columnDecl && !hasGridTemplate) {
129
+ decl.warn(result, "Autoplacement does not work without grid-template-columns property");
130
+ }
131
+ /**
132
+ * Autoplace grid items
133
+ */
134
+
135
+
136
+ if (isColumnProp && !hasGridTemplate) {
137
+ autoplaceGridItems(decl, result, gap, autoflowValue);
138
+ }
57
139
  }
58
140
 
59
- return _Declaration.prototype.set.call(this, decl, prefix);
141
+ return undefined;
60
142
  };
61
143
 
62
144
  return GridRowsColumns;
@@ -41,78 +41,30 @@ function (_Declaration) {
41
41
  var hasRows = false;
42
42
  var parent = decl.parent;
43
43
  var gap = getGridGap(decl);
44
- var inheritedGap = inheritGridGap(decl, gap); // remove already prefixed rows and columns
45
- // without gutter to prevent doubling prefixes
44
+ gap = inheritGridGap(decl, gap) || gap; // remove already prefixed rows
45
+ // to prevent doubling prefixes
46
46
 
47
- parent.walkDecls(/-ms-grid-(rows|columns)/, function (i) {
47
+ parent.walkDecls(/-ms-grid-rows/, function (i) {
48
48
  return i.remove();
49
- }); // add empty tracks to rows and columns
49
+ }); // add empty tracks to rows
50
50
 
51
51
  parent.walkDecls(/grid-template-(rows|columns)/, function (trackDecl) {
52
52
  if (trackDecl.prop === 'grid-template-rows') {
53
53
  hasRows = true;
54
54
  var prop = trackDecl.prop,
55
55
  value = trackDecl.value;
56
- /**
57
- * we must insert inherited gap values in some cases:
58
- * if we are inside media query && if we have no grid-gap value
59
- */
60
-
61
- if (inheritedGap) {
62
- trackDecl.cloneBefore({
63
- prop: prefixTrackProp({
64
- prop: prop,
65
- prefix: prefix
66
- }),
67
- value: prefixTrackValue({
68
- value: value,
69
- gap: inheritedGap.row
70
- })
71
- });
72
- } else {
73
- trackDecl.cloneBefore({
74
- prop: prefixTrackProp({
75
- prop: prop,
76
- prefix: prefix
77
- }),
78
- value: prefixTrackValue({
79
- value: value,
80
- gap: gap.row
81
- })
82
- });
83
- }
56
+ trackDecl.cloneBefore({
57
+ prop: prefixTrackProp({
58
+ prop: prop,
59
+ prefix: prefix
60
+ }),
61
+ value: prefixTrackValue({
62
+ value: value,
63
+ gap: gap.row
64
+ })
65
+ });
84
66
  } else {
85
67
  hasColumns = true;
86
- var _prop = trackDecl.prop,
87
- _value = trackDecl.value;
88
- /**
89
- * we must insert inherited gap values in some cases:
90
- * if we are inside media query && if we have no grid-gap value
91
- */
92
-
93
- if (inheritedGap) {
94
- trackDecl.cloneBefore({
95
- prop: prefixTrackProp({
96
- prop: _prop,
97
- prefix: prefix
98
- }),
99
- value: prefixTrackValue({
100
- value: _value,
101
- gap: inheritedGap.column
102
- })
103
- });
104
- } else {
105
- trackDecl.cloneBefore({
106
- prop: prefixTrackProp({
107
- prop: _prop,
108
- prefix: prefix
109
- }),
110
- value: prefixTrackValue({
111
- value: _value,
112
- gap: gap.column
113
- })
114
- });
115
- }
116
68
  }
117
69
  });
118
70
  var gridRows = getGridRows(decl.value);
@@ -124,20 +124,36 @@ function transformRepeat(_ref3, _ref4) {
124
124
  count: []
125
125
  }),
126
126
  count = _nodes$reduce.count,
127
- size = _nodes$reduce.size;
127
+ size = _nodes$reduce.size; // insert gap values
128
+
128
129
 
129
130
  if (gap) {
130
- var val = [];
131
+ var _ret = function () {
132
+ size = size.filter(function (i) {
133
+ return i.trim();
134
+ });
135
+ var val = [];
136
+
137
+ var _loop = function _loop(i) {
138
+ size.forEach(function (item, index) {
139
+ if (index > 0 || i > 1) {
140
+ val.push(gap);
141
+ }
131
142
 
132
- for (var i = 1; i <= count; i++) {
133
- if (gap && i > 1) {
134
- val.push(gap);
143
+ val.push(item);
144
+ });
145
+ };
146
+
147
+ for (var i = 1; i <= count; i++) {
148
+ _loop(i);
135
149
  }
136
150
 
137
- val.push(size.join());
138
- }
151
+ return {
152
+ v: val.join(' ')
153
+ };
154
+ }();
139
155
 
140
- return val.join(' ');
156
+ if (typeof _ret === "object") return _ret.v;
141
157
  }
142
158
 
143
159
  return "(" + size.join('') + ")[" + count.join('') + "]";
@@ -779,7 +795,9 @@ function warnIfGridRowColumnExists(decl, result) {
779
795
  var rule = decl.parent;
780
796
  var decls = [];
781
797
  rule.walkDecls(/^grid-(row|column)/, function (d) {
782
- decls.push(d);
798
+ if (!/-end$/.test(d.prop) && !/^span/.test(d.value)) {
799
+ decls.push(d);
800
+ }
783
801
  });
784
802
 
785
803
  if (decls.length > 0) {
@@ -986,6 +1004,129 @@ function warnGridGap(_ref13) {
986
1004
  decl.warn(result, 'Can not impliment grid-gap without grid-tamplate-columns');
987
1005
  }
988
1006
  }
1007
+ /**
1008
+ * normalize the grid-template-rows/columns values
1009
+ * @param {String} str grid-template-rows/columns value
1010
+ * @return {Array} normalized array with values
1011
+ * @example
1012
+ * let normalized = normalizeRowColumn('1fr repeat(2, 20px 50px) 1fr')
1013
+ * normalized // <= ['1fr', '20px', '50px', '20px', '50px', '1fr']
1014
+ */
1015
+
1016
+
1017
+ function normalizeRowColumn(str) {
1018
+ var normalized = parser(str).nodes.reduce(function (result, node) {
1019
+ if (node.type === 'function' && node.value === 'repeat') {
1020
+ var key = 'count';
1021
+
1022
+ var _node$nodes$reduce = node.nodes.reduce(function (acc, n) {
1023
+ if (n.type === 'word' && key === 'count') {
1024
+ acc[0] = Math.abs(parseInt(n.value));
1025
+ return acc;
1026
+ }
1027
+
1028
+ if (n.type === 'div' && n.value === ',') {
1029
+ key = 'value';
1030
+ return acc;
1031
+ }
1032
+
1033
+ if (key === 'value') {
1034
+ acc[1] += parser.stringify(n);
1035
+ }
1036
+
1037
+ return acc;
1038
+ }, [0, '']),
1039
+ count = _node$nodes$reduce[0],
1040
+ value = _node$nodes$reduce[1];
1041
+
1042
+ if (count) {
1043
+ for (var i = 0; i < count; i++) {
1044
+ result.push(value);
1045
+ }
1046
+ }
1047
+
1048
+ return result;
1049
+ }
1050
+
1051
+ if (node.type === 'space') {
1052
+ return result;
1053
+ }
1054
+
1055
+ return result.concat(parser.stringify(node));
1056
+ }, []);
1057
+ return normalized;
1058
+ }
1059
+ /**
1060
+ * Autoplace grid items
1061
+ * @param {Declaration} decl
1062
+ * @param {Result} result
1063
+ * @param {Object} gap gap values
1064
+ * @param {String} autoflowValue grid-auto-flow value
1065
+ * @return {void}
1066
+ * @see https://github.com/postcss/autoprefixer/issues/1148
1067
+ */
1068
+
1069
+
1070
+ function autoplaceGridItems(decl, result, gap, autoflowValue) {
1071
+ if (autoflowValue === void 0) {
1072
+ autoflowValue = 'row';
1073
+ }
1074
+
1075
+ var parent = decl.parent;
1076
+ var rowDecl = parent.nodes.find(function (i) {
1077
+ return i.prop === 'grid-template-rows';
1078
+ });
1079
+ var rows = normalizeRowColumn(rowDecl.value);
1080
+ var columns = normalizeRowColumn(decl.value); // Build array of area names with dummy values. If we have 3 columns and
1081
+ // 2 rows, filledRows will be equal to ['1 2 3', '4 5 6']
1082
+
1083
+ var filledRows = rows.map(function (_, rowIndex) {
1084
+ return Array.from({
1085
+ length: columns.length
1086
+ }, function (v, k) {
1087
+ return k + rowIndex * columns.length + 1;
1088
+ }).join(' ');
1089
+ });
1090
+ var areas = parseGridAreas({
1091
+ rows: filledRows,
1092
+ gap: gap
1093
+ });
1094
+ var keys = Object.keys(areas);
1095
+ var items = keys.map(function (i) {
1096
+ return areas[i];
1097
+ }); // Change the order of cells if grid-auto-flow value is 'column'
1098
+
1099
+ if (autoflowValue.includes('column')) {
1100
+ items = items.sort(function (a, b) {
1101
+ return a.column.start - b.column.start;
1102
+ });
1103
+ } // Insert new rules
1104
+
1105
+
1106
+ items.reverse().forEach(function (item, index) {
1107
+ var column = item.column,
1108
+ row = item.row;
1109
+ var nodeSelector = parent.selectors.map(function (sel) {
1110
+ return sel + (" > *:nth-child(" + (keys.length - index) + ")");
1111
+ }).join(', '); // create new rule
1112
+
1113
+ var node = parent.clone().removeAll(); // change rule selector
1114
+
1115
+ node.selector = nodeSelector; // insert prefixed row/column values
1116
+
1117
+ node.append({
1118
+ prop: '-ms-grid-row',
1119
+ value: row.start
1120
+ });
1121
+ node.append({
1122
+ prop: '-ms-grid-column',
1123
+ value: column.start
1124
+ }); // insert rule
1125
+
1126
+ parent.after(node);
1127
+ });
1128
+ return undefined;
1129
+ }
989
1130
 
990
1131
  module.exports = {
991
1132
  parse: parse,
@@ -1001,5 +1142,6 @@ module.exports = {
1001
1142
  warnGridGap: warnGridGap,
1002
1143
  warnTemplateSelectorNotFound: warnTemplateSelectorNotFound,
1003
1144
  warnIfGridRowColumnExists: warnIfGridRowColumnExists,
1004
- inheritGridGap: inheritGridGap
1145
+ inheritGridGap: inheritGridGap,
1146
+ autoplaceGridItems: autoplaceGridItems
1005
1147
  };
package/lib/processor.js CHANGED
@@ -8,8 +8,25 @@ 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
9
  var RADIAL_BLOCK = /\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/i;
10
10
  var IGNORE_NEXT = /(!\s*)?autoprefixer:\s*ignore\s+next/i;
11
+ var GRID_REGEX = /(!\s*)?autoprefixer\s*grid:\s*(on|off|(no-)?autoplace)/i;
11
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'];
12
13
 
14
+ function hasGridTemplate(decl) {
15
+ return decl.parent.some(function (i) {
16
+ return i.prop === 'grid-template' || i.prop === 'grid-template-areas';
17
+ });
18
+ }
19
+
20
+ function hasRowsAndColumns(decl) {
21
+ var hasRows = decl.parent.some(function (i) {
22
+ return i.prop === 'grid-template-rows';
23
+ });
24
+ var hasColumns = decl.parent.some(function (i) {
25
+ return i.prop === 'grid-template-columns';
26
+ });
27
+ return hasRows && hasColumns;
28
+ }
29
+
13
30
  var Processor =
14
31
  /*#__PURE__*/
15
32
  function () {
@@ -72,6 +89,7 @@ function () {
72
89
  var gridPrefixes = this.gridStatus(css, result) && this.prefixes.add['grid-area'] && this.prefixes.add['grid-area'].prefixes;
73
90
  css.walkDecls(function (decl) {
74
91
  if (_this.disabledDecl(decl, result)) return undefined;
92
+ var parent = decl.parent;
75
93
  var prop = decl.prop;
76
94
  var value = decl.value;
77
95
 
@@ -112,6 +130,18 @@ function () {
112
130
  node: decl
113
131
  });
114
132
  return undefined;
133
+ } else if (decl.prop === 'grid-gap') {
134
+ var status = _this.gridStatus(decl, result);
135
+
136
+ if (status === 'autoplace' && !hasRowsAndColumns(decl) && !hasGridTemplate(decl)) {
137
+ result.warn('grid-gap only works if grid-template(-areas) is being ' + 'used or both rows and columns have been declared ' + 'and cells have not been manually ' + 'placed inside the explicit grid', {
138
+ node: decl
139
+ });
140
+ } else if ((status === true || status === 'no-autoplace') && !hasGridTemplate(decl)) {
141
+ result.warn("grid-gap only works if grid-template(-areas) is being used", {
142
+ node: decl
143
+ });
144
+ }
115
145
  } else if (prop === 'grid-auto-columns') {
116
146
  result.warn('grid-auto-columns is not supported by IE', {
117
147
  node: decl
@@ -123,9 +153,27 @@ function () {
123
153
  });
124
154
  return undefined;
125
155
  } else if (prop === 'grid-auto-flow') {
126
- result.warn('grid-auto-flow is not supported by IE', {
127
- node: decl
156
+ var hasRows = parent.some(function (i) {
157
+ return i.prop === 'grid-template-rows';
158
+ });
159
+ var hasCols = parent.some(function (i) {
160
+ return i.prop === 'grid-template-columns';
128
161
  });
162
+
163
+ if (hasGridTemplate(decl)) {
164
+ result.warn('grid-auto-flow is not supported by IE', {
165
+ node: decl
166
+ });
167
+ } else if (value.includes('dense')) {
168
+ result.warn('grid-auto-flow: dense is not supported by IE', {
169
+ node: decl
170
+ });
171
+ } else if (!hasRows && !hasCols) {
172
+ result.warn('grid-auto-flow works only if grid-template-rows and ' + 'grid-template-columns are present in the same rule', {
173
+ node: decl
174
+ });
175
+ }
176
+
129
177
  return undefined;
130
178
  } else if (value.indexOf('auto-fit') !== -1) {
131
179
  result.warn('auto-fit value is not supported by IE', {
@@ -241,7 +289,7 @@ function () {
241
289
  }); // Insert grid-area prefixes. We need to be able to store the different
242
290
  // rules as a data and hack API is not enough for this
243
291
 
244
- if (this.gridStatus(css, result) === true) {
292
+ if (this.gridStatus(css, result)) {
245
293
  insertAreas(css, this.disabled);
246
294
  } // Values
247
295
 
@@ -580,11 +628,18 @@ function () {
580
628
  node.each(function (i) {
581
629
  if (i.type !== 'comment') return;
582
630
 
583
- if (/(!\s*)?autoprefixer\s*grid:\s*(off|on)/i.test(i.text)) {
631
+ if (GRID_REGEX.test(i.text)) {
632
+ var hasAutoplace = /:\s*autoplace/i.test(i.text);
633
+ var noAutoplace = /no-autoplace/i.test(i.text);
634
+
584
635
  if (typeof status !== 'undefined') {
585
- result.warn('Second Autoprefixer grid control comment ' + 'was ignored. Autoprefixer applies control ' + 'comment to whole block, not to next rules.', {
636
+ result.warn("Second Autoprefixer grid control comment was " + 'ignored. Autoprefixer applies control comments to the whole ' + 'block, not to the next rules.', {
586
637
  node: i
587
638
  });
639
+ } else if (hasAutoplace) {
640
+ status = 'autoplace';
641
+ } else if (noAutoplace) {
642
+ status = true;
588
643
  } else {
589
644
  status = /on/i.test(i.text);
590
645
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoprefixer",
3
- "version": "9.3.0",
3
+ "version": "9.4.2",
4
4
  "description": "Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website",
5
5
  "keywords": ["autoprefixer", "css", "prefix", "postcss", "postcss-plugin"],
6
6
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
@@ -10,11 +10,11 @@
10
10
  "node": ">=6.0.0"
11
11
  },
12
12
  "dependencies": {
13
- "browserslist": "^4.3.2",
14
- "caniuse-lite": "^1.0.30000898",
13
+ "browserslist": "^4.3.5",
14
+ "caniuse-lite": "^1.0.30000914",
15
15
  "normalize-range": "^0.1.2",
16
16
  "num2fraction": "^1.2.2",
17
- "postcss": "^7.0.5",
17
+ "postcss": "^7.0.6",
18
18
  "postcss-value-parser": "^3.3.1"
19
19
  },
20
20
  "bin": {