Skip to content

Commit 1b32308

Browse files
committed
Merge pull request #261 from jvmccarthy/fix_ie_invalid
Fix IE "Invalid calling object" error (attach to DOM and then compile)
2 parents 6c16c6b + d01016b commit 1b32308

9 files changed

+224
-170
lines changed

dist/modules/ocLazyLoad.directive.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
}, function (moduleName) {
1919
if (angular.isDefined(moduleName)) {
2020
$ocLazyLoad.load(moduleName).then(function () {
21-
$animate.enter($compile(content)($scope), $element);
21+
// Attach element contents to DOM and then compile them.
22+
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
23+
// of the compiled contents when attaching to the parent DOM.
24+
var contentElement = angular.element(content);
25+
$animate.enter(contentElement, $element);
26+
$compile(contentElement)($scope);
2227
});
2328
}
2429
}, true);
+60-60
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
// Array.indexOf polyfill for IE8
22
if (!Array.prototype.indexOf) {
3-
Array.prototype.indexOf = function (searchElement, fromIndex) {
4-
var k;
5-
6-
// 1. Let O be the result of calling ToObject passing
7-
// the this value as the argument.
8-
if (this == null) {
9-
throw new TypeError('"this" is null or not defined');
10-
}
11-
12-
var O = Object(this);
13-
14-
// 2. Let lenValue be the result of calling the Get
15-
// internal method of O with the argument "length".
16-
// 3. Let len be ToUint32(lenValue).
17-
var len = O.length >>> 0;
18-
19-
// 4. If len is 0, return -1.
20-
if (len === 0) {
21-
return -1;
22-
}
23-
24-
// 5. If argument fromIndex was passed let n be
25-
// ToInteger(fromIndex); else let n be 0.
26-
var n = +fromIndex || 0;
27-
28-
if (Math.abs(n) === Infinity) {
29-
n = 0;
30-
}
31-
32-
// 6. If n >= len, return -1.
33-
if (n >= len) {
34-
return -1;
35-
}
36-
37-
// 7. If n >= 0, then Let k be n.
38-
// 8. Else, n<0, Let k be len - abs(n).
39-
// If k is less than 0, then let k be 0.
40-
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
41-
42-
// 9. Repeat, while k < len
43-
while (k < len) {
44-
// a. Let Pk be ToString(k).
45-
// This is implicit for LHS operands of the in operator
46-
// b. Let kPresent be the result of calling the
47-
// HasProperty internal method of O with argument Pk.
48-
// This step can be combined with c
49-
// c. If kPresent is true, then
50-
// i. Let elementK be the result of calling the Get
51-
// internal method of O with the argument ToString(k).
52-
// ii. Let same be the result of applying the
53-
// Strict Equality Comparison Algorithm to
54-
// searchElement and elementK.
55-
// iii. If same is true, return k.
56-
if (k in O && O[k] === searchElement) {
57-
return k;
58-
}
59-
k++;
60-
}
61-
return -1;
62-
};
3+
Array.prototype.indexOf = function (searchElement, fromIndex) {
4+
var k;
5+
6+
// 1. Let O be the result of calling ToObject passing
7+
// the this value as the argument.
8+
if (this == null) {
9+
throw new TypeError('"this" is null or not defined');
10+
}
11+
12+
var O = Object(this);
13+
14+
// 2. Let lenValue be the result of calling the Get
15+
// internal method of O with the argument "length".
16+
// 3. Let len be ToUint32(lenValue).
17+
var len = O.length >>> 0;
18+
19+
// 4. If len is 0, return -1.
20+
if (len === 0) {
21+
return -1;
22+
}
23+
24+
// 5. If argument fromIndex was passed let n be
25+
// ToInteger(fromIndex); else let n be 0.
26+
var n = +fromIndex || 0;
27+
28+
if (Math.abs(n) === Infinity) {
29+
n = 0;
30+
}
31+
32+
// 6. If n >= len, return -1.
33+
if (n >= len) {
34+
return -1;
35+
}
36+
37+
// 7. If n >= 0, then Let k be n.
38+
// 8. Else, n<0, Let k be len - abs(n).
39+
// If k is less than 0, then let k be 0.
40+
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
41+
42+
// 9. Repeat, while k < len
43+
while (k < len) {
44+
// a. Let Pk be ToString(k).
45+
// This is implicit for LHS operands of the in operator
46+
// b. Let kPresent be the result of calling the
47+
// HasProperty internal method of O with argument Pk.
48+
// This step can be combined with c
49+
// c. If kPresent is true, then
50+
// i. Let elementK be the result of calling the Get
51+
// internal method of O with the argument ToString(k).
52+
// ii. Let same be the result of applying the
53+
// Strict Equality Comparison Algorithm to
54+
// searchElement and elementK.
55+
// iii. If same is true, return k.
56+
if (k in O && O[k] === searchElement) {
57+
return k;
58+
}
59+
k++;
60+
}
61+
return -1;
62+
};
6363
}

dist/ocLazyLoad.js

+58-53
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,12 @@
776776
}, function (moduleName) {
777777
if (angular.isDefined(moduleName)) {
778778
$ocLazyLoad.load(moduleName).then(function () {
779-
$animate.enter($compile(content)($scope), $element);
779+
// Attach element contents to DOM and then compile them.
780+
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
781+
// of the compiled contents when attaching to the parent DOM.
782+
var contentElement = angular.element(content);
783+
$animate.enter(contentElement, $element);
784+
$compile(contentElement)($scope);
780785
});
781786
}
782787
}, true);
@@ -1256,64 +1261,64 @@
12561261
})(angular);
12571262
// Array.indexOf polyfill for IE8
12581263
if (!Array.prototype.indexOf) {
1259-
Array.prototype.indexOf = function (searchElement, fromIndex) {
1260-
var k;
1264+
Array.prototype.indexOf = function (searchElement, fromIndex) {
1265+
var k;
12611266

1262-
// 1. Let O be the result of calling ToObject passing
1263-
// the this value as the argument.
1264-
if (this == null) {
1265-
throw new TypeError('"this" is null or not defined');
1266-
}
1267+
// 1. Let O be the result of calling ToObject passing
1268+
// the this value as the argument.
1269+
if (this == null) {
1270+
throw new TypeError('"this" is null or not defined');
1271+
}
12671272

1268-
var O = Object(this);
1273+
var O = Object(this);
12691274

1270-
// 2. Let lenValue be the result of calling the Get
1271-
// internal method of O with the argument "length".
1272-
// 3. Let len be ToUint32(lenValue).
1273-
var len = O.length >>> 0;
1275+
// 2. Let lenValue be the result of calling the Get
1276+
// internal method of O with the argument "length".
1277+
// 3. Let len be ToUint32(lenValue).
1278+
var len = O.length >>> 0;
12741279

1275-
// 4. If len is 0, return -1.
1276-
if (len === 0) {
1277-
return -1;
1278-
}
1280+
// 4. If len is 0, return -1.
1281+
if (len === 0) {
1282+
return -1;
1283+
}
12791284

1280-
// 5. If argument fromIndex was passed let n be
1281-
// ToInteger(fromIndex); else let n be 0.
1282-
var n = +fromIndex || 0;
1285+
// 5. If argument fromIndex was passed let n be
1286+
// ToInteger(fromIndex); else let n be 0.
1287+
var n = +fromIndex || 0;
12831288

1284-
if (Math.abs(n) === Infinity) {
1285-
n = 0;
1286-
}
1289+
if (Math.abs(n) === Infinity) {
1290+
n = 0;
1291+
}
12871292

1288-
// 6. If n >= len, return -1.
1289-
if (n >= len) {
1290-
return -1;
1291-
}
1293+
// 6. If n >= len, return -1.
1294+
if (n >= len) {
1295+
return -1;
1296+
}
12921297

1293-
// 7. If n >= 0, then Let k be n.
1294-
// 8. Else, n<0, Let k be len - abs(n).
1295-
// If k is less than 0, then let k be 0.
1296-
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
1297-
1298-
// 9. Repeat, while k < len
1299-
while (k < len) {
1300-
// a. Let Pk be ToString(k).
1301-
// This is implicit for LHS operands of the in operator
1302-
// b. Let kPresent be the result of calling the
1303-
// HasProperty internal method of O with argument Pk.
1304-
// This step can be combined with c
1305-
// c. If kPresent is true, then
1306-
// i. Let elementK be the result of calling the Get
1307-
// internal method of O with the argument ToString(k).
1308-
// ii. Let same be the result of applying the
1309-
// Strict Equality Comparison Algorithm to
1310-
// searchElement and elementK.
1311-
// iii. If same is true, return k.
1312-
if (k in O && O[k] === searchElement) {
1313-
return k;
1314-
}
1315-
k++;
1316-
}
1317-
return -1;
1318-
};
1298+
// 7. If n >= 0, then Let k be n.
1299+
// 8. Else, n<0, Let k be len - abs(n).
1300+
// If k is less than 0, then let k be 0.
1301+
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
1302+
1303+
// 9. Repeat, while k < len
1304+
while (k < len) {
1305+
// a. Let Pk be ToString(k).
1306+
// This is implicit for LHS operands of the in operator
1307+
// b. Let kPresent be the result of calling the
1308+
// HasProperty internal method of O with argument Pk.
1309+
// This step can be combined with c
1310+
// c. If kPresent is true, then
1311+
// i. Let elementK be the result of calling the Get
1312+
// internal method of O with the argument ToString(k).
1313+
// ii. Let same be the result of applying the
1314+
// Strict Equality Comparison Algorithm to
1315+
// searchElement and elementK.
1316+
// iii. If same is true, return k.
1317+
if (k in O && O[k] === searchElement) {
1318+
return k;
1319+
}
1320+
k++;
1321+
}
1322+
return -1;
1323+
};
13191324
}

0 commit comments

Comments
 (0)