All contributions

postcss/autoprefixer

Autoprefixer

A PostCSS plugin that adds browser prefixes to CSS based on Can I Use data, including the -ms-grid syntax for CSS Grid layouts.

Language
JavaScript
GitHub stars
22,197
Merged changes
3

What we changed

An inherited grid keeps the gap set with grid-row-gap and grid-column-gap, grid prefixes get the right source in source maps, and a new /* autoprefixer: ignore next warning */ comment hides a warning for one node without turning prefixes off.

What this work shows

  • PostCSS plugins and the CSS tree
  • Source maps
  • CSS Grid and the -ms-grid syntax
  • CSS control comments
What was broken

An inherited grid lost its gap

When a rule inherited grid-template-areas, Autoprefixer looked for the gap only in the grid-gap shorthand. If the container set grid-row-gap and grid-column-gap, the rule got -ms-grid-columns: (1fr)[2] instead of 1fr 50px 1fr, a grid without its gap.

How we fixed it

One rule for both forms

The expression that recognises the shorthand and the longhands moved into a shared constant, and inheritance now applies it the same way getGridGap does. A test case covers a rule that inherits gaps set with the longhands.

#1557

What was broken

Grid prefixes without a source in the map

The -ms-grid-row and -ms-grid-column declarations and the @media rule around them were created without a source field. The source map showed <no source> for them instead of the CSS file they came from.

How we fixed it

The source taken from the original node

Each added declaration now copies the source of the node it was generated from, and the @media rule takes it from the first rule it holds. A test processes three grid cases with a source map and checks that the sources list holds only the input file.

#1559

What was broken

A single warning could not be silenced

A grid with intentionally empty areas raised the Can not find grid areas warning, even though such a layout is valid. The ignore next comment could silence it only by also turning prefixes off for the next property.

How we fixed it

An ignore next warning comment

We added a /* autoprefixer: ignore next warning */ comment that hides warnings only for the next property or rule, while prefixes are still added. Warnings now go through a shared warn function, and the ignore next pattern skips the new comment so it does not switch prefixing off.

#1560

What it taught us

A tool that rewrites CSS must give the same result for shorthand and longhand properties and record every node it adds in the source map. A warning should be possible to silence in one place without switching the tool off for the whole rule.

More about this technology: TypeScript, React and Node

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.