autoprefixer
autoprefixer copied to clipboard
Shouldn't supports: false disable prefixing inside @supports block?
Browserslist config
"browserslist": [
"last 2 versions",
"not < 1%",
"last 2 edge versions",
"not ie < 11"
],
postcss.config.js
module.exports = {
plugins: {
autoprefixer: {
supports: false,
},
'postcss-import': {},
'postcss-custom-properties': {
preserve: false,
},
'postcss-custom-media': {
preserve: false,
},
},
};
Input CSS
@supports (position: sticky) {
.search-results {
position: sticky;
top: 0;
}
}
Output CSS
@supports (position: sticky) {
.search-results {
position: -webkit-sticky;
position: sticky;
top: 0;
}
}
Expected output CSS
@supports (position: sticky) {
.search-results {
position: sticky;
top: 0;
}
}
Given the configuration option, and the fact that the @supports
block effectively causes non-supporting browsers to skip over the content inside β wouldn't it make sense that autoprefixer didn't prefix anything inside said @supports
block?
Nice idea, but I will not have time for this during next few weeks.
Do you want to send PR?
Hmm, I will at least give it a look. But this would be the first time I'd do something outside of simple DOM manipulation with JavaScript. π
Well, I gave up. This was clearly outside of my competence area. π
You can remove -webkit-sticky
by /* autoprefixer:off */
inside @supports
That's an ok temporary solution. The advantage of having Autoprefixer understand @supports
though is that you can still get prefixing on values not associated with the @supports
statement inside @supports
.
Yes it should disable prefixing but only for properties associated with the @supports
statement.
@supports (display: grid) {
display: grid; /* should not get prefixed */
user-select: none; /* should still get prefixed */
}
This is really complicated to do though so it's probably likely to have lots of bugs in it if implemented.
There are still the /* autoprefixer:off */
and /* autoprefixer: ignore next */
control comments though which are able to achieve the result needed with a bit of extra writing.
@supports (display: grid) {
/* autoprefixer: ignore next */
display: grid; /* not prefixed */
user-select: none; /* still prefixed */
}
Yeap, it is a pretty rare case. I will not have time for it in next months. But letβs keep it open. If somebody will implement it, I will help with code polishing and release PR.
I'm gonna check it but at first glance it's a tricky one :)