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

Commit cc92da0

Browse files
mgolpetebacondarwin
authored andcommitted
chore(*): cleanup msie handling; add support comments
1. The conditions checking the msie variable value have been simplified. There is e.g. no point to check if `msie <= 11` since there IE 12 won't ever exist. 2. Edge UA-sniffing has been added to tests (only!) where appropriate 3. Support comments for IE/Edge have been added. Closes #15407
1 parent c9bb5b9 commit cc92da0

File tree

17 files changed

+62
-21
lines changed

17 files changed

+62
-21
lines changed

src/Angular.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ var
169169
angularModule,
170170
uid = 0;
171171

172+
// Support: IE 9-11 only
172173
/**
173174
* documentMode is an IE-only property
174175
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
@@ -1279,6 +1280,7 @@ function fromJson(json) {
12791280

12801281
var ALL_COLONS = /:/g;
12811282
function timezoneToOffset(timezone, fallback) {
1283+
// Support: IE 9-11 only, Edge 13-14+
12821284
// IE/Edge do not "understand" colon (`:`) in timezone
12831285
timezone = timezone.replace(ALL_COLONS, '');
12841286
var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;

src/auto/injector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,9 @@ function createInjector(modulesToLoad, strictDi) {
849849
}
850850

851851
function isClass(func) {
852+
// Support: IE 9-11 only
852853
// IE 9-11 do not support classes and IE9 leaks with the code below.
853-
if (msie <= 11 || typeof func !== 'function') {
854+
if (msie || typeof func !== 'function') {
854855
return false;
855856
}
856857
var result = func.$$ngIsClass;

src/ng/compile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
19591959
for (var i = 0; i < nodeList.length; i++) {
19601960
attrs = new Attributes();
19611961

1962+
// Support: IE 11 only
19621963
// Workaround for #11781 and #14924
19631964
if (msie === 11) {
19641965
mergeConsecutiveTextNodes(nodeList, i, notLiveList);

src/ng/directive/attrs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,11 @@ forEach(['src', 'srcset', 'href'], function(attrName) {
426426

427427
attr.$set(name, value);
428428

429-
// on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist
429+
// Support: IE 9-11 only
430+
// On IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist
430431
// then calling element.setAttribute('src', 'foo') doesn't do anything, so we need
431432
// to set the property as well to achieve the desired effect.
432-
// we use attr[attrName] value since $set can sanitize the url.
433+
// We use attr[attrName] value since $set can sanitize the url.
433434
if (msie && propName) element.prop(propName, attr[name]);
434435
});
435436
}

src/ng/rootScope.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function $RootScopeProvider() {
105105

106106
function cleanUpScope($scope) {
107107

108+
// Support: IE 9 only
108109
if (msie === 9) {
109110
// There is a memory leak in IE9 if all child scopes are not disconnected
110111
// completely when a scope is destroyed. So this code will recurse up through

src/ng/sce.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ function $SceProvider() {
748748

749749
this.$get = ['$parse', '$sceDelegate', function(
750750
$parse, $sceDelegate) {
751+
// Support: IE 9-11 only
751752
// Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow
752753
// the "expression(javascript expression)" syntax which is insecure.
753754
if (enabled && msie < 8) {

src/ng/sniffer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ function $SnifferProvider() {
5757
// We are purposefully using `!(android < 4)` to cover the case when `android` is undefined
5858
history: !!(hasHistoryPushState && !(android < 4) && !boxee),
5959
hasEvent: function(event) {
60+
// Support: IE 9-11 only
6061
// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
6162
// it. In particular the event is not fired when backspace or delete key are pressed or
6263
// when cut operation is performed.
6364
// IE10+ implements 'input' event but it erroneously fires under various situations,
6465
// e.g. when placeholder changes, or a form is focused.
65-
if (event === 'input' && msie <= 11) return false;
66+
if (event === 'input' && msie) return false;
6667

6768
if (isUndefined(eventSupport[event])) {
6869
var divElm = document.createElement('div');

src/ng/urlUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var originUrl = urlResolve(window.location.href);
5858
function urlResolve(url) {
5959
var href = url;
6060

61+
// Support: IE 9-11 only
6162
if (msie) {
6263
// Normalize before parse. Refer Implementation Notes on why this is
6364
// done in two steps on IE.

src/ngScenario/dsl.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ angular.scenario.dsl('binding', function() {
201201
*/
202202
angular.scenario.dsl('input', function() {
203203
var chain = {};
204+
205+
// Support: IE 9-11 only
206+
// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
207+
// it. In particular the event is not fired when backspace or delete key are pressed or
208+
// when cut operation is performed.
209+
// IE10+ implements 'input' event but it erroneously fires under various situations,
210+
// e.g. when placeholder changes, or a form is focused.
204211
var supportInputEvent = 'oninput' in window.document.createElement('div') && !msie;
205212

206213
chain.enter = function(value, event) {

test/helpers/matchers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,19 @@ beforeEach(function() {
357357

358358
toBeMarkedAsSelected: function() {
359359
// Selected is special because the element property and attribute reflect each other's state.
360+
361+
// Support: IE 9 only
360362
// IE9 will wrongly report hasAttribute('selected') === true when the property is
361363
// undefined or null, and the dev tools show that no attribute is set
364+
362365
return {
363366
compare: function(actual) {
364367
var errors = [];
365368
if (actual.selected === null || typeof actual.selected === 'undefined' || actual.selected === false) {
366369
errors.push('Expected option property "selected" to be truthy');
367370
}
368371

372+
// Support: IE 9 only
369373
if (msie !== 9 && actual.hasAttribute('selected') === false) {
370374
errors.push('Expected option to have attribute "selected"');
371375
}
@@ -383,6 +387,7 @@ beforeEach(function() {
383387
errors.push('Expected option property "selected" to be falsy');
384388
}
385389

390+
// Support: IE 9 only
386391
if (msie !== 9 && actual.hasAttribute('selected')) {
387392
errors.push('Expected option not to have attribute "selected"');
388393
}

0 commit comments

Comments
 (0)