Skip to content

Commit 098e391

Browse files
author
Selim Arsever
committed
Fix for loading a module with dependencies multiple times through the oc-lazy-load directive (http://plnkr.co/edit/pAq7cneNylQmfCFHZV66)
1 parent e1a3043 commit 098e391

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ocLazyLoad.core.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
debug = false,
2626
events = false,
27-
moduleCache = [];
27+
moduleCache = [],
28+
modulePromises = {};
2829

2930
moduleCache.push = function(value) {
3031
if(this.indexOf(value) === -1) {
@@ -572,6 +573,7 @@
572573
var res = modulesToLoad.slice(); // clean copy
573574
var loadNext = function loadNext(moduleName) {
574575
moduleCache.push(moduleName);
576+
modulePromises[moduleName] = deferred.promise;
575577
self._loadDependencies(moduleName, localParams).then(function success() {
576578
try {
577579
justLoaded = [];
@@ -594,6 +596,8 @@
594596

595597
// load the first in list
596598
loadNext(modulesToLoad.shift());
599+
} else if (localParams && localParams.name && modulePromises[localParams.name]) {
600+
return modulePromises[localParams.name];
597601
} else {
598602
deferred.resolve();
599603
}

0 commit comments

Comments
 (0)