New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fully supports
and partially supports
queries
#787
Conversation
This is like the `supports` query, except it does not include browsers with partial support for the given feature.
1f6863e
to
abf5955
Compare
👍
It doesn't look like "partial" support. Is current behaviour bug? |
Can you show popular real-world example when this query will be useful? |
Sorry for the slow reply, it's been a busy week.
It's debatable. If I were reviewing code when supports was added then I'd consider it a bug and that I'd expect "Change the behaviour of supports to omit partial support and we don't need to add any new query" would also be an acceptable solution but I doubt @ai would consider that change not disruptive enough to include in a minor/patch version.
I'm not sure I can ensure "popular", as partial support in caniuse's syntax is relatively rare these days - it was more prevalent when browsers introduced features with vendor prefixes rather than behind feature flags. Recent features that make heavy use of partial supports are container queries, container style queries,
If users wished to use Currently My particular use-case is for creating builds for long-tail legacy browsers, I'd want to use |
Yes, these use cases look legit. I will think about adding it. |
I've pushed up a new commit, to try to improve the documentation by adding an example referencing When thinking about documentation and how to teach this I felt that the difference between So try to solve this I've added a I've moved the existing examples of |
Let’s move to |
e5578b2
to
65501c7
Compare
fully supports
queryfully supports
and partially supports
queries
`partially supports` does the same thing as `supports` but makes it clearer that it includes partial browser support. It feels easier to teach the difference between `fully supports` and `partially supports` and then say `supports` is an alias` of `partially supports`.
65501c7
to
4d39b44
Compare
4d39b44
to
bda318e
Compare
I think I've addressed everything. Website update PR is at browserslist/browsersl.ist#522. Let me know when you're you've got no more feedback, and I can squash these commits down prior to merge. @ai one last question: I made this PR working on the assumption that changing the current behaviour of function isSupported(flags) {
- return (
- typeof flags === 'string' &&
- (flags.indexOf('y') >= 0 || flags.indexOf('a') >= 0)
- )
+ return typeof flags === 'string' && flags.indexOf('y') >= 0;
} |
Thanks. Released in 4.22. |
Context
Caniuse features can be marked as "fully supported", "partially supported" and a few other values that aren't relevant to this reminder/primer (see the stats key in caniuse docs). For instance for the
es6
feature, partial support began with Chrome 21 but wasn't marked as fully supported till Chrome 51.Browserslist's
supports
query includes browsers with both full and partial support for a given feature. Thussupports es6
includes Chrome 21 and up. This is somewhat surprising to me as if you'd try to use es6 features in Chrome 21 things would go very wrong very quickly. I hope to think of browserslist's supports query as "this is a baseline from which you can assume full support for a feature, so stuff like babel won't need to transpile/polyfill this at all", but thanks to it's partial support that's not quite what it does.I'd like a way to make a supports query that only considers full support, instead of partial and full support. I appreciate that changing the behaviour of supports after so long would be an unexpected change to the point of it being a breaking change and so a new query would be needed.
This PR is an approach to solve that problem, but I'd love some feedback on naming.
This PR
This PR adds a
fully supports
query, that acts likesupports
except it only considers full browser support. As a resultfully supports es6
's first Chrome version is Chrome 51.I'm not super tied to the
fully supports
name and it feels a bit clunky. In an ideal world it'd feel nicer forsupports
to be for full support, and then we have a modifier if we want to include partial support, but I know that's almost certainly too disruptive to ship. I would welcome suggestions for any syntax that you'd prefer.One alternative is having
supports es6 fully
- where fully is a modifier of the existing supports query, kinda like how you can do>5%
and>5% in US
.Another alternative is betting on this prefix more, and adding
partially supports
as a query too (with the same behaviour assupports
currently and pushing people to usefully supports
andpartially supports
instead ofsupports
. This kinda leans into the magical future world where we could change the default behaviour ofsupports
to be "full support", and then people have to opt in if they want to include partial support.