Skip to content

Commit

Permalink
Merge pull request #213 from onaluf/master
Browse files Browse the repository at this point in the history
fix: loading a module with dependencies with multiple oc-lazy-load directives
  • Loading branch information
ocombe committed Aug 28, 2015
2 parents 6771b9f + 098e391 commit f18acbc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ocLazyLoad.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
debug = false,
events = false,
moduleCache = [];
moduleCache = [],
modulePromises = {};

moduleCache.push = function(value) {
if(this.indexOf(value) === -1) {
Expand Down Expand Up @@ -588,6 +589,7 @@
var res = modulesToLoad.slice(); // clean copy
var loadNext = function loadNext(moduleName) {
moduleCache.push(moduleName);
modulePromises[moduleName] = deferred.promise;
self._loadDependencies(moduleName, localParams).then(function success() {
try {
justLoaded = [];
Expand All @@ -610,6 +612,8 @@

// load the first in list
loadNext(modulesToLoad.shift());
} else if (localParams && localParams.name && modulePromises[localParams.name]) {
return modulePromises[localParams.name];
} else {
deferred.resolve();
}
Expand Down

0 comments on commit f18acbc

Please # to comment.