Skip to content
Browse files

In IE, Browser.version should be the same as document.documentMode wh…

…en set. Fixes #1029

When document mode is switched, UA still remains as the current browser, but backwards functionality is simulated (limited).
Test by switching Document Mode in IE Dev Tools or setting X-UA-Compatible header/meta-tag.
  • Loading branch information...
1 parent a960a12 commit 601c6dd6a6a98d8635c1a8e6ee840b8b3f7022d1 @sebmarkbage sebmarkbage committed with cpojer
Showing with 6 additions and 3 deletions.
  1. +2 −0 Docs/Browser/Browser.md
  2. +3 −2 Source/Browser/Browser.js
  3. +1 −1 Specs
View
2 Docs/Browser/Browser.md
@@ -30,6 +30,8 @@ Some browser properties are attached to the Browser Object for browser and platf
* Browser.chrome - (*boolean*) True if the current browser is Chrome
* Browser.opera - (*boolean*) True if the current browser is Opera
+If an IE document is set to backwards compatibility mode using the X-UA-Compatible header, then the Browser object is treated as if the earlier version of the browser is running.
+
### Platform:
* Browser.Platform.mac - (*boolean*) True if the platform is Mac.
View
5 Source/Browser/Browser.js
@@ -32,7 +32,8 @@ $uid(document);
var ua = navigator.userAgent.toLowerCase(),
platform = navigator.platform.toLowerCase(),
- UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0];
+ UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
+ mode = UA[1] == 'ie' && document.documentMode;
var Browser = this.Browser = {
@@ -40,7 +41,7 @@ var Browser = this.Browser = {
name: (UA[1] == 'version') ? UA[3] : UA[1],
- version: parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
+ version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
Platform: {
name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
2 Specs
@@ -1 +1 @@
-Subproject commit 3eb99d310bb304fbc84b44db59eb7fc2a556a22e
+Subproject commit 4f8617240dd6d70d88c382e080ba00623814002f

0 comments on commit 601c6dd

Please sign in to comment.
Something went wrong with that request. Please try again.