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

Commit 2492866

Browse files
committed
chore(IE8) Remove more special code for IE8
1 parent 77d8ae1 commit 2492866

File tree

10 files changed

+16
-109
lines changed

10 files changed

+16
-109
lines changed

src/Angular.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ function forEach(obj, iterator, context) {
245245
if (obj) {
246246
if (isFunction(obj)) {
247247
for (key in obj) {
248-
// Need to check if hasOwnProperty exists,
249-
// as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
250-
if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
248+
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
251249
iterator.call(context, obj[key], key, obj);
252250
}
253251
}

src/jqLite.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,9 @@ function jqLiteClone(element) {
254254
function jqLiteDealoc(element, onlyDescendants) {
255255
if (!onlyDescendants) jqLiteRemoveData(element);
256256

257-
if (element.querySelectorAll) {
258-
var descendants = element.querySelectorAll('*');
259-
for (var i = 0, l = descendants.length; i < l; i++) {
260-
jqLiteRemoveData(descendants[i]);
261-
}
257+
var descendants = element.querySelectorAll('*');
258+
for (var i = 0, l = descendants.length; i < l; i++) {
259+
jqLiteRemoveData(descendants[i]);
262260
}
263261
}
264262

src/ng/directive/form.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,7 @@ var formDirectiveFactory = function(isNgForm) {
471471
controller.$setSubmitted();
472472
});
473473

474-
event.preventDefault
475-
? event.preventDefault()
476-
: event.returnValue = false; // IE
474+
event.preventDefault();
477475
};
478476

479477
addEventListenerFn(formElement[0], 'submit', handleFormSubmission);

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/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function LocationHashbangInHtml5Url(appBase, hashPrefix) {
296296
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
297297

298298
this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
299-
// include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
299+
// include hashPrefix in $$absUrl when $$url is empty so IE9 do not reload page because of removal of '#'
300300
this.$$absUrl = appBase + hashPrefix + this.$$url;
301301
};
302302

src/ng/urlUtils.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,13 @@ var originUrl = urlResolve(window.location.href);
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 <= 11 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

src/ngAnimate/animate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ angular.module('ngAnimate', ['ng'])
420420
})
421421

422422
//this private service is only used within CSS-enabled animations
423-
//IE8 + IE9 do not support rAF natively, but that is fine since they
424-
//also don't support transitions and keyframes which means that the code
423+
//IE9 does not support rAF natively, but that is fine since they
424+
//also doesn't support transitions and keyframes which means that the code
425425
//below will never be used by the two browsers.
426426
.factory('$$animateReflow', ['$$rAF', '$document', function($$rAF, $document) {
427427
var bod = $document[0].body;
@@ -1294,7 +1294,7 @@ angular.module('ngAnimate', ['ng'])
12941294
//skip the animation if animations are disabled, a parent is already being animated,
12951295
//the element is not currently attached to the document body or then completely close
12961296
//the animation if any matching animations are not found at all.
1297-
//NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
1297+
//NOTE: IE9 should close properly (run closeAnimation()) in case an animation was found.
12981298
if (animationsDisabled(element, parentElement)) {
12991299
fireDOMOperation();
13001300
fireBeforeCallbackAsync();

src/ngSanitize/sanitize.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ function htmlParser(html, handler) {
410410
}
411411

412412
var hiddenPre=document.createElement("pre");
413-
var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
414413
/**
415414
* decodes all entities into regular string
416415
* @param value
@@ -419,22 +418,11 @@ var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
419418
function decodeEntities(value) {
420419
if (!value) { return ''; }
421420

422-
// Note: IE8 does not preserve spaces at the start/end of innerHTML
423-
// so we must capture them and reattach them afterward
424-
var parts = spaceRe.exec(value);
425-
var spaceBefore = parts[1];
426-
var spaceAfter = parts[3];
427-
var content = parts[2];
428-
if (content) {
429-
hiddenPre.innerHTML=content.replace(/</g,"&lt;");
430-
// innerText depends on styling as it doesn't display hidden elements.
431-
// Therefore, it's better to use textContent not to cause unnecessary
432-
// reflows. However, IE<9 don't support textContent so the innerText
433-
// fallback is necessary.
434-
content = 'textContent' in hiddenPre ?
435-
hiddenPre.textContent : hiddenPre.innerText;
436-
}
437-
return spaceBefore + content + spaceAfter;
421+
hiddenPre.innerHTML = value.replace(/</g,"&lt;");
422+
// innerText depends on styling as it doesn't display hidden elements.
423+
// Therefore, it's better to use textContent to not cause unnecessary
424+
// reflows.
425+
return hiddenPre.textContent;
438426
}
439427

440428
/**

test/AngularSpec.js

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

562-
if (document.querySelectorAll) {
563-
it('should handle the result of querySelectorAll in IE8 as it has no hasOwnProperty function', function() {
564-
document.body.innerHTML = "<p>" +
565-
"<a name='x'>a</a>" +
566-
"<a name='y'>b</a>" +
567-
"<a name='x'>c</a>" +
568-
"</p>";
569-
570-
var htmlCollection = document.querySelectorAll('[name="x"]'),
571-
log = [];
572-
573-
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
574-
expect(log).toEqual(['0:a', '1:c']);
575-
});
576-
}
577-
578562
it('should handle arguments objects like arrays', function() {
579563
var args,
580564
log = [];

test/ngSanitize/sanitizeSpec.js

-52
Original file line numberDiff line numberDiff line change
@@ -485,55 +485,3 @@ describe('HTML', function() {
485485
});
486486
});
487487
});
488-
489-
describe('decodeEntities', function() {
490-
var handler, text,
491-
origHiddenPre = window.hiddenPre;
492-
493-
beforeEach(function() {
494-
text = '';
495-
handler = {
496-
start: function() {},
497-
chars: function(text_) {
498-
text = text_;
499-
},
500-
end: function() {},
501-
comment: function() {}
502-
};
503-
module('ngSanitize');
504-
});
505-
506-
afterEach(function() {
507-
window.hiddenPre = origHiddenPre;
508-
});
509-
510-
it('should use innerText if textContent is not available (IE<9)', function() {
511-
window.hiddenPre = {
512-
innerText: 'INNER_TEXT'
513-
};
514-
inject(function($sanitize) {
515-
htmlParser('<tag>text</tag>', handler);
516-
expect(text).toEqual('INNER_TEXT');
517-
});
518-
});
519-
it('should use textContent if available', function() {
520-
window.hiddenPre = {
521-
textContent: 'TEXT_CONTENT',
522-
innerText: 'INNER_TEXT'
523-
};
524-
inject(function($sanitize) {
525-
htmlParser('<tag>text</tag>', handler);
526-
expect(text).toEqual('TEXT_CONTENT');
527-
});
528-
});
529-
it('should use textContent even if empty', function() {
530-
window.hiddenPre = {
531-
textContent: '',
532-
innerText: 'INNER_TEXT'
533-
};
534-
inject(function($sanitize) {
535-
htmlParser('<tag>text</tag>', handler);
536-
expect(text).toEqual('');
537-
});
538-
});
539-
});

0 commit comments

Comments
 (0)