autoprefixer 10.3.2 → 10.3.6

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/README.md CHANGED
@@ -65,1051 +65,5 @@ Twitter account for news and releases: [@autoprefixer].
65
65
  [cult]: http://cultofmartians.com/tasks/autoprefixer-grid.html
66
66
 
67
67
 
68
- ## Contents
69
-
70
- * [Contents](#contents)
71
- * [Browsers](#browsers)
72
- * [FAQ](#faq)
73
- * [Does Autoprefixer polyfill Grid Layout for IE?](#does-autoprefixer-polyfill-grid-layout-for-ie)
74
- * [Does it add polyfills?](#does-it-add-polyfills)
75
- * [Why doesn’t Autoprefixer add prefixes to `border-radius`?](#why-doesnt-autoprefixer-add-prefixes-to-border-radius)
76
- * [Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?](#why-does-autoprefixer-use-unprefixed-properties-in--webkit-keyframes)
77
- * [How to work with legacy `-webkit-` only code?](#how-to-work-with-legacy--webkit--only-code)
78
- * [Does Autoprefixer add `-epub-` prefix?](#does-autoprefixer-add--epub--prefix)
79
- * [Why doesn’t Autoprefixer transform generic font-family `system-ui`?](#why-doesnt-autoprefixer-transform-generic-font-family-system-ui)
80
- * [Usage](#usage)
81
- * [Gulp](#gulp)
82
- * [Webpack](#webpack)
83
- * [CSS-in-JS](#css-in-js)
84
- * [CLI](#cli)
85
- * [Other Build Tools](#other-build-tools)
86
- * [Preprocessors](#preprocessors)
87
- * [GUI Tools](#gui-tools)
88
- * [JavaScript](#javascript)
89
- * [Text Editors and IDE](#text-editors-and-ide)
90
- * [Warnings](#warnings)
91
- * [Disabling](#disabling)
92
- * [Prefixes](#prefixes)
93
- * [Features](#features)
94
- * [Control Comments](#control-comments)
95
- * [Options](#options)
96
- * [Environment Variables](#environment-variables)
97
- * [Using environment variables to support CSS Grid prefixes in Create React App](#using-environment-variables-to-support-css-grid-prefixes-in-create-react-app)
98
- * [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie)
99
- * [Beware of enabling autoplacement in old projects](#beware-of-enabling-autoplacement-in-old-projects)
100
- * [Autoplacement limitations](#autoplacement-limitations)
101
- * [Both columns and rows must be defined](#both-columns-and-rows-must-be-defined)
102
- * [Repeat auto-fit and auto-fill are not supported](#repeat-auto-fit-and-auto-fill-are-not-supported)
103
- * [No manual cell placement or column/row spans allowed inside an autoplacement grid](#no-manual-cell-placement-or-columnrow-spans-allowed-inside-an-autoplacement-grid)
104
- * [Do not create `::before` and `::after` pseudo elements](#do-not-create-before-and-after-pseudo-elements)
105
- * [When changing the `grid gap` value, columns and rows must be re-declared](#when-changing-the-grid-gap-value-columns-and-rows-must-be-re-declared)
106
- * [Debug](#debug)
107
- * [Security Contact](#security-contact)
108
- * [For Enterprise](#for-enterprise)
109
-
110
- ## Browsers
111
-
112
- Autoprefixer uses [Browserslist], so you can specify the browsers
113
- you want to target in your project with queries like `> 5%`
114
- (see [Best Practices]).
115
-
116
- The best way to provide browsers is a `.browserslistrc` file in your project
117
- root, or by adding a `browserslist` key to your `package.json`.
118
-
119
- We recommend the use of these options over passing options to Autoprefixer so
120
- that the config can be shared with other tools such as [babel-preset-env] and
121
- [Stylelint].
122
-
123
- See [Browserslist docs] for queries, browser names, config format, and defaults.
124
-
125
- [Browserslist docs]: https://github.com/browserslist/browserslist#queries
126
- [babel-preset-env]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
127
- [Best Practices]: https://github.com/browserslist/browserslist#best-practices
128
- [Browserslist]: https://github.com/browserslist/browserslist
129
- [Stylelint]: https://stylelint.io/
130
-
131
-
132
- ## FAQ
133
-
134
- ### Does Autoprefixer polyfill Grid Layout for IE?
135
-
136
- Autoprefixer can be used to translate modern CSS Grid syntax into IE 10
137
- and IE 11 syntax, but this polyfill will not work in 100% of cases.
138
- This is why it is disabled by default.
139
-
140
- First, you need to enable Grid prefixes by using either the `grid: "autoplace"`
141
- option or the `/* autoprefixer grid: autoplace */` control comment.
142
- Also you can use environment variable to enable Grid:
143
- `AUTOPREFIXER_GRID=autoplace npm build`.
144
-
145
- Second, you need to test every fix with Grid in IE. It is not an enable and
146
- forget feature, but it is still very useful.
147
- Financial Times and Yandex use it in production.
148
-
149
- Third, there is only very limited auto placement support. Read the
150
- [Grid Autoplacement support in IE](#grid-autoplacement-support-in-ie) section
151
- for more details.
152
-
153
- Fourth, if you are not using the autoplacement feature, the best way
154
- to use Autoprefixer is by using `grid-template` or `grid-template-areas`.
155
-
156
- ```css
157
- .page {
158
- display: grid;
159
- grid-gap: 33px;
160
- grid-template:
161
- "head head head" 1fr
162
- "nav main main" minmax(100px, 1fr)
163
- "nav foot foot" 2fr /
164
- 1fr 100px 1fr;
165
- }
166
- .page__head {
167
- grid-area: head;
168
- }
169
- .page__nav {
170
- grid-area: nav;
171
- }
172
- .page__main {
173
- grid-area: main;
174
- }
175
- .page__footer {
176
- grid-area: foot;
177
- }
178
- ```
179
-
180
- See also:
181
-
182
- * [The guide about Grids in IE and Autoprefixer].
183
- * [`postcss-gap-properties`] to use new `gap` property
184
- instead of old `grid-gap`.
185
- * [`postcss-grid-kiss`] has alternate “everything in one property” syntax,
186
- which makes using Autoprefixer’s Grid translations safer.
187
-
188
- [The guide about Grids in IE and Autoprefixer]: https://css-tricks.com/css-grid-in-ie-css-grid-and-the-new-autoprefixer/
189
- [`postcss-gap-properties`]: https://github.com/jonathantneal/postcss-gap-properties
190
- [`postcss-grid-kiss`]: https://github.com/sylvainpolletvillard/postcss-grid-kiss
191
-
192
-
193
- ### Does it add polyfills?
194
-
195
- No. Autoprefixer only adds prefixes.
196
-
197
- Most new CSS features will require client side JavaScript to handle a new
198
- behavior correctly.
199
-
200
- Depending on what you consider to be a “polyfill”, you can take a look at some
201
- other tools and libraries. If you are just looking for syntax sugar,
202
- you might take a look at:
203
-
204
- - [postcss-preset-env] is a plugins preset with polyfills and Autoprefixer
205
- to write future CSS today.
206
- - [Oldie], a PostCSS plugin that handles some IE hacks (opacity, rgba, etc).
207
- - [postcss-flexbugs-fixes], a PostCSS plugin to fix flexbox issues.
208
-
209
- [postcss-flexbugs-fixes]: https://github.com/luisrudge/postcss-flexbugs-fixes
210
- [postcss-preset-env]: https://github.com/jonathantneal/postcss-preset-env
211
- [Oldie]: https://github.com/jonathantneal/oldie
212
-
213
-
214
- ### Why doesn’t Autoprefixer add prefixes to `border-radius`?
215
-
216
- Developers are often surprised by how few prefixes are required today.
217
- If Autoprefixer doesn’t add prefixes to your CSS, check if they’re still
218
- required on [Can I Use].
219
-
220
- [Can I Use]: https://caniuse.com/
221
-
222
-
223
- ### Why does Autoprefixer use unprefixed properties in `@-webkit-keyframes`?
224
-
225
- Browser teams can remove some prefixes before others, so we try to use all
226
- combinations of prefixed/unprefixed values.
227
-
228
-
229
- ### How to work with legacy `-webkit-` only code?
230
-
231
- Autoprefixer needs unprefixed property to add prefixes. So if you only
232
- wrote `-webkit-gradient` without W3C’s `gradient`,
233
- Autoprefixer will not add other prefixes.
234
-
235
- But [PostCSS] has plugins to convert CSS to unprefixed state.
236
- Use [postcss-unprefix] before Autoprefixer.
237
-
238
- [postcss-unprefix]: https://github.com/gucong3000/postcss-unprefix
239
-
240
-
241
- ### Does Autoprefixer add `-epub-` prefix?
242
-
243
- No, Autoprefixer works only with browsers prefixes from Can I Use.
244
- But you can use [postcss-epub] for prefixing ePub3 properties.
245
-
246
- [postcss-epub]: https://github.com/Rycochet/postcss-epub
247
-
248
-
249
- ### Why doesn’t Autoprefixer transform generic font-family `system-ui`?
250
-
251
- `system-ui` is technically not a prefix and the transformation is not
252
- future-proof. You can use [postcss-font-family-system-ui] to transform
253
- `system-ui` to a practical font-family list.
254
-
255
- [postcss-font-family-system-ui]: https://github.com/JLHwung/postcss-font-family-system-ui
256
-
257
-
258
- ## Usage
259
-
260
- ### Gulp
261
-
262
- In Gulp you can use [gulp-postcss] with `autoprefixer` npm package.
263
-
264
- ```js
265
- gulp.task('autoprefixer', () => {
266
- const autoprefixer = require('autoprefixer')
267
- const sourcemaps = require('gulp-sourcemaps')
268
- const postcss = require('gulp-postcss')
269
-
270
- return gulp.src('./src/*.css')
271
- .pipe(sourcemaps.init())
272
- .pipe(postcss([ autoprefixer() ]))
273
- .pipe(sourcemaps.write('.'))
274
- .pipe(gulp.dest('./dest'))
275
- })
276
- ```
277
-
278
- With `gulp-postcss` you also can combine Autoprefixer
279
- with [other PostCSS plugins].
280
-
281
- [gulp-postcss]: https://github.com/postcss/gulp-postcss
282
- [other PostCSS plugins]: https://github.com/postcss/postcss#plugins
283
-
284
-
285
- ### Webpack
286
-
287
- In [webpack] you can use [postcss-loader] with `autoprefixer`
288
- and [other PostCSS plugins].
289
-
290
- ```js
291
- module.exports = {
292
- module: {
293
- rules: [
294
- {
295
- test: /\.css$/,
296
- use: ["style-loader", "css-loader", "postcss-loader"]
297
- }
298
- ]
299
- }
300
- }
301
- ```
302
-
303
- And create a `postcss.config.js` with:
304
-
305
- ```js
306
- module.exports = {
307
- plugins: [
308
- require('autoprefixer')
309
- ]
310
- }
311
- ```
312
-
313
- [other PostCSS plugins]: https://github.com/postcss/postcss#plugins
314
- [postcss-loader]: https://github.com/postcss/postcss-loader
315
- [webpack]: https://webpack.js.org/
316
-
317
-
318
- ### CSS-in-JS
319
-
320
- The best way to use PostCSS with CSS-in-JS is [`astroturf`].
321
- Add its loader to your `webpack.config.js`:
322
-
323
- ```js
324
- module.exports = {
325
- module: {
326
- rules: [
327
- {
328
- test: /\.css$/,
329
- use: ['style-loader', 'postcss-loader'],
330
- },
331
- {
332
- test: /\.jsx?$/,
333
- use: ['babel-loader', 'astroturf/loader'],
334
- }
335
- ]
336
- }
337
- }
338
- ```
339
-
340
- Then create `postcss.config.js`:
341
-
342
- ```js
343
- module.exports = {
344
- plugins: [
345
- require('autoprefixer')
346
- ]
347
- }
348
- ```
349
-
350
- [`astroturf`]: https://github.com/4Catalyzer/astroturf
351
-
352
-
353
- ### CLI
354
-
355
- You can use the [postcss-cli] to run Autoprefixer from CLI:
356
-
357
- ```sh
358
- npm install postcss-cli autoprefixer
359
- npx postcss *.css --use autoprefixer -d build/
360
- ```
361
-
362
- See `postcss -h` for help.
363
-
364
- [postcss-cli]: https://github.com/postcss/postcss-cli
365
-
366
-
367
- ### Other Build Tools
368
-
369
- * **Grunt:** [grunt-postcss]
370
- * **Ruby on Rails**: [autoprefixer-rails]
371
- * **Neutrino**: [neutrino-middleware-postcss]
372
- * **Jekyll**: add `autoprefixer-rails` and `jekyll-assets` to `Gemfile`
373
- * **Brunch**: [postcss-brunch]
374
- * **Broccoli**: [broccoli-postcss]
375
- * **Middleman**: [middleman-autoprefixer]
376
- * **Mincer**: add `autoprefixer` npm package and enable it:
377
- `environment.enable('autoprefixer')`
378
-
379
- [neutrino-middleware-postcss]: https://www.npmjs.com/package/neutrino-middleware-postcss
380
- [middleman-autoprefixer]: https://github.com/middleman/middleman-autoprefixer
381
- [autoprefixer-rails]: https://github.com/ai/autoprefixer-rails
382
- [broccoli-postcss]: https://github.com/jeffjewiss/broccoli-postcss
383
- [postcss-brunch]: https://github.com/iamvdo/postcss-brunch
384
- [grunt-postcss]: https://github.com/C-Lodder/grunt-postcss
385
-
386
-
387
- #### Preprocessors
388
-
389
- * **Less**: [less-plugin-autoprefix]
390
- * **Stylus**: [autoprefixer-stylus]
391
- * **Compass**: [autoprefixer-rails#compass]
392
-
393
- [less-plugin-autoprefix]: https://github.com/less/less-plugin-autoprefix
394
- [autoprefixer-stylus]: https://github.com/jenius/autoprefixer-stylus
395
- [autoprefixer-rails#compass]: https://github.com/ai/autoprefixer-rails#compass
396
-
397
-
398
- #### GUI Tools
399
-
400
- * [CodeKit](https://codekitapp.com/help/autoprefixer/)
401
- * [Prepros](https://prepros.io)
402
-
403
-
404
- ### JavaScript
405
-
406
- You can use Autoprefixer with [PostCSS] in your Node.js application
407
- or if you want to develop an Autoprefixer plugin for a new environment.
408
-
409
- ```js
410
- const autoprefixer = require('autoprefixer')
411
- const postcss = require('postcss')
412
-
413
- postcss([ autoprefixer ]).process(css).then(result => {
414
- result.warnings().forEach(warn => {
415
- console.warn(warn.toString())
416
- })
417
- console.log(result.css)
418
- })
419
- ```
420
-
421
- There is also a [standalone build] for the browser or for a non-Node.js runtime.
422
-
423
- You can use [html-autoprefixer] to process HTML with inlined CSS.
424
-
425
- [html-autoprefixer]: https://github.com/RebelMail/html-autoprefixer
426
- [standalone build]: https://raw.github.com/ai/autoprefixer-rails/master/vendor/autoprefixer.js
427
- [PostCSS]: https://github.com/postcss/postcss
428
-
429
-
430
- ### Text Editors and IDE
431
-
432
- Autoprefixer should be used in assets build tools. Text editor plugins are not
433
- a good solution, because prefixes decrease code readability and you will need
434
- to change values in all prefixed properties.
435
-
436
- I recommend you to learn how to use build tools like [Parcel].
437
- They work much better and will open you a whole new world of useful plugins
438
- and automation.
439
-
440
- If you can’t move to a build tool, you can use text editor plugins:
441
-
442
- * [Visual Studio Code](https://github.com/mrmlnc/vscode-autoprefixer)
443
- * [Atom Editor](https://github.com/sindresorhus/atom-autoprefixer)
444
- * [Sublime Text](https://github.com/sindresorhus/sublime-autoprefixer)
445
- * [Brackets](https://github.com/mikaeljorhult/brackets-autoprefixer)
446
-
447
- [Parcel]: https://parceljs.org/
448
-
449
-
450
- ## Warnings
451
-
452
- Autoprefixer uses the [PostCSS warning API] to warn about really important
453
- problems in your CSS:
454
-
455
- * Old direction syntax in gradients.
456
- * Old unprefixed `display: box` instead of `display: flex`
457
- by latest specification version.
458
-
459
- You can get warnings from `result.warnings()`:
460
-
461
- ```js
462
- result.warnings().forEach(warn => {
463
- console.warn(warn.toString())
464
- })
465
- ```
466
-
467
- Every Autoprefixer runner should display these warnings.
468
-
469
- [PostCSS warning API]: http://api.postcss.org/Warning.html
470
-
471
-
472
- ## Disabling
473
-
474
- ### Prefixes
475
-
476
- Autoprefixer was designed to have no interface – it just works.
477
- If you need some browser specific hack just write a prefixed property
478
- after the unprefixed one.
479
-
480
- ```css
481
- a {
482
- transform: scale(0.5);
483
- -moz-transform: scale(0.6);
484
- }
485
- ```
486
-
487
- If some prefixes were generated incorrectly, please create an [issue on GitHub].
488
-
489
- [issue on GitHub]: https://github.com/postcss/autoprefixer/issues
490
-
491
-
492
- ### Features
493
-
494
- You can use these plugin options to control some of Autoprefixer’s features.
495
-
496
- * `grid: "autoplace"` will enable `-ms-` prefixes for Grid Layout including some
497
- [limited autoplacement support](#grid-autoplacement-support-in-ie).
498
- * `supports: false` will disable `@supports` parameters prefixing.
499
- * `flexbox: false` will disable flexbox properties prefixing.
500
- Or `flexbox: "no-2009"` will add prefixes only for final and IE
501
- versions of specification.
502
- * `remove: false` will disable cleaning outdated prefixes.
503
-
504
- You should set them inside the plugin like so:
505
-
506
- ```js
507
- autoprefixer({ grid: 'autoplace' })
508
- ```
509
-
510
-
511
- ### Control Comments
512
-
513
- If you do not need Autoprefixer in some part of your CSS,
514
- you can use control comments to disable Autoprefixer.
515
-
516
- ```css
517
- .a {
518
- transition: 1s; /* will be prefixed */
519
- }
520
-
521
- .b {
522
- /* autoprefixer: off */
523
- transition: 1s; /* will not be prefixed */
524
- }
525
-
526
- .c {
527
- /* autoprefixer: ignore next */
528
- transition: 1s; /* will not be prefixed */
529
- mask: url(image.png); /* will be prefixed */
530
- }
531
- ```
532
-
533
- There are three types of control comments:
534
-
535
- * `/* autoprefixer: (on|off) */`: enable/disable all Autoprefixer translations for the
536
- whole block both *before* and *after* the comment.
537
- * `/* autoprefixer: ignore next */`: disable Autoprefixer only for the next property
538
- or next rule selector or at-rule parameters (but not rule/at‑rule body).
539
- * `/* autoprefixer grid: (autoplace|no-autoplace|off) */`: control how Autoprefixer handles
540
- grid translations for the whole block:
541
- * `autoplace`: enable grid translations with autoplacement support.
542
- * `no-autoplace`: enable grid translations with autoplacement
543
- support *disabled* (alias for deprecated value `on`).
544
- * `off`: disable all grid translations.
545
-
546
- You can also use comments recursively:
547
-
548
- ```css
549
- /* autoprefixer: off */
550
- @supports (transition: all) {
551
- /* autoprefixer: on */
552
- a {
553
- /* autoprefixer: off */
554
- }
555
- }
556
- ```
557
-
558
- Note that comments that disable the whole block should not be featured in the same
559
- block twice:
560
-
561
- ```css
562
- /* How not to use block level control comments */
563
-
564
- .do-not-do-this {
565
- /* autoprefixer: off */
566
- transition: 1s;
567
- /* autoprefixer: on */
568
- transform: rotate(20deg);
569
- }
570
- ```
571
-
572
-
573
- ## Options
574
-
575
- Function `autoprefixer(options)` returns a new PostCSS plugin.
576
- See [PostCSS API] for plugin usage documentation.
577
-
578
- ```js
579
- autoprefixer({ cascade: false })
580
- ```
581
-
582
- Available options are:
583
-
584
- * `env` (string): environment for Browserslist.
585
- * `cascade` (boolean): should Autoprefixer use Visual Cascade,
586
- if CSS is uncompressed. Default: `true`
587
- * `add` (boolean): should Autoprefixer add prefixes. Default is `true`.
588
- * `remove` (boolean): should Autoprefixer [remove outdated] prefixes.
589
- Default is `true`.
590
- * `supports` (boolean): should Autoprefixer add prefixes for `@supports`
591
- parameters. Default is `true`.
592
- * `flexbox` (boolean|string): should Autoprefixer add prefixes for flexbox
593
- properties. With `"no-2009"` value Autoprefixer will add prefixes only
594
- for final and IE 10 versions of specification. Default is `true`.
595
- * `grid` (false|`"autoplace"`|`"no-autoplace"`): should Autoprefixer
596
- add IE 10-11 prefixes for Grid Layout properties?
597
- * `false` (default): prevent Autoprefixer from outputting
598
- CSS Grid translations.
599
- * `"autoplace"`: enable Autoprefixer grid translations
600
- and *include* autoplacement support. You can also use
601
- `/* autoprefixer grid: autoplace */` in your CSS.
602
- * `"no-autoplace"`: enable Autoprefixer grid translations
603
- but *exclude* autoplacement support. You can also use
604
- `/* autoprefixer grid: no-autoplace */` in your CSS.
605
- (alias for the deprecated `true` value)
606
- * `stats` (object): custom [usage statistics] for `> 10% in my stats`
607
- browsers query.
608
- * `overrideBrowserslist` (array): list of queries for target browsers.
609
- Try to not use it. The best practice is to use `.browserslistrc` config
610
- or `browserslist` key in `package.json` to share target browsers
611
- with Babel, ESLint and Stylelint. See [Browserslist docs]
612
- for available queries and default value.
613
- * `ignoreUnknownVersions` (boolean): do not raise error on unknown browser
614
- version in Browserslist config. Default is `false`.
615
-
616
- Plugin object has `info()` method for debugging purpose.
617
-
618
- You can use PostCSS processor to process several CSS files
619
- to increase performance.
620
-
621
- [usage statistics]: https://github.com/browserslist/browserslist#custom-usage-data
622
- [PostCSS API]: http://api.postcss.org
623
-
624
- ## Environment Variables
625
-
626
- * `AUTOPREFIXER_GRID`: (`autoplace`|`no-autoplace`) should Autoprefixer
627
- add IE 10-11 prefixes for Grid Layout properties?
628
- * `autoplace`: enable Autoprefixer grid translations
629
- and *include* autoplacement support.
630
- * `no-autoplace`: enable Autoprefixer grid translations
631
- but *exclude* autoplacement support.
632
-
633
- Environment variables are useful, when you want to change Autoprefixer options but don't have access to config files.
634
- [Create React App] is a good example of this.
635
-
636
- [Create React App]: (https://reactjs.org/docs/create-a-new-react-app.html#create-react-app)
637
-
638
- ### Using environment variables to support CSS Grid prefixes in Create React App
639
-
640
- 1. Install the latest version of Autoprefixer and [cross-env](https://www.npmjs.com/package/cross-env):
641
-
642
- ```
643
- npm install autoprefixer@latest cross-env --save-dev
644
- ```
645
-
646
- 2. Under `"browserslist"` > `"development"` in the package.json file, add `"last 1 ie version"`
647
-
648
- ```
649
- "browserslist": {
650
- "production": [
651
- ">0.2%",
652
- "not dead",
653
- "not op_mini all"
654
- ],
655
- "development": [
656
- "last 1 chrome version",
657
- "last 1 firefox version",
658
- "last 1 safari version",
659
- "last 1 ie version"
660
- ]
661
- }
662
- ```
663
-
664
- 3. Update `"scripts"` in the package.json file to the following:
665
-
666
- ```
667
- "scripts": {
668
- "start": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts start",
669
- "build": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts build",
670
- "test": "cross-env AUTOPREFIXER_GRID=autoplace react-scripts test",
671
- "eject": "react-scripts eject"
672
- },
673
- ```
674
-
675
- Replace `autoplace` with `no-autoplace` in the above example if you prefer to disable Autoprefixer Grid autoplacement support.
676
-
677
- Now when you run `npm start` you will see CSS Grid prefixes automatically being applied to your output CSS.
678
-
679
- See also [Browserslist environment variables] for more examples on how to use environment variables in your project.
680
-
681
- [Browserslist environment variables]: https://github.com/browserslist/browserslist#environment-variables
682
-
683
- ## Grid Autoplacement support in IE
684
-
685
- If the `grid` option is set to `"autoplace"`, limited autoplacement support is added to Autoprefixers grid translations. You can also use
686
- the `/* autoprefixer grid: autoplace */` control comment or
687
- `AUTOPREFIXER_GRID=autoplace npm build` environment variable.
688
-
689
- Autoprefixer will only autoplace grid cells if both `grid-template-rows`
690
- and `grid-template-columns` has been set. If `grid-template`
691
- or `grid-template-areas` has been set, Autoprefixer will use area based
692
- cell placement instead.
693
-
694
- Autoprefixer supports autoplacement by using `nth-child` CSS selectors.
695
- It creates [number of columns] x [number of rows] `nth-child` selectors.
696
- For this reason Autoplacement is only supported within the explicit grid.
697
-
698
- ```css
699
- /* Input CSS */
700
-
701
- /* autoprefixer grid: autoplace */
702
-
703
- .autoplacement-example {
704
- display: grid;
705
- grid-template-columns: 1fr 1fr;
706
- grid-template-rows: auto auto;
707
- grid-gap: 20px;
708
- }
709
- ```
710
-
711
- ```css
712
- /* Output CSS */
713
-
714
- /* autoprefixer grid: autoplace */
715
-
716
- .autoplacement-example {
717
- display: -ms-grid;
718
- display: grid;
719
- -ms-grid-columns: 1fr 20px 1fr;
720
- grid-template-columns: 1fr 1fr;
721
- -ms-grid-rows: auto 20px auto;
722
- grid-template-rows: auto auto;
723
- grid-gap: 20px;
724
- }
725
-
726
- .autoplacement-example > *:nth-child(1) {
727
- -ms-grid-row: 1;
728
- -ms-grid-column: 1;
729
- }
730
-
731
- .autoplacement-example > *:nth-child(2) {
732
- -ms-grid-row: 1;
733
- -ms-grid-column: 3;
734
- }
735
-
736
- .autoplacement-example > *:nth-child(3) {
737
- -ms-grid-row: 3;
738
- -ms-grid-column: 1;
739
- }
740
-
741
- .autoplacement-example > *:nth-child(4) {
742
- -ms-grid-row: 3;
743
- -ms-grid-column: 3;
744
- }
745
- ```
746
-
747
- ### Beware of enabling autoplacement in old projects
748
-
749
- Be careful about enabling autoplacement in any already established projects that have
750
- previously not used Autoprefixer's grid autoplacement feature before.
751
-
752
- If this was your html:
753
-
754
- ```html
755
- <div class="grid">
756
- <div class="grid-cell"></div>
757
- </div>
758
- ```
759
-
760
- The following CSS will not work as expected with the autoplacement feature enabled:
761
-
762
- ```css
763
- /* Unsafe CSS when Autoplacement is enabled */
764
-
765
- .grid-cell {
766
- grid-column: 2;
767
- grid-row: 2;
768
- }
769
-
770
- .grid {
771
- display: grid;
772
- grid-template-columns: repeat(3, 1fr);
773
- grid-template-rows: repeat(3, 1fr);
774
- }
775
- ```
776
-
777
- Swapping the rules around will not fix the issue either:
778
-
779
- ```css
780
- /* Also unsafe to use this CSS */
781
-
782
- .grid {
783
- display: grid;
784
- grid-template-columns: repeat(3, 1fr);
785
- grid-template-rows: repeat(3, 1fr);
786
- }
787
-
788
- .grid-cell {
789
- grid-column: 2;
790
- grid-row: 2;
791
- }
792
- ```
793
-
794
- One way to deal with this issue is to disable autoplacement in the
795
- grid-declaration rule:
796
-
797
- ```css
798
- /* Disable autoplacement to fix the issue */
799
-
800
- .grid {
801
- /* autoprefixer grid: no-autoplace */
802
- display: grid;
803
- grid-template-columns: repeat(3, 1fr);
804
- grid-template-rows: repeat(3, 1fr);
805
- }
806
-
807
- .grid-cell {
808
- grid-column: 2;
809
- grid-row: 2;
810
- }
811
- ```
812
-
813
- The absolute best way to integrate autoplacement into already existing projects
814
- though is to leave autoplacement turned off by default and then use a control
815
- comment to enable it when needed. This method is far less likely to cause
816
- something on the site to break.
817
-
818
- ```css
819
- /* Disable autoplacement by default in old projects */
820
- /* autoprefixer grid: no-autoplace */
821
-
822
- /* Old code will function the same way it always has */
823
- .old-grid {
824
- display: grid;
825
- grid-template-columns: repeat(3, 1fr);
826
- grid-template-rows: repeat(3, 1fr);
827
- }
828
- .old-grid-cell {
829
- grid-column: 2;
830
- grid-row: 2;
831
- }
832
-
833
- /* Enable autoplacement when you want to use it in new code */
834
- .new-autoplace-friendly-grid {
835
- /* autoprefixer grid: autoplace */
836
- display: grid;
837
- grid-template-columns: repeat(3, 1fr);
838
- grid-template-rows: repeat(3, auto);
839
- }
840
- ```
841
-
842
- Note that the `grid: "no-autoplace"` setting and the
843
- `/* autoprefixer grid: no-autoplace */` control comment share identical
844
- functionality to the `grid: true` setting and the `/* autoprefixer grid: on */`
845
- control comment. There is no need to refactor old code to use `no-autoplace`
846
- in place of the old `true` and `on` statements.
847
-
848
- ### Autoplacement limitations
849
-
850
- #### Both columns and rows must be defined
851
-
852
- Autoplacement only works inside the explicit grid. The columns and rows need to be defined
853
- so that Autoprefixer knows how many `nth-child` selectors to generate.
854
-
855
- ```css
856
- .not-allowed {
857
- display: grid;
858
- grid-template-columns: repeat(3, 1fr);
859
- }
860
-
861
- .is-allowed {
862
- display: grid;
863
- grid-template-columns: repeat(3, 1fr);
864
- grid-template-rows: repeat(10, auto);
865
- }
866
- ```
867
-
868
- #### Repeat auto-fit and auto-fill are not supported
869
-
870
- The `repeat(auto-fit, ...)` and `repeat(auto-fill, ...)` grid functionality relies on
871
- knowledge from the browser about screen dimensions and the number of available grid
872
- items for it to work properly. Autoprefixer does not have access to this information
873
- so unfortunately this little snippet will _never_ be IE friendly.
874
-
875
- ```css
876
- .grid {
877
- /* This will never be IE friendly */
878
- grid-template-columns: repeat(auto-fit, min-max(200px, 1fr))
879
- }
880
- ```
881
-
882
- #### No manual cell placement or column/row spans allowed inside an autoplacement grid
883
-
884
- Elements must not be manually placed or given column/row spans inside
885
- an autoplacement grid. Only the most basic of autoplacement grids are supported.
886
- Grid cells can still be placed manually outside the the explicit grid though.
887
- Support for manually placing individual grid cells inside an explicit
888
- autoplacement grid is planned for a future release.
889
-
890
- ```css
891
- .autoplacement-grid {
892
- display: grid;
893
- grid-template-columns: repeat(3, 1fr);
894
- grid-template-rows: repeat(3, auto);
895
- }
896
-
897
- /* Grid cells placed inside the explicit grid
898
- will break the layout in IE */
899
- .not-permitted-grid-cell {
900
- grid-column: 1;
901
- grid-row: 1;
902
- }
903
-
904
- /* Grid cells placed outside the
905
- explicit grid will work in IE */
906
- .permitted-grid-cell {
907
- grid-column: 1 / span 2;
908
- grid-row: 4;
909
- }
910
- ```
911
-
912
- If manual cell placement is required, we recommend using `grid-template` or
913
- `grid-template-areas` instead:
914
-
915
- ```css
916
- .page {
917
- display: grid;
918
- grid-gap: 30px;
919
- grid-template:
920
- "head head"
921
- "nav main" minmax(100px, 1fr)
922
- "foot foot" /
923
- 200px 1fr;
924
- }
925
- .page__head {
926
- grid-area: head;
927
- }
928
- .page__nav {
929
- grid-area: nav;
930
- }
931
- .page__main {
932
- grid-area: main;
933
- }
934
- .page__footer {
935
- grid-area: foot;
936
- }
937
- ```
938
-
939
- #### Do not create `::before` and `::after` pseudo elements
940
-
941
- Let's say you have this HTML:
942
-
943
- ```html
944
- <div class="grid">
945
- <div class="grid-cell"></div>
946
- </div>
947
- ```
948
-
949
- And you write this CSS:
950
-
951
- ```css
952
- .grid {
953
- display: grid;
954
- grid-template-columns: 1fr 1fr;
955
- grid-template-rows: auto;
956
- }
957
-
958
- .grid::before {
959
- content: 'before';
960
- }
961
-
962
- .grid::after {
963
- content: 'after';
964
- }
965
- ```
966
-
967
- This will be the output:
968
-
969
- ```css
970
- .grid {
971
- display: -ms-grid;
972
- display: grid;
973
- -ms-grid-columns: 1fr 1fr;
974
- grid-template-columns: 1fr 1fr;
975
- -ms-grid-rows: auto;
976
- grid-template-rows: auto;
977
- }
978
-
979
- .grid > *:nth-child(1) {
980
- -ms-grid-row: 1;
981
- -ms-grid-column: 1;
982
- }
983
-
984
-
985
- .grid > *:nth-child(2) {
986
- -ms-grid-row: 1;
987
- -ms-grid-column: 2;
988
- }
989
-
990
- .grid::before {
991
- content: 'before';
992
- }
993
-
994
- .grid::after {
995
- content: 'after';
996
- }
997
- ```
998
-
999
- IE will place `.grid-cell`, `::before` and `::after` in row 1 column 1.
1000
- Modern browsers on the other hand will place `::before` in row 1 column 1,
1001
- `.grid-cell` in row 1 column 2, and `::after` in row 2 column 1.
1002
-
1003
- See this [CodePen](https://codepen.io/daniel-tonon/pen/gBymVw) to see a visualization
1004
- of the issue. View the CodePen in both a modern browser and IE to see the difference.
1005
-
1006
- Note that you can still create `::before` and `::after` elements as long as you manually
1007
- place them outside the explicit grid.
1008
-
1009
- #### When changing the `grid gap` value, columns and rows must be re-declared
1010
-
1011
- If you wish to change the size of a `grid-gap`, you will need to redeclare the grid columns and rows.
1012
-
1013
- ```css
1014
- .grid {
1015
- display: grid;
1016
- grid-template-columns: 1fr 1fr;
1017
- grid-template-rows: auto;
1018
- grid-gap: 50px;
1019
- }
1020
-
1021
- /* This will *NOT* work in IE */
1022
- @media (max-width: 600px) {
1023
- .grid {
1024
- grid-gap: 20px;
1025
- }
1026
- }
1027
-
1028
- /* This will *NOT* work in IE */
1029
- .grid.small-gap {
1030
- grid-gap: 20px;
1031
- }
1032
- ```
1033
-
1034
- ```css
1035
- .grid {
1036
- display: grid;
1037
- grid-template-columns: 1fr 1fr;
1038
- grid-template-rows: auto;
1039
- grid-gap: 50px;
1040
- }
1041
-
1042
- /* This *WILL* work in IE */
1043
- @media (max-width: 600px) {
1044
- .grid {
1045
- grid-template-columns: 1fr 1fr;
1046
- grid-template-rows: auto;
1047
- grid-gap: 20px;
1048
- }
1049
- }
1050
-
1051
- /* This *WILL* work in IE */
1052
- .grid.small-gap {
1053
- grid-template-columns: 1fr 1fr;
1054
- grid-template-rows: auto;
1055
- grid-gap: 20px;
1056
- }
1057
- ```
1058
-
1059
- ## Debug
1060
-
1061
- Run `npx autoprefixer --info` in your project directory to check
1062
- which browsers are selected and which properties will be prefixed:
1063
-
1064
- ```console
1065
- $ npx autoprefixer --info
1066
- Browsers:
1067
- Edge: 16
1068
-
1069
- These browsers account for 0.26% of all users globally
1070
-
1071
- At-Rules:
1072
- @viewport: ms
1073
-
1074
- Selectors:
1075
- ::placeholder: ms
1076
-
1077
- Properties:
1078
- appearance: webkit
1079
- flow-from: ms
1080
- flow-into: ms
1081
- hyphens: ms
1082
- overscroll-behavior: ms
1083
- region-fragment: ms
1084
- scroll-snap-coordinate: ms
1085
- scroll-snap-destination: ms
1086
- scroll-snap-points-x: ms
1087
- scroll-snap-points-y: ms
1088
- scroll-snap-type: ms
1089
- text-size-adjust: ms
1090
- text-spacing: ms
1091
- user-select: ms
1092
- ```
1093
-
1094
- JS API is also available:
1095
-
1096
- ```js
1097
- console.log(autoprefixer().info())
1098
- ```
1099
-
1100
- ## Security Contact
1101
-
1102
- To report a security vulnerability, please use the [Tidelift security contact].
1103
- Tidelift will coordinate the fix and disclosure.
1104
-
1105
- [Tidelift security contact]: https://tidelift.com/security
1106
-
1107
- ## For Enterprise
1108
-
1109
- Available as part of the Tidelift Subscription.
1110
-
1111
- The maintainers of `autoprefixer` and thousands of other packages are working
1112
- with Tidelift to deliver commercial support and maintenance for the open source
1113
- dependencies you use to build your applications. Save time, reduce risk,
1114
- and improve code health, while paying the maintainers of the exact dependencies
1115
- you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-autoprefixer?utm_source=npm-autoprefixer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
68
+ ## Docs
69
+ Read **[full docs](https://github.com/postcss/autoprefixer#readme)** on GitHub.
package/data/prefixes.js CHANGED
@@ -583,7 +583,15 @@ f(prefixIntrinsic, browsers =>
583
583
  )
584
584
 
585
585
  f(prefixIntrinsic, { match: /x|\s#4/ }, browsers =>
586
- prefix(['fill', 'fill-available', 'stretch'], {
586
+ prefix(['fill', 'fill-available'], {
587
+ props: sizeProps,
588
+ feature: 'intrinsic-width',
589
+ browsers
590
+ })
591
+ )
592
+
593
+ f(prefixIntrinsic, { match: /x|\s#5/ }, browsers =>
594
+ prefix(['stretch'], {
587
595
  props: sizeProps,
588
596
  feature: 'intrinsic-width',
589
597
  browsers
@@ -1,6 +1,6 @@
1
+ let { yellow, red } = require('nanocolors')
1
2
  let browserslist = require('browserslist')
2
3
  let { agents } = require('caniuse-lite')
3
- let colorette = require('colorette')
4
4
 
5
5
  let Browsers = require('./browsers')
6
6
  let Prefixes = require('./prefixes')
@@ -89,15 +89,9 @@ function plugin(...reqs) {
89
89
  reqs = options.overrideBrowserslist
90
90
  } else if (options.browsers) {
91
91
  if (typeof console !== 'undefined' && console.warn) {
92
- if (colorette.red) {
93
- console.warn(
94
- colorette.red(
95
- WARNING.replace(/`[^`]+`/g, i => colorette.yellow(i.slice(1, -1)))
96
- )
97
- )
98
- } else {
99
- console.warn(WARNING)
100
- }
92
+ console.warn(
93
+ red(WARNING.replace(/`[^`]+`/g, i => yellow(i.slice(1, -1))))
94
+ )
101
95
  }
102
96
  reqs = options.browsers
103
97
  }
@@ -1,6 +1,19 @@
1
1
  let Selector = require('../selector')
2
+ let utils = require('../utils')
2
3
 
3
4
  class FileSelectorButton extends Selector {
5
+ constructor(name, prefixes, all) {
6
+ super(name, prefixes, all)
7
+
8
+ if (this.prefixes) {
9
+ this.prefixes = utils.uniq(
10
+ this.prefixes.map(i => {
11
+ return '-webkit-'
12
+ })
13
+ )
14
+ }
15
+ }
16
+
4
17
  /**
5
18
  * Return different selectors depend on prefix
6
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoprefixer",
3
- "version": "10.3.2",
3
+ "version": "10.3.6",
4
4
  "description": "Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"
@@ -26,15 +26,11 @@
26
26
  "postcss": "^8.1.0"
27
27
  },
28
28
  "dependencies": {
29
- "browserslist": "^4.16.8",
30
- "caniuse-lite": "^1.0.30001251",
31
- "colorette": "^1.3.0",
29
+ "browserslist": "^4.17.1",
30
+ "caniuse-lite": "^1.0.30001260",
32
31
  "fraction.js": "^4.1.1",
32
+ "nanocolors": "^0.2.8",
33
33
  "normalize-range": "^0.1.2",
34
34
  "postcss-value-parser": "^4.1.0"
35
- },
36
- "browser": {
37
- "colorette": false,
38
- "chalk": false
39
35
  }
40
36
  }