-
Notifications
You must be signed in to change notification settings - Fork 19
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
Check mobile ie11 and ie11 running compatibility mode #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion on the boolean checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I think it might be useful to add a little comment on top of ie11_actual?
to explain why it is needed.
lib/browser_sniffer.rb
Outdated
@@ -24,6 +24,14 @@ def ie11? | |||
browser == :ie && major_browser_version == 11 | |||
end | |||
|
|||
def ie11_actual? | |||
ie_11 = browser == :ie && major_browser_version == 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the ie11?
method instead of redefining it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but there could be legitimate uses where ie11?
is being relied on to return false even if it's ie11 rendering as ie7 in compatibility mode, for example. I don't want to break any apps out there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, I meant using the existing method ie11?
instead of defining this ie_11
variable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see that you have already done that! 👍
2acece4
to
c40a458
Compare
Description
The method
ie11?
will return false for ie11 mobile and when ie11 is running in compatibility mode for an older browser.For example:
^ this UA string is for IE11 on windows 10 running in IE7 compatibility mode.
.ie11?
will return false, since it's seeing the browser as IE7.^ this UA string is for IE11 mobile running on Windows Phone 8.1.
ie11?
will return false since the browser isn't being properly captured.This PR adds a new method called
ie11_actual?
that looks a little deeper to determine if the UA is for IE11. It checks:browser
is:ie
and themajor_browser_version
is 11 - the same check in theie11?
methodOR
engine_name
is"Trident"
and themajor_engine_version
is7
, catching any browsers using the IE11 engineOR
major_browser_version
is11
and thebrowser_name
is"IEMobile"
Why this approach?
In the case that
1.
apps using theie11?
method rely on having it returntrue
for the browser version being served regardless of whether it's a compatibility view and2.
apps using theie11?
method rely on only desktop version to causetrue
to be returned, I opted to create a new method that will return true when ie11 is in use in any way.