browserslist icon indicating copy to clipboard operation
browserslist copied to clipboard

`mobileToDesktop` doesn't change the browser name

Open ylemkimon opened this issue 5 years ago • 3 comments

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: https://github.com/browserslist/browserslist/blob/f5ff062d9ed723bfa7de9121ddeef27e1e7aa5fe/index.js#L245-L249

Is this intended behavior?

ylemkimon avatar Jul 20 '20 09:07 ylemkimon

Nope, let's fix it in pull request

ai avatar Jul 20 '20 16:07 ai

@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: https://github.com/browserslist/browserslist/blob/f5ff062d9ed723bfa7de9121ddeef27e1e7aa5fe/index.js#L254

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 #508. I think it can take arrays of normalizer names, e.g., mobileToDesktop, chromiumToChrome, or custom functions.

ylemkimon avatar Jul 23 '20 09:07 ylemkimon

I like new option

ai avatar Jul 23 '20 15:07 ai