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

negated props? #5

Closed
oyeanuj opened this issue May 17, 2018 · 3 comments
Closed

negated props? #5

oyeanuj opened this issue May 17, 2018 · 3 comments

Comments

@oyeanuj
Copy link

oyeanuj commented May 17, 2018

Hi @quentin-sommer, firstly, thank you for creating this useful library!

In a particular use-case, I was looking to target only a mobile phones, but not tablets. Unfortunately, I noticed that the mobile prop is set to true on both mobile and tablet devices.

So, in such a case, what do you recommend? Would you consider adding a false value such that the code below would target only say mobile phones:

<UserAgent mobile tablet = { false } /> 

If so, that would be useful for people who want to target only certain browsers on certain mobile devices as this would provide the desired flexibility?

Thank you!

@quentin-sommer
Copy link
Owner

quentin-sommer commented May 18, 2018

Hi, Thanks for using the library!

I'm afraid I'm the one responsible for mobile and tablet being both matched at once. It's happening because the mobile prop is optimistic and matches mobile + Android or iOS detection

uaResults.mobile =
  uaResults.android ||
  uaResults.ios     ||
  uaParser.getDevice().type === 'mobile'

uaResults.tablet = uaParser.getDevice().type === 'tablet'

Will it work for you just disabling this part?

uaResults.android ||
uaResults.ios     ||

It will ensure that only one of mobile or tablet prop is true

@oyeanuj
Copy link
Author

oyeanuj commented May 22, 2018

@quentin-sommer I think that should work. I think the keeping the OS check separate from device type would help reduce false positives and provide flexibility for those who want those checks for their usecase.

@quentin-sommer
Copy link
Owner

quentin-sommer commented May 23, 2018

Fixed starting 1.3.0
41da0d5

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

No branches or pull requests

2 participants