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

Commit f6a1ad5

Browse files
committed
refactor(*): remove workarounds for IE <9, update IE/Edge-related comments
1 parent d9128e7 commit f6a1ad5

17 files changed

+55
-115
lines changed

docs/config/templates/ngdoc/api/directive.template.html

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ <h2 id="usage">Usage</h2>
1818
<ul>
1919
{% if doc.restrict.element %}
2020
<li>as element:
21-
{% if doc.name.indexOf('ng') == 0 -%}
22-
(This directive can be used as custom element, but be aware of <a href="guide/ie">IE restrictions</a>).
23-
{%- endif %}
2421
{% code %}
2522
<{$ doc.name | dashCase $}
2623
{%- for param in doc.params %}

docs/content/guide/bootstrap.ngdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ initialization.
4040
<html ng-app>
4141

4242
3. If you choose to use the old style directive syntax `ng:` then include xml-namespace in `html`
43-
to make IE happy. (This is here for historical reasons, and we no longer recommend use of
44-
`ng:`.)
43+
when running the page in the XHTML mode. (This is here for historical reasons, and we no longer
44+
recommend use of `ng:`.)
4545

4646
<html xmlns:ng="http://angularjs.org">
4747

docs/content/guide/ie.ngdoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div class="alert alert-warning">
99
**Note:** AngularJS 1.3 has dropped support for IE8. Read more about it on
10-
[our blog](http://blog.angularjs.org/2013/12/angularjs-13-new-release-approaches.html).
10+
[our blog](https://blog.angularjs.org/2013/12/angularjs-13-new-release-approaches.html).
1111
AngularJS 1.2 will continue to support IE8, but the core team does not plan to spend time
1212
addressing issues specific to IE8 or earlier.
1313
</div>
@@ -19,16 +19,16 @@ on IE.
1919
The project currently supports and will attempt to fix bugs for IE9 and above. The continuous
2020
integration server runs all the tests against IE9, IE10, and IE11. See
2121
[Travis CI](https://travis-ci.org/angular/angular.js) and
22-
[ci.angularjs.org](http://ci.angularjs.org).
22+
[ci.angularjs.org](https://ci.angularjs.org).
2323

2424
We do not run tests on IE8 and below. A subset of the AngularJS functionality may work on these
2525
browsers, but it is up to you to test and decide whether it works for your particular app.
2626

2727

2828
To ensure your Angular application works on IE please consider:
2929

30-
1. Use `ng-style` tags instead of `style="{{ someCss }}"`. The latter works in Chrome and Firefox
31-
but does not work in Internet Explorer <= 11 (the most recent version at time of writing).
30+
1. Use `ng-style` tags instead of `style="{{ someCss }}"`. The latter works in Chrome, Firefox,
31+
Safari and Edge but does not work in Internet Explorer (even 11).
3232
2. For the `type` attribute of buttons, use `ng-attr-type` tags instead of
3333
`type="{{ someExpression }}"`. If using the latter, Internet Explorer overwrites the expression
3434
with `type="submit"` before Angular has a chance to interpolate it.

docs/content/misc/faq.ngdoc

+2-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ We run our extensive test suite against the following browsers: the latest versi
142142
Firefox, Safari, and Safari for iOS, as well as Internet Explorer versions 9-11. See
143143
{@link guide/ie Internet Explorer Compatibility} for more details on supporting legacy IE browsers.
144144

145-
If a browser is untested, it doesn't mean it won't work; for example, older Android (2.3.x)
146-
is supported in the sense that we avoid the dot notation for reserved words as property names,
147-
but we don't actively test changes against it. You can also expect browsers to work that share
148-
a large part of their codebase with a browser we test, such as Opera > version 12
145+
If a browser is untested, it doesn't mean it won't work. You can also expect browsers to work that
146+
share a large part of their codebase with a browser we test, such as Opera 15 or newer
149147
(uses the Blink engine), or the various Firefox derivatives.
150148

151149

src/Angular.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ function fromJson(json) {
13691369

13701370
var ALL_COLONS = /:/g;
13711371
function timezoneToOffset(timezone, fallback) {
1372-
// Support: IE 9-11 only, Edge 13-14+
1372+
// Support: IE 9-11 only, Edge 13-15+
13731373
// IE/Edge do not "understand" colon (`:`) in timezone
13741374
timezone = timezone.replace(ALL_COLONS, '');
13751375
var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
@@ -1396,12 +1396,7 @@ function convertTimezoneToLocal(date, timezone, reverse) {
13961396
* @returns {string} Returns the string representation of the element.
13971397
*/
13981398
function startingTag(element) {
1399-
element = jqLite(element).clone();
1400-
try {
1401-
// turns out IE does not let you set .html() on elements which
1402-
// are not allowed to have children. So we just ignore it.
1403-
element.empty();
1404-
} catch (e) { /* empty */ }
1399+
element = jqLite(element).clone().empty();
14051400
var elemHtml = jqLite('<div>').append(element).html();
14061401
try {
14071402
return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) :
@@ -1539,6 +1534,7 @@ function allowAutoBootstrap(document) {
15391534
var script = document.currentScript;
15401535

15411536
if (!script) {
1537+
// Support: IE 9-11 only
15421538
// IE does not have `document.currentScript`
15431539
return true;
15441540
}

src/ng/directive/ngOptions.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
407407
}
408408

409409

410-
// we can't just jqLite('<option>') since jqLite is not smart enough
410+
// Support: IE 9 only
411+
// We can't just jqLite('<option>') since jqLite is not smart enough
411412
// to create it in <select> and IE barfs otherwise.
412413
var optionTemplate = window.document.createElement('option'),
413414
optGroupTemplate = window.document.createElement('optgroup');
@@ -619,7 +620,8 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
619620
function updateOptionElement(option, element) {
620621
option.element = element;
621622
element.disabled = option.disabled;
622-
// NOTE: The label must be set before the value, otherwise IE10/11/EDGE create unresponsive
623+
// Support: IE 11 only, Edge 12-13 only
624+
// NOTE: The label must be set before the value, otherwise IE 11 & Edge create unresponsive
623625
// selects in certain circumstances when multiple selects are next to each other and display
624626
// the option list in listbox style, i.e. the select is [multiple], or specifies a [size].
625627
// See https://github.com/angular/angular.js/issues/11314 for more info.

src/ng/directive/select.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
var noopNgModelController = { $setViewValue: noop, $render: noop };
66

77
function setOptionSelectedStatus(optionEl, value) {
8-
optionEl.prop('selected', value); // needed for IE
8+
optionEl.prop('selected', value);
99
/**
1010
* When unselecting an option, setting the property to null / false should be enough
1111
* However, screenreaders might react to the selected attribute instead, see
@@ -40,6 +40,7 @@ var SelectController =
4040
// does not match any of the options. When it is rendered the value of the unknown
4141
// option is '? XXX ?' where XXX is the hashKey of the value that is not known.
4242
//
43+
// Support: IE 9 only
4344
// We can't just jqLite('<option>') since jqLite is not smart enough
4445
// to create it in <select> and IE barfs otherwise.
4546
self.unknownOption = jqLite(window.document.createElement('option'));
@@ -620,10 +621,11 @@ var selectDirective = function() {
620621
includes(value, selectCtrl.selectValueMap[option.value]));
621622
var currentlySelected = option.selected;
622623

623-
// IE and Edge, adding options to the selection via shift+click/UP/DOWN,
624+
// Support: IE 9-11 only, Edge 12-15+
625+
// In IE and Edge adding options to the selection via shift+click/UP/DOWN
624626
// will de-select already selected options if "selected" on those options was set
625627
// more than once (i.e. when the options were already selected)
626-
// So we only modify the selected property if neccessary.
628+
// So we only modify the selected property if necessary.
627629
// Note: this behavior cannot be replicated via unit tests because it only shows in the
628630
// actual user interface.
629631
if (shouldBeSelected !== currentlySelected) {

src/ngSanitize/sanitize.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -313,26 +313,15 @@ function $SanitizeProvider() {
313313
return obj;
314314
}
315315

316-
var inertBodyElement;
317-
(function(window) {
316+
var inertBodyElement = (function(window) {
318317
var doc;
319318
if (window.document && window.document.implementation) {
320319
doc = window.document.implementation.createHTMLDocument('inert');
321320
} else {
322321
throw $sanitizeMinErr('noinert', 'Can\'t create an inert html document');
323322
}
324323
var docElement = doc.documentElement || doc.getDocumentElement();
325-
var bodyElements = docElement.getElementsByTagName('body');
326-
327-
// usually there should be only one body element in the document, but IE doesn't have any, so we need to create one
328-
if (bodyElements.length === 1) {
329-
inertBodyElement = bodyElements[0];
330-
} else {
331-
var html = doc.createElement('html');
332-
inertBodyElement = doc.createElement('body');
333-
html.appendChild(inertBodyElement);
334-
doc.appendChild(html);
335-
}
324+
return docElement.getElementsByTagName('body')[0];
336325
})(window);
337326

338327
/**
@@ -363,6 +352,7 @@ function $SanitizeProvider() {
363352
}
364353
mXSSAttempts--;
365354

355+
// Support: IE 9-11 only
366356
// strip custom-namespaced attributes on IE<=11
367357
if (window.document.documentMode) {
368358
stripCustomNsAttrs(inertBodyElement);

test/AngularSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,7 @@ describe('angular', function() {
17331733
dealoc(appElement);
17341734
});
17351735

1736+
// Support: IE 9-11 only
17361737
// IE does not support `document.currentScript` (nor extensions with protocol), so skip tests.
17371738
if (!msie) {
17381739
describe('auto bootstrap restrictions', function() {

test/helpers/privateMocks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function xthey(msg, vals, spec) {
3131
}
3232

3333
function browserSupportsCssAnimations() {
34-
// Support: IE < 10
35-
// Only IE10+ support keyframes / transitions
34+
// Support: IE 9 only
35+
// Only IE 10+ support keyframes / transitions
3636
return !(window.document.documentMode < 10);
3737
}
3838

test/helpers/testabilityPatch.js

+1-20
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ beforeEach(function() {
3030
if (window.publishExternalAPI) {
3131
publishExternalAPI(angular);
3232

33-
// workaround for IE bug https://plus.google.com/104744871076396904202/posts/Kqjuj6RSbbT
34-
// IE overwrite window.jQuery with undefined because of empty jQuery var statement, so we have to
35-
// correct this, but only if we are not running in jqLite mode
36-
if (!_jqLiteMode && _jQuery !== jQuery) {
37-
jQuery = _jQuery;
38-
}
39-
4033
// This resets global id counter;
4134
uid = 0;
4235

@@ -184,6 +177,7 @@ function sortedHtml(element, showNgClass) {
184177

185178
var attr = attributes[i];
186179
if (attr.name.match(/^ng[:-]/) ||
180+
!/^ng\d+/.test(attr.name) &&
187181
(attr.value || attr.value === '') &&
188182
attr.value !== 'null' &&
189183
attr.value !== 'auto' &&
@@ -199,19 +193,6 @@ function sortedHtml(element, showNgClass) {
199193
attr.name !== 'tabIndex' &&
200194
attr.name !== 'style' &&
201195
attr.name.substr(0, 6) !== 'jQuery') {
202-
// in IE we need to check for all of these.
203-
if (/ng\d+/.exec(attr.name) ||
204-
attr.name === 'getElementById' ||
205-
// IE7 has `selected` in attributes
206-
attr.name === 'selected' ||
207-
// IE7 adds `value` attribute to all LI tags
208-
(node.nodeName === 'LI' && attr.name === 'value') ||
209-
// IE8 adds bogus rowspan=1 and colspan=1 to TD elements
210-
(node.nodeName === 'TD' && attr.name === 'rowSpan' && attr.value === '1') ||
211-
(node.nodeName === 'TD' && attr.name === 'colSpan' && attr.value === '1')) {
212-
continue;
213-
}
214-
215196
attrs.push(' ' + attr.name + '="' + attr.value + '"');
216197
}
217198
}

test/jqLiteSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ describe('jqLite', function() {
13681368
expect(callback).toHaveBeenCalledTimes(1);
13691369
});
13701370

1371-
it('should set event.target on IE', function() {
1371+
it('should set event.target', function() {
13721372
var elm = jqLite(a);
13731373
elm.on('click', function(event) {
13741374
expect(event.target).toBe(a);

test/minErrSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('minErr', function() {
5353
arr, obj, anonFn, namedFn);
5454

5555
expect(myError.message).toContain('[test:26] arr: [1,2,3]; obj: {"a":123,"b":"baar"};');
56+
// Support: IE 9-11 only
5657
// IE does not add space after "function"
5758
expect(myError.message).toMatch(/anonFn: function\s?\(something\);/);
5859
expect(myError.message).toContain('namedFn: function foo(something)');

test/ng/compileSpec.js

+19-29
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ describe('$compile', function() {
509509
}));
510510

511511
// NOTE: This test may be redundant.
512-
// Support: Edge 14+
512+
// Support: Edge 14-15+
513513
// An `<svg>` element inside a `<foreignObject>` element on MS Edge has no
514514
// size, causing the included `<circle>` element to also have no size and thus fails an
515515
// assertion (relying on the element having a non-zero size).
@@ -760,36 +760,26 @@ describe('$compile', function() {
760760
element = $compile('<div factory-error template-error linking-error></div>')($rootScope);
761761
expect($exceptionHandler.errors[0]).toEqual('FactoryError');
762762
expect($exceptionHandler.errors[1][0]).toEqual('TemplateError');
763-
expect(ie($exceptionHandler.errors[1][1])).
764-
toEqual('<div factory-error linking-error template-error>');
763+
expect(sortTag($exceptionHandler.errors[1][1])).
764+
toEqual('<div factory-error="" linking-error="" template-error="">');
765765
expect($exceptionHandler.errors[2][0]).toEqual('LinkingError');
766-
expect(ie($exceptionHandler.errors[2][1])).
767-
toEqual('<div class="ng-scope" factory-error linking-error template-error>');
768-
769-
770-
// crazy stuff to make IE happy
771-
function ie(text) {
772-
var list = [],
773-
parts, elementName;
774-
775-
parts = lowercase(text).
776-
replace('<', '').
777-
replace('>', '').
778-
split(' ');
766+
expect(sortTag($exceptionHandler.errors[2][1])).
767+
toEqual('<div class="ng-scope" factory-error="" linking-error="" template-error="">');
768+
769+
// Support: IE 9-11 only, Edge 15+
770+
// IE/Edge sort attributes in a different order.
771+
function sortTag(text) {
772+
var parts, elementName;
773+
774+
parts = text
775+
.replace('<', '')
776+
.replace('>', '')
777+
.split(' ');
779778
elementName = parts.shift();
780779
parts.sort();
781780
parts.unshift(elementName);
782-
forEach(parts, function(value) {
783-
if (value.substring(0,2) !== 'ng') {
784-
value = value.replace('=""', '');
785-
var match = value.match(/=(.*)/);
786-
if (match && match[1].charAt(0) !== '"') {
787-
value = value.replace(/=(.*)/, '="$1"');
788-
}
789-
list.push(value);
790-
}
791-
});
792-
return '<' + list.join(' ') + '>';
781+
782+
return '<' + parts.join(' ') + '>';
793783
}
794784
});
795785
});
@@ -3369,13 +3359,13 @@ describe('$compile', function() {
33693359
it('should translate {{}} in terminal nodes', inject(function($rootScope, $compile) {
33703360
element = $compile('<select ng:model="x"><option value="">Greet {{name}}!</option></select>')($rootScope);
33713361
$rootScope.$digest();
3372-
expect(sortedHtml(element).replace(' selected="true"', '')).
3362+
expect(sortedHtml(element).replace(' selected="selected"', '')).
33733363
toEqual('<select ng:model="x">' +
33743364
'<option value="">Greet !</option>' +
33753365
'</select>');
33763366
$rootScope.name = 'Misko';
33773367
$rootScope.$digest();
3378-
expect(sortedHtml(element).replace(' selected="true"', '')).
3368+
expect(sortedHtml(element).replace(' selected="selected"', '')).
33793369
toEqual('<select ng:model="x">' +
33803370
'<option value="">Greet Misko!</option>' +
33813371
'</select>');

test/ng/directive/booleanAttrsSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('ngHref', function() {
284284
expect(element.attr('href')).toEqual(undefined);
285285
}));
286286

287-
// Support: IE 9-11 only, Edge 12-14+
287+
// Support: IE 9-11 only, Edge 12-15+
288288
if (msie || /\bEdge\/[\d.]+\b/.test(window.navigator.userAgent)) {
289289
// IE/Edge fail when setting a href to a URL containing a % that isn't a valid escape sequence
290290
// See https://github.com/angular/angular.js/issues/13388

test/ng/locationSpec.js

+5-23
Original file line numberDiff line numberDiff line change
@@ -1887,29 +1887,11 @@ describe('$location', function() {
18871887
initBrowser({ url: 'http://host.com/base/index.html', basePath: '/base/index.html' }),
18881888
setupRewriteChecks(),
18891889
function($browser) {
1890-
var rightClick;
1891-
if (window.document.createEvent) {
1892-
rightClick = window.document.createEvent('MouseEvents');
1893-
rightClick.initMouseEvent('click', true, true, window, 1, 10, 10, 10, 10, false,
1894-
false, false, false, 2, null);
1895-
1896-
link.dispatchEvent(rightClick);
1897-
} else if (window.document.createEventObject) { // for IE
1898-
rightClick = window.document.createEventObject();
1899-
rightClick.type = 'click';
1900-
rightClick.cancelBubble = true;
1901-
rightClick.detail = 1;
1902-
rightClick.screenX = 10;
1903-
rightClick.screenY = 10;
1904-
rightClick.clientX = 10;
1905-
rightClick.clientY = 10;
1906-
rightClick.ctrlKey = false;
1907-
rightClick.altKey = false;
1908-
rightClick.shiftKey = false;
1909-
rightClick.metaKey = false;
1910-
rightClick.button = 2;
1911-
link.fireEvent('onclick', rightClick);
1912-
}
1890+
var rightClick = window.document.createEvent('MouseEvents');
1891+
rightClick.initMouseEvent('click', true, true, window, 1, 10, 10, 10, 10, false,
1892+
false, false, false, 2, null);
1893+
1894+
link.dispatchEvent(rightClick);
19131895
expectNoRewrite($browser);
19141896
}
19151897
);

test/ng/urlUtilsSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('urlUtils', function() {
1717

1818

1919
it('should return pathname as / if empty path provided', function() {
20-
//IE counts / as empty, necessary to use / so that pathname is not context.html
20+
// IE (all versions) counts / as empty, necessary to use / so that pathname is not context.html
2121
var parsed = urlResolve('/');
2222
expect(parsed.pathname).toBe('/');
2323
});

0 commit comments

Comments
 (0)