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

Commit 5c46cb9

Browse files
committed
chore(IE8) Remove more special code for IE8
1 parent 613d0a3 commit 5c46cb9

File tree

8 files changed

+12
-103
lines changed

8 files changed

+12
-103
lines changed

src/Angular.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ function forEach(obj, iterator, context) {
238238
if (obj) {
239239
if (isFunction(obj)) {
240240
for (key in obj) {
241-
// Need to check if hasOwnProperty exists,
242-
// as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
243-
if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
241+
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
244242
iterator.call(context, obj[key], key, obj);
245243
}
246244
}

src/ng/httpBackend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
5858
xhr.onload = function requestLoaded() {
5959
var statusText = xhr.statusText || '';
6060

61-
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
61+
// responseText is the old-school way of retrieving response (supported by IE9)
6262
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
6363
var response = ('response' in xhr) ? xhr.response : xhr.responseText;
6464

src/ng/urlUtils.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,13 @@ var originUrl = urlResolve(window.location.href, true);
2424
*
2525
* Implementation Notes for IE
2626
* ---------------------------
27-
* IE >= 8 and <= 10 normalizes the URL when assigned to the anchor node similar to the other
27+
* IE <= 10 normalizes the URL when assigned to the anchor node similar to the other
2828
* browsers. However, the parsed components will not be set if the URL assigned did not specify
2929
* them. (e.g. if you assign a.href = "foo", then a.protocol, a.host, etc. will be empty.) We
3030
* work around that by performing the parsing in a 2nd step by taking a previously normalized
3131
* URL (e.g. by assigning to a.href) and assigning it a.href again. This correctly populates the
3232
* properties such as protocol, hostname, port, etc.
3333
*
34-
* IE7 does not normalize the URL when assigned to an anchor node. (Apparently, it does, if one
35-
* uses the inner HTML approach to assign the URL as part of an HTML snippet -
36-
* http://stackoverflow.com/a/472729) However, setting img[src] does normalize the URL.
37-
* Unfortunately, setting img[src] to something like "javascript:foo" on IE throws an exception.
38-
* Since the primary usage for normalizing URLs is to sanitize such URLs, we can't use that
39-
* method and IE < 8 is unsupported.
40-
*
4134
* References:
4235
* http://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement
4336
* http://www.aptana.com/reference/html/api/HTMLAnchorElement.html
@@ -65,7 +58,7 @@ var originUrl = urlResolve(window.location.href, true);
6558
function urlResolve(url, base) {
6659
var href = url;
6760

68-
if (msie) {
61+
if (msie < 11) {
6962
// Normalize before parse. Refer Implementation Notes on why this is
7063
// done in two steps on IE.
7164
urlParsingNode.setAttribute("href", href);

src/ngAnimate/animate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ angular.module('ngAnimate', ['ng'])
353353
})
354354

355355
//this private service is only used within CSS-enabled animations
356-
//IE8 + IE9 do not support rAF natively, but that is fine since they
357-
//also don't support transitions and keyframes which means that the code
356+
//IE9 does not support rAF natively, but that is fine since they
357+
//also doesn't support transitions and keyframes which means that the code
358358
//below will never be used by the two browsers.
359359
.factory('$$animateReflow', ['$$rAF', '$document', function($$rAF, $document) {
360360
var bod = $document[0].body;
@@ -1119,7 +1119,7 @@ angular.module('ngAnimate', ['ng'])
11191119
//skip the animation if animations are disabled, a parent is already being animated,
11201120
//the element is not currently attached to the document body or then completely close
11211121
//the animation if any matching animations are not found at all.
1122-
//NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
1122+
//NOTE: IE9 should close properly (run closeAnimation()) in case an animation was found.
11231123
if (animationsDisabled(element, parentElement)) {
11241124
fireDOMOperation();
11251125
fireBeforeCallbackAsync();

src/ngSanitize/sanitize.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ function htmlParser( html, handler ) {
379379
}
380380

381381
var hiddenPre=document.createElement("pre");
382-
var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
383382
/**
384383
* decodes all entities into regular string
385384
* @param value
@@ -388,22 +387,11 @@ var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
388387
function decodeEntities(value) {
389388
if (!value) { return ''; }
390389

391-
// Note: IE8 does not preserve spaces at the start/end of innerHTML
392-
// so we must capture them and reattach them afterward
393-
var parts = spaceRe.exec(value);
394-
var spaceBefore = parts[1];
395-
var spaceAfter = parts[3];
396-
var content = parts[2];
397-
if (content) {
398-
hiddenPre.innerHTML=content.replace(/</g,"&lt;");
399-
// innerText depends on styling as it doesn't display hidden elements.
400-
// Therefore, it's better to use textContent not to cause unnecessary
401-
// reflows. However, IE<9 don't support textContent so the innerText
402-
// fallback is necessary.
403-
content = 'textContent' in hiddenPre ?
404-
hiddenPre.textContent : hiddenPre.innerText;
405-
}
406-
return spaceBefore + content + spaceAfter;
390+
hiddenPre.innerHTML = value.replace(/</g,"&lt;");
391+
// innerText depends on styling as it doesn't display hidden elements.
392+
// Therefore, it's better to use textContent to not cause unnecessary
393+
// reflows.
394+
return hiddenPre.textContent;
407395
}
408396

409397
/**

src/ngScenario/browserTrigger.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
(function() {
4-
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
5-
64
/**
75
* Triggers a browser event. Attempts to choose the right event if one is
86
* not specified.

test/AngularSpec.js

-16
Original file line numberDiff line numberDiff line change
@@ -587,22 +587,6 @@ describe('angular', function() {
587587
expect(log).toEqual(['0:a', '1:c']);
588588
});
589589

590-
if (document.querySelectorAll) {
591-
it('should handle the result of querySelectorAll in IE8 as it has no hasOwnProperty function', function() {
592-
document.body.innerHTML = "<p>" +
593-
"<a name='x'>a</a>" +
594-
"<a name='y'>b</a>" +
595-
"<a name='x'>c</a>" +
596-
"</p>";
597-
598-
var htmlCollection = document.querySelectorAll('[name="x"]'),
599-
log = [];
600-
601-
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
602-
expect(log).toEqual(['0:a', '1:c']);
603-
});
604-
}
605-
606590
it('should handle arguments objects like arrays', function() {
607591
var args,
608592
log = [];

test/ngSanitize/sanitizeSpec.js

-52
Original file line numberDiff line numberDiff line change
@@ -464,55 +464,3 @@ describe('HTML', function() {
464464
});
465465
});
466466
});
467-
468-
describe('decodeEntities', function() {
469-
var handler, text,
470-
origHiddenPre = window.hiddenPre;
471-
472-
beforeEach(function() {
473-
text = '';
474-
handler = {
475-
start: function() {},
476-
chars: function(text_){
477-
text = text_;
478-
},
479-
end: function() {},
480-
comment: function() {}
481-
};
482-
module('ngSanitize');
483-
});
484-
485-
afterEach(function() {
486-
window.hiddenPre = origHiddenPre;
487-
});
488-
489-
it('should use innerText if textContent is not available (IE<9)', function() {
490-
window.hiddenPre = {
491-
innerText: 'INNER_TEXT'
492-
};
493-
inject(function($sanitize) {
494-
htmlParser('<tag>text</tag>', handler);
495-
expect(text).toEqual('INNER_TEXT');
496-
});
497-
});
498-
it('should use textContent if available', function() {
499-
window.hiddenPre = {
500-
textContent: 'TEXT_CONTENT',
501-
innerText: 'INNER_TEXT'
502-
};
503-
inject(function($sanitize) {
504-
htmlParser('<tag>text</tag>', handler);
505-
expect(text).toEqual('TEXT_CONTENT');
506-
});
507-
});
508-
it('should use textContent even if empty', function() {
509-
window.hiddenPre = {
510-
textContent: '',
511-
innerText: 'INNER_TEXT'
512-
};
513-
inject(function($sanitize) {
514-
htmlParser('<tag>text</tag>', handler);
515-
expect(text).toEqual('');
516-
});
517-
});
518-
});

0 commit comments

Comments
 (0)