Skip to content
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

mobileToDesktop doesn't change the browser name #510

Open
ylemkimon opened this issue Jul 20, 2020 · 3 comments · May be fixed by #511
Open

mobileToDesktop doesn't change the browser name #510

ylemkimon opened this issue Jul 20, 2020 · 3 comments · May be fixed by #511

Comments

@ylemkimon
Copy link

ylemkimon commented Jul 20, 2020

npx browserslist --mobile-to-desktop ">3%, and_chr 50"

Actual

and_chr 81
and_chr 50
chrome 83
ios_saf 13.4-13.5

Expected

chrome 50
chrome 81
chrome 83
ios_saf 13.4-13.5

Currently, mobileToDesktop logic is only applied to byName:

browserslist/index.js

Lines 245 to 249 in f5ff062

function byName (name, context) {
name = name.toLowerCase()
name = browserslist.aliases[name] || name
if (context.mobileToDesktop && browserslist.desktopNames[name]) {
var desktop = browserslist.data[browserslist.desktopNames[name]]

Is this intended behavior?

@ylemkimon ylemkimon changed the title mobileToDesktop doesn't apply to usage queries mobileToDesktop only applies to version queries Jul 20, 2020
@ai
Copy link
Member

ai commented Jul 20, 2020

Nope, let's fix it in pull request

@ylemkimon ylemkimon changed the title mobileToDesktop only applies to version queries mobileToDesktop doesn't change the browser name Jul 23, 2020
@ylemkimon
Copy link
Author

ylemkimon commented Jul 23, 2020

@ai Looking at the code and commits, it turns out mobileToDesktop doesn't change the mobile browser to desktop one like what the doc says and its name suggests, but only resolves the version part using desktop one:

cloned.name = name

I think there are two ways to proceed:

  1. Change the browser name if mobileToDesktop is true. This may be a breaking change since it modifies the behavior of an existing option.
  2. Add another option, something like normalize, along with Option to return Chrome versions for Chromium-based browsers #508. I think it can take arrays of normalizer names, e.g., mobileToDesktop, chromiumToChrome, or custom functions.

@ai
Copy link
Member

ai commented Jul 23, 2020

I like new option

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 a pull request may close this issue.

2 participants