Skip to content

Commit ca047fd

Browse files
committed
Merge pull request #240 from joaovieira/master
fix: directive compile original contents after dependency is loaded. Fixes #168 Fixes #194
2 parents f1f7ae3 + a48e3ce commit ca047fd

File tree

7 files changed

+174
-201
lines changed

7 files changed

+174
-201
lines changed

dist/modules/ocLazyLoad.directive.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
priority: 1000,
99
compile: function compile(element, attrs) {
1010
// we store the content and remove it before compilation
11-
var content = element[0].innerHTML;
11+
var content = element.contents();
1212
element.html('');
1313

1414
return function ($scope, $element, $attr) {
@@ -18,14 +18,7 @@
1818
}, function (moduleName) {
1919
if (angular.isDefined(moduleName)) {
2020
$ocLazyLoad.load(moduleName).then(function () {
21-
$animate.enter(content, $element);
22-
var contents = element.contents();
23-
angular.forEach(contents, function (content) {
24-
if (content.nodeType !== 3) {
25-
// 3 is a text node
26-
$compile(content)($scope);
27-
}
28-
});
21+
$animate.enter($compile(content)($scope), $element);
2922
});
3023
}
3124
}, true);
Lines changed: 60 additions & 60 deletions
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

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@
764764
priority: 1000,
765765
compile: function compile(element, attrs) {
766766
// we store the content and remove it before compilation
767-
var content = element[0].innerHTML;
767+
var content = element.contents();
768768
element.html('');
769769

770770
return function ($scope, $element, $attr) {
@@ -774,14 +774,7 @@
774774
}, function (moduleName) {
775775
if (angular.isDefined(moduleName)) {
776776
$ocLazyLoad.load(moduleName).then(function () {
777-
$animate.enter(content, $element);
778-
var contents = element.contents();
779-
angular.forEach(contents, function (content) {
780-
if (content.nodeType !== 3) {
781-
// 3 is a text node
782-
$compile(content)($scope);
783-
}
784-
});
777+
$animate.enter($compile(content)($scope), $element);
785778
});
786779
}
787780
}, true);
@@ -1261,64 +1254,64 @@
12611254
})(angular);
12621255
// Array.indexOf polyfill for IE8
12631256
if (!Array.prototype.indexOf) {
1264-
Array.prototype.indexOf = function (searchElement, fromIndex) {
1265-
var k;
1257+
Array.prototype.indexOf = function (searchElement, fromIndex) {
1258+
var k;
12661259

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-
}
1260+
// 1. Let O be the result of calling ToObject passing
1261+
// the this value as the argument.
1262+
if (this == null) {
1263+
throw new TypeError('"this" is null or not defined');
1264+
}
12721265

1273-
var O = Object(this);
1266+
var O = Object(this);
12741267

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;
1268+
// 2. Let lenValue be the result of calling the Get
1269+
// internal method of O with the argument "length".
1270+
// 3. Let len be ToUint32(lenValue).
1271+
var len = O.length >>> 0;
12791272

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

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

1289-
if (Math.abs(n) === Infinity) {
1290-
n = 0;
1291-
}
1282+
if (Math.abs(n) === Infinity) {
1283+
n = 0;
1284+
}
12921285

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

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

0 commit comments

Comments
 (0)