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

refactor: remove the remaining IE8 code bits from the codebase #9356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/content/error/$httpBackend/noxhr.ngdoc

This file was deleted.

17 changes: 0 additions & 17 deletions docs/content/error/$sce/iequirks.ngdoc

This file was deleted.

52 changes: 25 additions & 27 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,37 +1218,35 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var attrEndName = false;

attr = nAttrs[j];
if (!msie || msie >= 8 || attr.specified) {
name = attr.name;
value = trim(attr.value);

// support ngAttr attribute binding
ngAttrName = directiveNormalize(name);
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
name = snake_case(ngAttrName.substr(6), '-');
}
name = attr.name;
value = trim(attr.value);

var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
if (directiveIsMultiElement(directiveNName)) {
if (ngAttrName === directiveNName + 'Start') {
attrStartName = name;
attrEndName = name.substr(0, name.length - 5) + 'end';
name = name.substr(0, name.length - 6);
}
}
// support ngAttr attribute binding
ngAttrName = directiveNormalize(name);
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
name = snake_case(ngAttrName.substr(6), '-');
}

nName = directiveNormalize(name.toLowerCase());
attrsMap[nName] = name;
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
attrs[nName] = value;
if (getBooleanAttrName(node, nName)) {
attrs[nName] = true; // presence means true
}
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
if (directiveIsMultiElement(directiveNName)) {
if (ngAttrName === directiveNName + 'Start') {
attrStartName = name;
attrEndName = name.substr(0, name.length - 5) + 'end';
name = name.substr(0, name.length - 6);
}
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
attrEndName);
}

nName = directiveNormalize(name.toLowerCase());
attrsMap[nName] = name;
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
attrs[nName] = value;
if (getBooleanAttrName(node, nName)) {
attrs[nName] = true; // presence means true
}
}
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
attrEndName);
}

// use class as directive
Expand Down
16 changes: 0 additions & 16 deletions src/ng/directive/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@
var htmlAnchorDirective = valueFn({
restrict: 'E',
compile: function(element, attr) {

if (msie <= 8) {

// turn <a href ng-click="..">link</a> into a stylable link in IE
// but only if it doesn't have name attribute, in which case it's an anchor
if (!attr.href && !attr.name) {
attr.$set('href', '');
}

// add a comment node to anchors to workaround IE bug that causes element content to be reset
// to new attribute content if attribute is updated with value containing @ and element also
// contains value with @
// see issue #1949
element.append(document.createComment('IE fix'));
}

if (!attr.href && !attr.xlinkHref && !attr.name) {
return function(scope, element) {
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
Expand Down
17 changes: 4 additions & 13 deletions src/ng/httpBackend.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
'use strict';

function createXhr(method) {
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
//if it is available
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
!window.XMLHttpRequest)) {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
return new window.XMLHttpRequest();
}

throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest.");
// TODO: inline the constructor call and remove this helper method
function createXhr() {
return new window.XMLHttpRequest();
}

/**
Expand Down Expand Up @@ -59,7 +50,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
});
} else {

var xhr = createXhr(method);
var xhr = createXhr();

xhr.open(method, url, true);
forEach(headers, function(value, key) {
Expand Down
12 changes: 5 additions & 7 deletions src/ng/sanitizeUri.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ function $$SanitizeUriProvider() {
this.$get = function() {
return function sanitizeUri(uri, isImage) {
var regex = isImage ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist;
var normalizedVal;
// NOTE: urlResolve() doesn't support IE < 8 so we don't sanitize for that case.
if (!msie || msie >= 8 ) {
normalizedVal = urlResolve(uri).href;
if (normalizedVal !== '' && !normalizedVal.match(regex)) {
return 'unsafe:'+normalizedVal;
}
var normalizedVal = urlResolve(uri).href;

if (normalizedVal !== '' && !normalizedVal.match(regex)) {
return 'unsafe:'+normalizedVal;
}

return uri;
};
};
Expand Down
8 changes: 0 additions & 8 deletions src/ng/sce.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,14 +729,6 @@ function $SceProvider() {

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

var sce = shallowCopy(SCE_CONTEXTS);

Expand Down
56 changes: 0 additions & 56 deletions test/ng/sceSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,62 +26,6 @@ describe('SCE', function() {
}));
});

describe('IE8 quirks mode', function() {
function runTest(enabled, documentMode, expectException) {
module(function($provide) {
$provide.value('$sniffer', {
msie: documentMode,
msieDocumentMode: documentMode
});
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
});

inject(function($window, $injector) {
function constructSce() {
/* global $SceProvider: false */
var sceProvider = new $SceProvider();
sceProvider.enabled(enabled);
return $injector.invoke(sceProvider.$get, sceProvider);
}

if (expectException) {
expect(constructSce).toThrowMinErr(
'$sce', 'iequirks', 'Strict Contextual Escaping does not support Internet Explorer ' +
'version < 9 in quirks mode. You can fix this by adding the text <!doctype html> to ' +
'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' +
'information.');
} else {
// no exception.
constructSce();
}
});
}

it('should throw an exception when sce is enabled in quirks mode', function() {
runTest(true, 7, true);
});

it('should NOT throw an exception when sce is enabled and in standards mode', function() {
runTest(true, 8, false);
});

it('should NOT throw an exception when sce is enabled and documentMode is undefined', function() {
runTest(true, undefined, false);
});

it('should NOT throw an exception when sce is disabled even when in quirks mode', function() {
runTest(false, 7, false);
});

it('should NOT throw an exception when sce is disabled and in standards mode', function() {
runTest(false, 8, false);
});

it('should NOT throw an exception when sce is disabled and documentMode is undefined', function() {
runTest(false, undefined, false);
});
});

describe('when enabled', function() {
it('should wrap string values with TrustedValueHolder', inject(function($sce) {
var originalValue = 'original_value';
Expand Down