forked from browserslist/browserslist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "and" operator to query parser (browserslist#286)
* added failing test for AND operator * new initial query marker * all tests pass * make it clear that you can write 'OR'/'or' instead of ',' * reduced fixture used for testing AND operator * get test coverage to 100% * trim off 9bytes * changed QueryType enum name from inititial to oneliner, since it's for oneliner queries but also for the initital query in a query composition but the former is more common - I'm open for other names. Also change the limit since the build is slightly bigger when running on travis (for unknown reason). Changed enum values for QueryType, so QueryType.oneliner | QueryType.or is different than QueryType.or * The project policy is to keep text editor ignores in local .git/info/exclude * It is OK to just set "limit": "8.8 KB" * added comments about the difference in filtering * merged with master * temporary up size limit to allow new additions from upstream master * cherry picking files from upstream master * temp up size limit after merge * trim tests and added test for 'complex cases with version-less browser and not query as AND query' * shaved off a few bytes and made sure the AND syntax can be used in package.json * actually execute package.json AND queries in test * backport 'to not' algorithm to 21c25e2 * fixed inline documentation and comments * added description of the new supported query syntax * fixed 'combiner' illustrations - can not inline SVG in README * center illustrations * see what it looks like if the illustrations does not have a defined width * fixed documentation as advised by @ai - browserslist#286 (comment) * updated CHANGELOG and dependencies * fixed CHANGELOG * Remove ChangeLog
- Loading branch information
1 parent
961d65b
commit 3efc998
Showing
9 changed files
with
267 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var browserslist = require('../') | ||
|
||
var path = require('path') | ||
|
||
var PACKAGE = path.join(__dirname, 'fixtures', 'package2') | ||
|
||
it('query composition with AND operator', () => { | ||
// old behavior | ||
expect( | ||
browserslist('ie >= 6, ie <= 7') | ||
).toEqual([ | ||
'ie 11', | ||
'ie 10', | ||
'ie 9', | ||
'ie 8', | ||
'ie 7', | ||
'ie 6', | ||
'ie 5.5' | ||
]) | ||
|
||
// new behavior | ||
expect( | ||
browserslist('ie >= 6 and ie <= 7') | ||
).toEqual([ | ||
'ie 7', | ||
'ie 6' | ||
]) | ||
|
||
// and with not | ||
expect( | ||
browserslist('ie < 11 and not ie 7') | ||
).toEqual([ | ||
'ie 10', | ||
'ie 9', | ||
'ie 8', | ||
'ie 6', | ||
'ie 5.5' | ||
]) | ||
}) | ||
|
||
it('correctly works with not and one-version browsers as AND query', () => { | ||
expect(browserslist('last 1 Baidu version and not <2% in AT')).toHaveLength(0) | ||
}) | ||
|
||
it('reads config from package.json', () => { | ||
expect(browserslist.findConfig(PACKAGE)).toEqual({ | ||
defaults: ['ie > 6 and ie 9 or ie 10'] | ||
}) | ||
|
||
expect(browserslist(null, { path: PACKAGE })).toEqual( | ||
['ie 10', 'ie 9'] | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"private": true, | ||
"browserslist": ["ie > 6 and ie 9 or ie 10"] | ||
} |
Oops, something went wrong.