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

Commit a177156

Browse files
committed
chore(IE8): remove all special code for IE8
Remove all code that was IE8 specific
1 parent 7a36d49 commit a177156

17 files changed

+187
-332
lines changed

src/ng/compile.js

+25-27
Original file line numberDiff line numberDiff line change
@@ -1172,37 +1172,35 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
11721172
var attrEndName = false;
11731173

11741174
attr = nAttrs[j];
1175-
if (!msie || msie >= 8 || attr.specified) {
1176-
name = attr.name;
1177-
value = trim(attr.value);
1178-
1179-
// support ngAttr attribute binding
1180-
ngAttrName = directiveNormalize(name);
1181-
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
1182-
name = snake_case(ngAttrName.substr(6), '-');
1183-
}
1175+
name = attr.name;
1176+
value = trim(attr.value);
11841177

1185-
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1186-
if (directiveIsMultiElement(directiveNName)) {
1187-
if (ngAttrName === directiveNName + 'Start') {
1188-
attrStartName = name;
1189-
attrEndName = name.substr(0, name.length - 5) + 'end';
1190-
name = name.substr(0, name.length - 6);
1191-
}
1192-
}
1178+
// support ngAttr attribute binding
1179+
ngAttrName = directiveNormalize(name);
1180+
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
1181+
name = snake_case(ngAttrName.substr(6), '-');
1182+
}
11931183

1194-
nName = directiveNormalize(name.toLowerCase());
1195-
attrsMap[nName] = name;
1196-
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
1197-
attrs[nName] = value;
1198-
if (getBooleanAttrName(node, nName)) {
1199-
attrs[nName] = true; // presence means true
1200-
}
1184+
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1185+
if (directiveIsMultiElement(directiveNName)) {
1186+
if (ngAttrName === directiveNName + 'Start') {
1187+
attrStartName = name;
1188+
attrEndName = name.substr(0, name.length - 5) + 'end';
1189+
name = name.substr(0, name.length - 6);
12011190
}
1202-
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
1203-
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
1204-
attrEndName);
12051191
}
1192+
1193+
nName = directiveNormalize(name.toLowerCase());
1194+
attrsMap[nName] = name;
1195+
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
1196+
attrs[nName] = value;
1197+
if (getBooleanAttrName(node, nName)) {
1198+
attrs[nName] = true; // presence means true
1199+
}
1200+
}
1201+
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
1202+
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
1203+
attrEndName);
12061204
}
12071205

12081206
// use class as directive

src/ng/httpBackend.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ function createXhr(method) {
44
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
55
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
66
//if it is available
7-
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
8-
!window.XMLHttpRequest)) {
7+
if (!window.XMLHttpRequest) {
98
return new window.ActiveXObject("Microsoft.XMLHTTP");
109
} else if (window.XMLHttpRequest) {
1110
return new window.XMLHttpRequest();

src/ng/sanitizeUri.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ function $$SanitizeUriProvider() {
6161
return function sanitizeUri(uri, isImage) {
6262
var regex = isImage ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist;
6363
var normalizedVal;
64-
// NOTE: urlResolve() doesn't support IE < 8 so we don't sanitize for that case.
65-
if (!msie || msie >= 8 ) {
66-
normalizedVal = urlResolve(uri).href;
67-
if (normalizedVal !== '' && !normalizedVal.match(regex)) {
68-
return 'unsafe:'+normalizedVal;
69-
}
64+
normalizedVal = urlResolve(uri).href;
65+
if (normalizedVal !== '' && !normalizedVal.match(regex)) {
66+
return 'unsafe:'+normalizedVal;
7067
}
7168
return uri;
7269
};

src/ngScenario/browserTrigger.js

+51-79
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
function indexOf(array, obj) {
75
if (array.indexOf) return array.indexOf(obj);
86

@@ -63,96 +61,70 @@
6361
return indexOf(keys, key) !== -1;
6462
}
6563

66-
if (msie < 9) {
67-
if (inputType == 'radio' || inputType == 'checkbox') {
68-
element.checked = !element.checked;
69-
}
70-
71-
// WTF!!! Error: Unspecified error.
72-
// Don't know why, but some elements when detached seem to be in inconsistent state and
73-
// calling .fireEvent() on them will result in very unhelpful error (Error: Unspecified error)
74-
// forcing the browser to compute the element position (by reading its CSS)
75-
// puts the element in consistent state.
76-
element.style.posLeft;
77-
78-
// TODO(vojta): create event objects with pressed keys to get it working on IE<9
79-
var ret = element.fireEvent('on' + eventType);
80-
if (inputType == 'submit') {
81-
while(element) {
82-
if (element.nodeName.toLowerCase() == 'form') {
83-
element.fireEvent('onsubmit');
84-
break;
85-
}
86-
element = element.parentNode;
87-
}
64+
var evnt;
65+
if(/transitionend/.test(eventType)) {
66+
if(window.WebKitTransitionEvent) {
67+
evnt = new WebKitTransitionEvent(eventType, eventData);
68+
evnt.initEvent(eventType, false, true);
8869
}
89-
return ret;
90-
} else {
91-
var evnt;
92-
if(/transitionend/.test(eventType)) {
93-
if(window.WebKitTransitionEvent) {
94-
evnt = new WebKitTransitionEvent(eventType, eventData);
95-
evnt.initEvent(eventType, false, true);
70+
else {
71+
try {
72+
evnt = new TransitionEvent(eventType, eventData);
9673
}
97-
else {
98-
try {
99-
evnt = new TransitionEvent(eventType, eventData);
100-
}
101-
catch(e) {
102-
evnt = document.createEvent('TransitionEvent');
103-
evnt.initTransitionEvent(eventType, null, null, null, eventData.elapsedTime || 0);
104-
}
74+
catch(e) {
75+
evnt = document.createEvent('TransitionEvent');
76+
evnt.initTransitionEvent(eventType, null, null, null, eventData.elapsedTime || 0);
10577
}
10678
}
107-
else if(/animationend/.test(eventType)) {
108-
if(window.WebKitAnimationEvent) {
109-
evnt = new WebKitAnimationEvent(eventType, eventData);
110-
evnt.initEvent(eventType, false, true);
111-
}
112-
else {
113-
try {
114-
evnt = new AnimationEvent(eventType, eventData);
115-
}
116-
catch(e) {
117-
evnt = document.createEvent('AnimationEvent');
118-
evnt.initAnimationEvent(eventType, null, null, null, eventData.elapsedTime || 0);
119-
}
120-
}
79+
}
80+
else if(/animationend/.test(eventType)) {
81+
if(window.WebKitAnimationEvent) {
82+
evnt = new WebKitAnimationEvent(eventType, eventData);
83+
evnt.initEvent(eventType, false, true);
12184
}
12285
else {
123-
evnt = document.createEvent('MouseEvents');
124-
x = x || 0;
125-
y = y || 0;
126-
evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'),
127-
pressed('alt'), pressed('shift'), pressed('meta'), 0, element);
86+
try {
87+
evnt = new AnimationEvent(eventType, eventData);
88+
}
89+
catch(e) {
90+
evnt = document.createEvent('AnimationEvent');
91+
evnt.initAnimationEvent(eventType, null, null, null, eventData.elapsedTime || 0);
92+
}
12893
}
94+
}
95+
else {
96+
evnt = document.createEvent('MouseEvents');
97+
x = x || 0;
98+
y = y || 0;
99+
evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'),
100+
pressed('alt'), pressed('shift'), pressed('meta'), 0, element);
101+
}
129102

130-
/* we're unable to change the timeStamp value directly so this
131-
* is only here to allow for testing where the timeStamp value is
132-
* read */
133-
evnt.$manualTimeStamp = eventData.timeStamp;
103+
/* we're unable to change the timeStamp value directly so this
104+
* is only here to allow for testing where the timeStamp value is
105+
* read */
106+
evnt.$manualTimeStamp = eventData.timeStamp;
134107

135-
if(!evnt) return;
108+
if(!evnt) return;
136109

137-
var originalPreventDefault = evnt.preventDefault,
138-
appWindow = element.ownerDocument.defaultView,
139-
fakeProcessDefault = true,
140-
finalProcessDefault,
141-
angular = appWindow.angular || {};
110+
var originalPreventDefault = evnt.preventDefault,
111+
appWindow = element.ownerDocument.defaultView,
112+
fakeProcessDefault = true,
113+
finalProcessDefault,
114+
angular = appWindow.angular || {};
142115

143-
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
144-
angular['ff-684208-preventDefault'] = false;
145-
evnt.preventDefault = function() {
146-
fakeProcessDefault = false;
147-
return originalPreventDefault.apply(evnt, arguments);
148-
};
116+
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
117+
angular['ff-684208-preventDefault'] = false;
118+
evnt.preventDefault = function() {
119+
fakeProcessDefault = false;
120+
return originalPreventDefault.apply(evnt, arguments);
121+
};
149122

150-
element.dispatchEvent(evnt);
151-
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
123+
element.dispatchEvent(evnt);
124+
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
152125

153-
delete angular['ff-684208-preventDefault'];
126+
delete angular['ff-684208-preventDefault'];
154127

155-
return finalProcessDefault;
156-
}
128+
return finalProcessDefault;
157129
};
158130
}());

test/AngularSpec.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,6 @@ describe('angular', function() {
371371

372372
it('should correctly test for keys that are present on Object.prototype', function() {
373373
/* jshint -W001 */
374-
// MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return
375-
// things like hasOwnProperty even if it is explicitly defined on the actual object!
376-
if (msie<=8) return;
377374
expect(equals({}, {hasOwnProperty: 1})).toBe(false);
378375
expect(equals({}, {toString: null})).toBe(false);
379376
});
@@ -964,15 +961,13 @@ describe('angular', function() {
964961
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
965962
});
966963

967-
if (!msie || msie >= 9) {
968-
it('should correctly detect node name with "namespace" when xmlns is NOT defined', function() {
969-
var div = jqLite('<div xmlns:ngtest="http://angularjs.org/">' +
970-
'<ngtest:foo ngtest:attr="bar"></ng-test>' +
971-
'</div>')[0];
972-
expect(nodeName_(div.childNodes[0])).toBe('ngtest:foo');
973-
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
974-
});
975-
}
964+
it('should correctly detect node name with "namespace" when xmlns is NOT defined', function() {
965+
var div = jqLite('<div xmlns:ngtest="http://angularjs.org/">' +
966+
'<ngtest:foo ngtest:attr="bar"></ng-test>' +
967+
'</div>')[0];
968+
expect(nodeName_(div.childNodes[0])).toBe('ngtest:foo');
969+
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
970+
});
976971
});
977972

978973

test/jqLiteSpec.js

+7-36
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,7 @@ describe('jqLite', function() {
594594
expect(input.attr('READONLY')).toBe('readonly');
595595

596596
input.attr('readonly', false);
597-
598-
// attr('readonly') fails in jQuery 1.6.4, so we have to bypass it
599-
//expect(input.attr('readOnly')).toBeUndefined();
600-
//expect(input.attr('readonly')).toBeUndefined();
601-
if (msie < 9) {
602-
expect(input[0].getAttribute('readonly')).toBe('');
603-
} else {
604-
expect(input[0].getAttribute('readonly')).toBe(null);
605-
}
606-
//expect('readOnly' in input[0].attributes).toBe(false);
597+
expect(input[0].getAttribute('readonly')).toBe(null);
607598

608599
input.attr('readOnly', 'READonly');
609600
expect(input.attr('readonly')).toBe('readonly');
@@ -877,26 +868,15 @@ describe('jqLite', function() {
877868
expect(jqLite(b).css('margin')).toEqual('3px');
878869

879870
selector.css('margin', '');
880-
if (msie <= 8) {
881-
expect(jqLite(a).css('margin')).toBe('auto');
882-
expect(jqLite(b).css('margin')).toBe('auto');
883-
} else {
884-
expect(jqLite(a).css('margin')).toBeFalsy();
885-
expect(jqLite(b).css('margin')).toBeFalsy();
886-
}
871+
expect(jqLite(a).css('margin')).toBeFalsy();
872+
expect(jqLite(b).css('margin')).toBeFalsy();
887873
});
888874

889875

890876
it('should set a bunch of css properties specified via an object', function() {
891-
if (msie <= 8) {
892-
expect(jqLite(a).css('margin')).toBe('auto');
893-
expect(jqLite(a).css('padding')).toBe('0px');
894-
expect(jqLite(a).css('border')).toBeUndefined();
895-
} else {
896-
expect(jqLite(a).css('margin')).toBeFalsy();
897-
expect(jqLite(a).css('padding')).toBeFalsy();
898-
expect(jqLite(a).css('border')).toBeFalsy();
899-
}
877+
expect(jqLite(a).css('margin')).toBeFalsy();
878+
expect(jqLite(a).css('padding')).toBeFalsy();
879+
expect(jqLite(a).css('border')).toBeFalsy();
900880

901881
jqLite(a).css({'margin': '1px', 'padding': '2px', 'border': ''});
902882

@@ -1127,14 +1107,7 @@ describe('jqLite', function() {
11271107
if (window.jQuery) return;
11281108
var browserMoveTrigger = function(from, to){
11291109
var fireEvent = function(type, element, relatedTarget){
1130-
var evnt, msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
1131-
if (msie < 9){
1132-
evnt = document.createEventObject();
1133-
evnt.srcElement = element;
1134-
evnt.relatedTarget = relatedTarget;
1135-
element.fireEvent('on' + type, evnt);
1136-
return;
1137-
}
1110+
var evnt;
11381111
evnt = document.createEvent('MouseEvents');
11391112

11401113
var originalPreventDefault = evnt.preventDefault,
@@ -1477,8 +1450,6 @@ describe('jqLite', function() {
14771450
});
14781451

14791452
it('should select all types iframe contents', function() {
1480-
// IE8 does not like this test, although the functionality may still work there.
1481-
if (msie < 9) return;
14821453
var iframe_ = document.createElement('iframe');
14831454
var tested = false;
14841455
var iframe = jqLite(iframe_);

test/ng/compileSpec.js

-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ describe('$compile', function() {
389389
// it turns out that when a browser plugin is bound to an DOM element (typically <object>),
390390
// the plugin's context rather than the usual DOM apis are exposed on this element, so
391391
// childNodes might not exist.
392-
if (msie < 9) return;
393392

394393
element = jqLite('<div>{{1+2}}</div>');
395394

0 commit comments

Comments
 (0)