Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

msie: documentMode detection to replace userAgent sniffing #4155

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/component-spec/mocks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copy/pasted from src/Angular.js, so that we can disable specific tests on IE.
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
var msie = document.documentMode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks people using using IE7, as few of them as there are. I'm not sure if I really have a problem with this, but it's something to think about.

You know what, I'm not sure I care, this is great. Right on!


var createMockWindow = function() {
var mockWindow = {};
Expand Down
8 changes: 2 additions & 6 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ var /** holds major version number for IE or NaN for real browsers */
uid = ['0', '0', '0'];

/**
* IE 11 changed the format of the UserAgent string.
* See http://msdn.microsoft.com/en-us/library/ms537503.aspx
* document.documentMode is IE specific and returns IE document Mode for current page.
*/
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
if (isNaN(msie)) {
msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
}
msie = document.documentMode;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/ngScenario/browserTrigger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

(function() {
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
var msie = document.documentMode;

function indexOf(array, obj) {
if (array.indexOf) return array.indexOf(obj);
Expand Down
2 changes: 1 addition & 1 deletion test/ngTouch/directive/ngSwipeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var swipeTests = function(description, restrictBrowsers, startEvent, moveEvent,
// Skip tests on IE < 9. These versions of IE don't support createEvent(), and so
// we cannot control the (x,y) position of events.
// It works fine in IE 8 under manual testing.
var msie = +((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
var msie = document.documentMode;
if (msie < 9) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/ngTouch/swipeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var swipeTests = function(description, restrictBrowsers, startEvent, moveEvent,
// Skip tests on IE < 9. These versions of IE don't support createEvent(), and so
// we cannot control the (x,y) position of events.
// It works fine in IE 8 under manual testing.
var msie = +((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
var msie = document.documentMode;
if (msie < 9) {
return;
}
Expand Down