Cssnano: mergeRules incorrectly merges placeholder selectors

Created on 30 Oct 2017  路  7Comments  路  Source: cssnano/cssnano

For example, consider this CSS file:

input:-ms-input-placeholder {
  font-size: 14px;
}
input::-ms-input-placeholder {
  font-size: 14px;
}

(Note: different numbers of colons)

If you run cssnano against this file with the default preset, you get:

input:-ms-input-placeholder,input::-ms-input-placeholder{font-size:14px}

Unfortunately, this won't work with Internet Explorer. These rules cannot be safely merged. When I disable the mergeRules optimization, this issue is resolved.

This issue may be related to https://github.com/ben-eb/cssnano/issues/297

bug

Most helpful comment

@evilebottnawi I believe it's an issue with IE 10 and IE 11

All 7 comments

@maxlapides That's the same selector twice, did you mean to use two different vendor prefixes?

@chriseppstein The first selector is a pseudo-class (one colon), the second selector is a pseudo-element (two colons).

The reason this issue cropped up for me is I'm running Autoprefixer before cssnano in my webpack workflow. For example, if you go to https://autoprefixer.github.io/ and, with the default browsers filter, enter:

input::placeholder {
  color: pink;
}

Autoprefixer will return:

input::-webkit-input-placeholder {
  color: pink;
}
input::-moz-placeholder {
  color: pink;
}
input:-ms-input-placeholder {
  color: pink;
}
input::-ms-input-placeholder {
  color: pink;
}
input::placeholder {
  color: pink;
}

And then cssnano combines the two ms-input-placeholder selectors, which unfortunately breaks IE support.

@maxlapides ah, I missed that thanks for clarifying.

When I disable the mergeRules optimization

TBH, this should be the default for the current implementation.

Any update on this? I've also had to disable the mergeRules optimisation. It would be great if we could configure this to ignore specified selectors.

@maxlapides which IE versions don't work?

@evilebottnawi I believe it's an issue with IE 10 and IE 11

@maxlapides thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aryaroudi picture aryaroudi  路  3Comments

zhangchao828 picture zhangchao828  路  8Comments

matanarbel-startapp picture matanarbel-startapp  路  6Comments

hudochenkov picture hudochenkov  路  8Comments

PanJiaChen picture PanJiaChen  路  7Comments