Skip to content

Commit 64241a5

Browse files
mgolIgorMinar
authored andcommitted
chore($sniffer): Remove $sniffer.msie & $sniffer.msieDocumentMode
Since msie is now set to document.documentMode, it's not necessary to keep the documentMode in a separate property. Also, msie is a variable global to Angular source so there's no need to replicate it in $sniffer. Closes angulargh-9496
1 parent 2435e2b commit 64241a5

File tree

6 files changed

+18
-34
lines changed

6 files changed

+18
-34
lines changed

docs/content/error/$sce/iequirks.ngdoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
@ngdoc error
22
@name $sce:iequirks
3-
@fullName IE8 in quirks mode is unsupported
3+
@fullName IE<11 in quirks mode is unsupported
44
@description
55

6-
This error occurs when you are using AngularJS with {@link ng.$sce Strict Contextual Escaping (SCE)} mode enabled (the default) on IE8 or lower in quirks mode.
6+
This error occurs when you are using AngularJS with {@link ng.$sce Strict Contextual Escaping (SCE)} mode enabled (the default) on IE10 or lower in quirks mode.
77

8-
In this mode, IE8 allows one to execute arbitrary javascript by the use of the `expression()` syntax and is not supported.
8+
In this mode, IE<11 allow one to execute arbitrary javascript by the use of the `expression()` syntax and is not supported.
99
Refer
10-
[MSDN Blogs > IEBlog > Ending Expressions](http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx)
10+
[CSS expressions no longer supported for the Internet zone](http://msdn.microsoft.com/en-us/library/ie/dn384050(v=vs.85).aspx)
1111
to learn more about them.
1212

1313
To resolve this error please specify the proper doctype at the top of your main html document:

src/ng/sce.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ function $SceDelegateProvider() {
410410
*
411411
* As of version 1.2, Angular ships with SCE enabled by default.
412412
*
413-
* Note: When enabled (the default), IE8 in quirks mode is not supported. In this mode, IE8 allows
413+
* Note: When enabled (the default), IE<11 in quirks mode is not supported. In this mode, IE<11 allow
414414
* one to execute arbitrary javascript by the use of the expression() syntax. Refer
415415
* <http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx> to learn more about them.
416416
* You can ensure your document is in standards mode and not quirks mode by adding `<!doctype html>`
@@ -727,13 +727,13 @@ function $SceProvider() {
727727
* sce.js and sceSpecs.js would need to be aware of this detail.
728728
*/
729729

730-
this.$get = ['$parse', '$sniffer', '$sceDelegate', function(
731-
$parse, $sniffer, $sceDelegate) {
732-
// Prereq: Ensure that we're not running in IE8 quirks mode. In that mode, IE allows
730+
this.$get = ['$document', '$parse', '$sceDelegate', function(
731+
$document, $parse, $sceDelegate) {
732+
// Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow
733733
// the "expression(javascript expression)" syntax which is insecure.
734-
if (enabled && $sniffer.msie && $sniffer.msieDocumentMode < 8) {
734+
if (enabled && $document[0].documentMode < 8) {
735735
throw $sceMinErr('iequirks',
736-
'Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks ' +
736+
'Strict Contextual Escaping does not support Internet Explorer version < 11 in quirks ' +
737737
'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' +
738738
'document. See http://docs.angularjs.org/api/ng.$sce for more information.');
739739
}

src/ng/sniffer.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function $SnifferProvider() {
2121
int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
2222
boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
2323
document = $document[0] || {},
24-
documentMode = document.documentMode,
2524
vendorPrefix,
2625
vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
2726
bodyStyle = document.body && document.body.style,
@@ -81,9 +80,7 @@ function $SnifferProvider() {
8180
vendorPrefix: vendorPrefix,
8281
transitions : transitions,
8382
animations : animations,
84-
android: android,
85-
msie : msie,
86-
msieDocumentMode: documentMode
83+
android: android
8784
};
8885
}];
8986
}

test/ng/locationSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('$location', function() {
1818
var urlParsingNodePlaceholder;
1919

2020
beforeEach(inject(function ($sniffer) {
21-
if ($sniffer.msie) return;
21+
if (msie) return;
2222

2323
urlParsingNodePlaceholder = urlParsingNode;
2424

@@ -38,7 +38,7 @@ describe('$location', function() {
3838
}));
3939

4040
afterEach(inject(function ($sniffer) {
41-
if ($sniffer.msie) return;
41+
if (msie) return;
4242
//reset urlParsingNode
4343
urlParsingNode = urlParsingNodePlaceholder;
4444
}));

test/ng/sceSpecs.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ describe('SCE', function() {
2626
}));
2727
});
2828

29-
describe('IE8 quirks mode', function() {
29+
describe('IE<11 quirks mode', function() {
3030
function runTest(enabled, documentMode, expectException) {
3131
module(function($provide) {
32-
$provide.value('$sniffer', {
33-
msie: documentMode,
34-
msieDocumentMode: documentMode
35-
});
32+
$provide.value('$document', [{
33+
documentMode: documentMode
34+
}]);
3635
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
3736
});
3837

@@ -47,7 +46,7 @@ describe('SCE', function() {
4746
if (expectException) {
4847
expect(constructSce).toThrowMinErr(
4948
'$sce', 'iequirks', 'Strict Contextual Escaping does not support Internet Explorer ' +
50-
'version < 9 in quirks mode. You can fix this by adding the text <!doctype html> to ' +
49+
'version < 11 in quirks mode. You can fix this by adding the text <!doctype html> to ' +
5150
'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' +
5251
'information.');
5352
} else {

test/ng/snifferSpec.js

-12
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,4 @@ describe('$sniffer', function() {
332332
expect($sniffer.android).toBe(2);
333333
});
334334
});
335-
336-
it('should return the internal msie flag', inject(function($sniffer) {
337-
expect(isNaN($sniffer.msie)).toBe(isNaN(msie));
338-
if (msie) {
339-
expect($sniffer.msie).toBe(msie);
340-
}
341-
}));
342-
343-
it('should return document.documentMode as msieDocumentMode', function() {
344-
var someDocumentMode = 123;
345-
expect(sniffer({}, {documentMode: someDocumentMode}).msieDocumentMode).toBe(someDocumentMode);
346-
});
347335
});

0 commit comments

Comments
 (0)