Skip to content

Alias mobile browsers to the desktop version#371

Merged
ai merged 3 commits intobrowserslist:masterfrom
nicolo-ribaudo:mobile-alias
May 14, 2019
Merged

Alias mobile browsers to the desktop version#371
ai merged 3 commits intobrowserslist:masterfrom
nicolo-ribaudo:mobile-alias

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Contributor

Fixes #367

In this PR, browserslist fallback to the desktop version only if the query doesn't match a mobile version. I didn't choose to always fallback in case a mobile browser has a release which doesn't match its desktop counterpart (is it even possible?).

})

it('supports Can I Use missing mobile versions', () => {
expect(browserslist('chromeandroid 53')).toEqual(['and_chr 53'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test all 4 shortcuts

@ai
Copy link
Copy Markdown
Member

ai commented May 11, 2019

We need to do it only on a special option.

I can’t release major version (because many old projects are using Browserslist and they will not update it for years). As result, we can’t break API.

expect(browserslist('chromeandroid 53')).not.toEqual(['and_chr 53'])
expect(browserslist('and_ff 60')).not.toEqual(['and_ff 60'])
expect(() => browserslist('ie_mob 9')).toThrow()
expect(() => browserslist('op_mob 30')).toThrow()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why some of these browsers throw and some resolve to another version, but it's the current behavior:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, error is throwing because Can I Use doesn't have info

@ai
Copy link
Copy Markdown
Member

ai commented May 12, 2019

Can you add additional option here https://github.com/browserslist/browserslist#js-api

@ai ai merged commit 49ec436 into browserslist:master May 14, 2019
@nicolo-ribaudo nicolo-ribaudo deleted the mobile-alias branch May 14, 2019 09:03
@nicolo-ribaudo
Copy link
Copy Markdown
Contributor Author

Thanks!

@ai
Copy link
Copy Markdown
Member

ai commented May 14, 2019

@nicolo-ribaudo do you have a Twitter account to mention you in release tweet?

@ai
Copy link
Copy Markdown
Member

ai commented May 14, 2019

Released in 4.6

@nicolo-ribaudo
Copy link
Copy Markdown
Contributor Author

Yup, it's @NicoloRibaudo

zhouyu9527 pushed a commit to zhouyu9527/browserslist that referenced this pull request Jul 5, 2022
* Alias mobile browsers to the desktop version

* Add mobileToDesktop option

* Documentation
tats-u pushed a commit to tats-u/browserslist that referenced this pull request Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong chromeandroid version parsing

2 participants