Skip to content

Commit

Permalink
Adds changelog, updates README and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pastelsky committed Dec 15, 2018
1 parent 1a2a249 commit 1cbab42
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 155 deletions.
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# v3.0.0
- **Fix**: Don't crash when `options` parameter is not specified
- **Fix**: Use `loose` option to parse browsers versions. Doesn't crash on versions like `6.00.1` or 6.0.0005` etc.

- **Feature**: Added support for Samsung Internet

- **Breaking**: Safari on desktop and on iOS are now considered as separate browsers.
You'll need to use separate browserslist queries to target both of them - `['Safari >= 10', 'iOS >= 10.1']`. See #23
- **Breaking**: Removing support for undocumented option to `matchesUA` - `all`.
This was used internally, and shouldn't be breaking change for you unless you poked around code to discover it.
- **Breaking**: Remove deprecated `_allowHigherVersions` flag. This has been replaced by `allowHigherVersions` in the past.

# v2.0.1
- Remove deprecated _allowHigherVersions option from README

# v2.0.0
- **Feature**: Added Yandex to list of supported browsers
- **Feature**: Added support for Yandex Browser
- **Deprecation**: Deprecated `_allowHigherVersions`

#v1.2.1
- Fixed build link

#v1.2.0
- **Feature**: Updated packages and added support for headless chrome and chromium
- Fixed links in badges

#v1.1.0
- **Feature**: Added support for selecting environment
- Updated browserslist version

#v1.0.4
- delete gitignore

#v1.0.3
- Update README.md

#v1.0.2
- Second try at fixing logo

#v1.0.1
- Updated browserslist version

#v1.0.0
- Create LICENSE
- /browserlist/ => browserslist
- Refactored code and rewrote Readme

#v0.0.2
- Added install instructions
- Initial commit
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ matchesUA('Mozilla/5.0 (Windows NT 10.0; rv:54.0) Gecko/20100101 Firefox/54.0',
| env || When multiple browserslist [environments](https://github.com/ai/browserslist#environments) are specified, pick the config belonging to this environment.|
| ignorePatch | `true` | Ignore differences in patch browser numbers |
| ignoreMinor | `false` | Ignore differences in minor browser versions |
| allowHigherVersions | `false` | For all the browsers in the browserslist query, return a match if the user agent version is equal to or higher than the one specified in browserslist. See [why](#when-querying-for-modern-browsers) this might be useful
| allowHigherVersions | `false` | For all the browsers in the browserslist query, return a match if the user agent version is equal to or higher than the one specified in browserslist. See [why](#when-querying-for-modern-browsers) this might be useful.

## Supported browsers
| Browser Family | Browserslist
- Chrome (Chrome / Chromium / Yandex) as `and_chr` | `ChromeAndroid` | `Chrome`
- Samsung Internet as `Samsung`
- Firefox as `ff` | `and_ff` | `FirefoxAndroid` | `Firefox`
- Safari as `ios_saf`
- Safari iOS as `ios_saf` | `iOS`
- Safari Desktop as `Safari`
- IE as `ie` | `ie_mob`
- Edge as `Edge`

Expand All @@ -57,9 +58,13 @@ matchesUA('Mozilla/5.0 (Windows NT 10.0; rv:54.0) Gecko/20100101 Firefox/54.0',
- All browsers on iOS (Chrome, Firefox etc) use Safari's WebKit as the underlying engine, and hence will be resolved to Safari. Since `browserslist` is usually used for
transpiling / autoprefixing for browsers, this behaviour is what's intended in most cases, but might surprise you otherwise.

- Right now, Chrome for Android and Firefox for Android are resolved to their desktop equivalents. The `caniuse` database does not currently store historical data for these browsers separately (except the last version) See [#156](https://github.com/ai/browserslist/issues/156)
- Right now, Chrome for Android and Firefox for Android are resolved to their desktop equivalents. The `caniuse` database does not currently store historical data for these browsers separately (except the last version) See [#156](https://github.com/ai/browserslist/issues/156). However,
safari for iOS and desktop can be matched separately, since this data is available for both.

## When querying for modern browsers
- It is a good idea to update this package often so that browser definitions are upto date.
- It is also a good idea to add `unreleased versions` to your browserslist query, and set `ignoreMinor` and `ignorePatch` to true so that alpha / beta / canary versions of browsers are matched.
- In case you're unable to keep this package up-to-date, you can set the `allowHigherVersions` to `true`. For all the browsers specified in your browserslist query, this will return a match if the user agent version is equal to or higher than those specified in your browserslist query. Use this with care though, since it's a wildcard, and only lightly tested.
- In case you're unable to keep this package up-to-date, you can set the `allowHigherVersions` to `true`. For all the browsers specified in your browserslist query, this will return a match if the user agent version is equal to or higher than those specified in your browserslist query. Use this with care though, since it's a wildcard, and only lightly tested.

## Further reads
- [Smart Bundling: Shipping legacy code to only legacy browsers](https://www.smashingmagazine.com/2018/10/smart-bundling-legacy-code-browsers/)
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function resolveUserAgent(uaString) {

const parsedUA = useragent.parse(strippedUA)

// Case A: For Safari, Chrome and others browsers
// Case A: For Safari, Chrome and others browsers on iOS
// that report as Safari after stripping tags
if (parsedUA.family.includes('Safari') && parsedUA.os.family === 'iOS') {
return {
Expand Down Expand Up @@ -155,8 +155,7 @@ const parseBrowsersList = (browsersList) => {

try {
// Browser version can return as "10.0-10.2"
const splitVersion = browserVersion.split('-')[0]
normalizedVersion = splitVersion
normalizedVersion = browserVersion.split('-')[0]
} catch (e) {
}

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
},
"scripts": {
"test": "jest",
"watch-tests": "jest --watch",
"test:watch": "jest --watch",
"prepublish": "yarn run build",
"build": "mkdir -p lib && babel index.js --out-file lib/index.js"
},
"dependencies": {
"browserslist": "^4.3.4",
"semver": "^5.4.1",
"browserslist": "^4.3.6",
"semver": "^5.6.0",
"useragent": "^2.3.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"jest": "^23.4.1",
"jest": "^23.6.0",
"useragent-generator": "^1.1.0"
},
"jest": {
Expand Down
27 changes: 2 additions & 25 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ it('resolves desktop safari on osx properly', () => {
family: 'Safari',
version: '10.1.0',
})

expect(resolveUserAgent(ua.safari('11.0.0')))
.toEqual({
family: 'Safari',
version: '11.0.0',
})

expect(resolveUserAgent(ua.safari('12.0.0')))
.toEqual({
family: 'Safari',
version: '12.0.0',
})
})

it('resolves IE/Edge properly', () => {
Expand Down Expand Up @@ -215,20 +203,12 @@ it('detects if browserslist matches UA', () => {
expect(matchesUA(ua.chrome.androidWebview('4.3.3'), { browsers: modernList }))
.toBeFalsy()

expect(matchesUA(ua.safari('11.0.0'), {browsers: modernList}))
.toBeTruthy()

expect(matchesUA(ua.safari('11.1.0'), {browsers: modernList}))
.toBeTruthy()

expect(matchesUA(ua.safari('12.0.0'), {browsers: modernList}))
expect(matchesUA(ua.safari('12.0.0'), { browsers: modernList }))
.toBeTruthy()

expect(matchesUA(ua.safari('10.0.0'), {browsers: modernList}))
expect(matchesUA(ua.safari('10.0.0'), { browsers: modernList }))
.toBeFalsy()

expect(matchesUA(ua.safari('10.1.2'), {browsers: modernList}))
.toBeFalsy()
expect(matchesUA(CustomUserAgentString.SAMSUNG_BROWSER_7_2, { browsers: modernList }))
.toBeTruthy()
})
Expand All @@ -240,9 +220,6 @@ it('can interpret various variations in specifying browser names', () => {
expect(matchesUA(ua.safari.iOS('10.3.0'), { browsers: ['ios_saf >= 10.1.0'] }))
.toBeTruthy()

expect(matchesUA(ua.safari('10.1.2'), {browsers: ['Safari >= 10.1.0']}))
.toBeTruthy()

expect(matchesUA(ua.firefox.androidPhone('46.0.0'), { browsers: ['FirefoxAndroid >= 41.1.0'] }))
.toBeTruthy()
})
Expand Down
Loading

0 comments on commit 1cbab42

Please sign in to comment.