Skip to content

Commit f18acbc

Browse files
committed
Merge pull request #213 from onaluf/master
fix: loading a module with dependencies with multiple oc-lazy-load directives
2 parents 6771b9f + 098e391 commit f18acbc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ocLazyLoad.core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
debug = false,
2727
events = false,
28-
moduleCache = [];
28+
moduleCache = [],
29+
modulePromises = {};
2930

3031
moduleCache.push = function(value) {
3132
if(this.indexOf(value) === -1) {
@@ -588,6 +589,7 @@
588589
var res = modulesToLoad.slice(); // clean copy
589590
var loadNext = function loadNext(moduleName) {
590591
moduleCache.push(moduleName);
592+
modulePromises[moduleName] = deferred.promise;
591593
self._loadDependencies(moduleName, localParams).then(function success() {
592594
try {
593595
justLoaded = [];
@@ -610,6 +612,8 @@
610612

611613
// load the first in list
612614
loadNext(modulesToLoad.shift());
615+
} else if (localParams && localParams.name && modulePromises[localParams.name]) {
616+
return modulePromises[localParams.name];
613617
} else {
614618
deferred.resolve();
615619
}

0 commit comments

Comments
 (0)