placeholder-shown selector should not be merged
See original GitHub issueCSSO 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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe it fixed in https://github.com/css/csso/commit/ba7952c7f457600f3cf7f9c844ea1509ffb89468 and will be shipped in next version.
@agka Thank you for the report, I’ve created an issue – #450