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

Commit 4aea500

Browse files
committed
refactor: use document.documentMode to determine msie version
1 parent 86c7d12 commit 4aea500

File tree

5 files changed

+10
-24
lines changed

5 files changed

+10
-24
lines changed

src/Angular.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,10 @@ var /** holds major version number for IE or NaN for real browsers */
171171
uid = 0;
172172

173173
/**
174-
* IE 11 changed the format of the UserAgent string.
175-
* See http://msdn.microsoft.com/en-us/library/ms537503.aspx
174+
* documentMode is an IE-only property
175+
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
176176
*/
177-
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
178-
if (isNaN(msie)) {
179-
msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
180-
}
177+
msie = document.documentMode;
181178

182179

183180
/**

src/ngScenario/browserTrigger.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
'use strict';
22

33
(function() {
4-
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
4+
/**
5+
* documentMode is an IE-only property
6+
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
7+
*/
8+
msie = document.documentMode;
59

610
/**
711
* Triggers a browser event. Attempts to choose the right event if one is

test/jqLiteSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ describe('jqLite', function() {
11851185
if (window.jQuery) return;
11861186
var browserMoveTrigger = function(from, to){
11871187
var fireEvent = function(type, element, relatedTarget){
1188-
var evnt, msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
1188+
var evnt;
1189+
11891190
if (msie < 9){
11901191
evnt = document.createEventObject();
11911192
evnt.srcElement = element;

test/ngTouch/directive/ngSwipeSpec.js

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ var swipeTests = function(description, restrictBrowsers, startEvent, moveEvent,
1414
}
1515
}
1616

17-
// Skip tests on IE < 9. These versions of IE don't support createEvent(), and so
18-
// we cannot control the (x,y) position of events.
19-
// It works fine in IE 8 under manual testing.
20-
var msie = +((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
21-
if (msie < 9) {
22-
return;
23-
}
24-
2517
beforeEach(function() {
2618
module('ngTouch');
2719
});

test/ngTouch/swipeSpec.js

-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ describe('$swipe', function() {
44
var element;
55
var events;
66

7-
// Skip tests on IE < 9. These versions of IE don't support createEvent(), and so
8-
// we cannot control the (x,y) position of events.
9-
// It works fine in IE 8 under manual testing.
10-
var msie = +((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
11-
if (msie < 9) {
12-
return;
13-
}
14-
157
beforeEach(function() {
168
module('ngTouch');
179
inject(function($compile, $rootScope) {

0 commit comments

Comments
 (0)