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

Commit e843ae7

Browse files
lgalfasoIgorMinar
authored andcommitted
chore(IE8): remove all special code for IE8
Remove all code that was IE8 specific Closes #8837
1 parent 40d8da8 commit e843ae7

17 files changed

+185
-343
lines changed

src/ng/compile.js

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

13581358
attr = nAttrs[j];
1359-
if (!msie || msie >= 8 || attr.specified) {
1360-
name = attr.name;
1361-
value = trim(attr.value);
1362-
1363-
// support ngAttr attribute binding
1364-
ngAttrName = directiveNormalize(name);
1365-
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
1366-
name = snake_case(ngAttrName.substr(6), '-');
1367-
}
1359+
name = attr.name;
1360+
value = trim(attr.value);
13681361

1369-
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1370-
if (directiveIsMultiElement(directiveNName)) {
1371-
if (ngAttrName === directiveNName + 'Start') {
1372-
attrStartName = name;
1373-
attrEndName = name.substr(0, name.length - 5) + 'end';
1374-
name = name.substr(0, name.length - 6);
1375-
}
1376-
}
1362+
// support ngAttr attribute binding
1363+
ngAttrName = directiveNormalize(name);
1364+
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
1365+
name = snake_case(ngAttrName.substr(6), '-');
1366+
}
13771367

1378-
nName = directiveNormalize(name.toLowerCase());
1379-
attrsMap[nName] = name;
1380-
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
1381-
attrs[nName] = value;
1382-
if (getBooleanAttrName(node, nName)) {
1383-
attrs[nName] = true; // presence means true
1384-
}
1368+
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1369+
if (directiveIsMultiElement(directiveNName)) {
1370+
if (ngAttrName === directiveNName + 'Start') {
1371+
attrStartName = name;
1372+
attrEndName = name.substr(0, name.length - 5) + 'end';
1373+
name = name.substr(0, name.length - 6);
13851374
}
1386-
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
1387-
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
1388-
attrEndName);
13891375
}
1376+
1377+
nName = directiveNormalize(name.toLowerCase());
1378+
attrsMap[nName] = name;
1379+
if (isNgAttr || !attrs.hasOwnProperty(nName)) {
1380+
attrs[nName] = value;
1381+
if (getBooleanAttrName(node, nName)) {
1382+
attrs[nName] = true; // presence means true
1383+
}
1384+
}
1385+
addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
1386+
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
1387+
attrEndName);
13901388
}
13911389

13921390
// use class as directive

src/ng/directive/a.js

-16
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@
1616
var htmlAnchorDirective = valueFn({
1717
restrict: 'E',
1818
compile: function(element, attr) {
19-
20-
if (msie <= 8) {
21-
22-
// turn <a href ng-click="..">link</a> into a stylable link in IE
23-
// but only if it doesn't have name attribute, in which case it's an anchor
24-
if (!attr.href && !attr.name) {
25-
attr.$set('href', '');
26-
}
27-
28-
// add a comment node to anchors to workaround IE bug that causes element content to be reset
29-
// to new attribute content if attribute is updated with value containing @ and element also
30-
// contains value with @
31-
// see issue #1949
32-
element.append(document.createComment('IE fix'));
33-
}
34-
3519
if (!attr.href && !attr.xlinkHref && !attr.name) {
3620
return function(scope, element) {
3721
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.

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-77
Original file line numberDiff line numberDiff line change
@@ -52,96 +52,70 @@
5252
return keys.indexOf(key) !== -1;
5353
}
5454

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

119-
/* we're unable to change the timeStamp value directly so this
120-
* is only here to allow for testing where the timeStamp value is
121-
* read */
122-
evnt.$manualTimeStamp = eventData.timeStamp;
94+
/* we're unable to change the timeStamp value directly so this
95+
* is only here to allow for testing where the timeStamp value is
96+
* read */
97+
evnt.$manualTimeStamp = eventData.timeStamp;
12398

124-
if(!evnt) return;
99+
if(!evnt) return;
125100

126-
var originalPreventDefault = evnt.preventDefault,
127-
appWindow = element.ownerDocument.defaultView,
128-
fakeProcessDefault = true,
129-
finalProcessDefault,
130-
angular = appWindow.angular || {};
101+
var originalPreventDefault = evnt.preventDefault,
102+
appWindow = element.ownerDocument.defaultView,
103+
fakeProcessDefault = true,
104+
finalProcessDefault,
105+
angular = appWindow.angular || {};
131106

132-
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
133-
angular['ff-684208-preventDefault'] = false;
134-
evnt.preventDefault = function() {
135-
fakeProcessDefault = false;
136-
return originalPreventDefault.apply(evnt, arguments);
137-
};
107+
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
108+
angular['ff-684208-preventDefault'] = false;
109+
evnt.preventDefault = function() {
110+
fakeProcessDefault = false;
111+
return originalPreventDefault.apply(evnt, arguments);
112+
};
138113

139-
element.dispatchEvent(evnt);
140-
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
114+
element.dispatchEvent(evnt);
115+
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
141116

142-
delete angular['ff-684208-preventDefault'];
117+
delete angular['ff-684208-preventDefault'];
143118

144-
return finalProcessDefault;
145-
}
119+
return finalProcessDefault;
146120
};
147121
}());

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
});
@@ -1033,15 +1030,13 @@ describe('angular', function() {
10331030
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
10341031
});
10351032

1036-
if (!msie || msie >= 9) {
1037-
it('should correctly detect node name with "namespace" when xmlns is NOT defined', function() {
1038-
var div = jqLite('<div xmlns:ngtest="http://angularjs.org/">' +
1039-
'<ngtest:foo ngtest:attr="bar"></ng-test>' +
1040-
'</div>')[0];
1041-
expect(nodeName_(div.childNodes[0])).toBe('ngtest:foo');
1042-
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
1043-
});
1044-
}
1033+
it('should correctly detect node name with "namespace" when xmlns is NOT defined', function() {
1034+
var div = jqLite('<div xmlns:ngtest="http://angularjs.org/">' +
1035+
'<ngtest:foo ngtest:attr="bar"></ng-test>' +
1036+
'</div>')[0];
1037+
expect(nodeName_(div.childNodes[0])).toBe('ngtest:foo');
1038+
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
1039+
});
10451040
});
10461041

10471042

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

@@ -1185,14 +1165,7 @@ describe('jqLite', function() {
11851165
if (window.jQuery) return;
11861166
var browserMoveTrigger = function(from, to){
11871167
var fireEvent = function(type, element, relatedTarget){
1188-
var evnt, msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
1189-
if (msie < 9){
1190-
evnt = document.createEventObject();
1191-
evnt.srcElement = element;
1192-
evnt.relatedTarget = relatedTarget;
1193-
element.fireEvent('on' + type, evnt);
1194-
return;
1195-
}
1168+
var evnt;
11961169
evnt = document.createEvent('MouseEvents');
11971170

11981171
var originalPreventDefault = evnt.preventDefault,
@@ -1535,8 +1508,6 @@ describe('jqLite', function() {
15351508
});
15361509

15371510
it('should select all types iframe contents', function() {
1538-
// IE8 does not like this test, although the functionality may still work there.
1539-
if (msie < 9) return;
15401511
var iframe_ = document.createElement('iframe');
15411512
var tested = false;
15421513
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)