question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

placeholder-shown selector should not be merged

See original GitHub issue

CSSO automatically merges blocks with identical properties even when :placeholder-shown, :-ms-input-placeholder, :-moz-placeholder-shown are used as selectors.

Those vendor prefixed selectors are typically generated by autoprefixer (cf https://github.com/postcss/autoprefixer/issues/1311 )

But actually browsers ignores the blocks when a unrecognized selector is present.

Faulty behaviour encountered on

  • chromium 81.0.4044.138 (Official Build) Built on Ubuntu , running on Ubuntu 18.04 (64-bit)
  • mozilla firefox 76.0.1 (64bit) for ubuntu

For example, given two text inputs with different ids

#input1:placeholder-shown {
  background-color: green; /* applied */
}

#input1:-ms-input-placeholder {
  background-color: green;
}

#input2:placeholder-shown, #input2:-ms-input-placeholder {
  background-color: green; /* ignored */
}

related codepen : https://codepen.io/agka/pen/vYNMeBq

Possibly related to #383

Known workaround is to set restructure to false but it kinda defeats the purpose of the optimizer

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lahmatiycommented, Oct 27, 2020

I believe it fixed in https://github.com/css/csso/commit/ba7952c7f457600f3cf7f9c844ea1509ffb89468 and will be shipped in next version.

0reactions
lahmatiycommented, Jan 26, 2022

@agka Thank you for the report, I’ve created an issue – #450

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS :placeholder-shown | SamanthaMing.com
Use this pseudo-class to style an input that is currently displaying the placeholder text -- in other words, the user has not typed...
Read more >
Is there a way to merge the input and its placeholder classes ...
It worths mentioning that you're not actually merging the CSS when SASS is used. SASS is just a preprocessor that allows us to...
Read more >
CSS ::placeholder and :placeholder-shown
Now, why don't we combine two selector :not and :placeholder-shown . So we can target if the input is not empty then we...
Read more >
placeholder-shown pseudo selectors in CSS - YouTube
The ::placeholder pseudo class allows you to style the placeholder text of a form element.The : placeholder - shown pseudo class selects the ......
Read more >
:placeholder-shown - CSS: Cascading Style Sheets | MDN
The :placeholder-shown CSS pseudo-class represents any or element ... When form fields are too small, placeholder text can get cropped in an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found