Skip to content

Commit 6bbaed9

Browse files
committed
fix: keep track of components signatures instead of just the names
Fixes #120
1 parent ed200fa commit 6bbaed9

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

src/ocLazyLoad.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -843,19 +843,38 @@
843843
regInvokes[moduleName] = {};
844844
}
845845
if(angular.isUndefined(regInvokes[moduleName][type])) {
846-
regInvokes[moduleName][type] = [];
846+
regInvokes[moduleName][type] = {};
847847
}
848-
var onInvoke = function(invokeName) {
848+
var onInvoke = function(invokeName, signature) {
849849
newInvoke = true;
850-
regInvokes[moduleName][type].push(invokeName);
850+
regInvokes[moduleName][type][invokeName].push(signature);
851851
broadcast('ocLazyLoad.componentLoaded', [moduleName, type, invokeName]);
852852
};
853-
if(angular.isString(invokeList) && regInvokes[moduleName][type].indexOf(invokeList) === -1) {
854-
onInvoke(invokeList);
855-
} else if(angular.isObject(invokeList)) {
853+
var signature = function(data) {
854+
if(angular.isArray(data)) { // arrays are objects, we need to test for it first
855+
return data.toString();
856+
} else if(angular.isObject(data)) { // constants & values for example
857+
return JSON.stringify(data);
858+
} else {
859+
return data.toString();
860+
}
861+
};
862+
if(angular.isString(invokeList)) {
863+
if(angular.isUndefined(regInvokes[moduleName][type][invokeList])) {
864+
regInvokes[moduleName][type][invokeList] = [];
865+
}
866+
if(regInvokes[moduleName][type][invokeList].indexOf(signature(args[2][1])) === -1) {
867+
onInvoke(invokeList, signature(args[2][1]));
868+
}
869+
} else if(angular.isObject(invokeList)) { // decorators for example
856870
angular.forEach(invokeList, function(invoke) {
857-
if(angular.isString(invoke) && regInvokes[moduleName][type].indexOf(invoke) === -1) {
858-
onInvoke(invoke);
871+
if(angular.isString(invoke)) {
872+
if(angular.isUndefined(regInvokes[moduleName][type][invoke])) {
873+
regInvokes[moduleName][type][invoke] = [];
874+
}
875+
if(regInvokes[moduleName][type][invoke].indexOf(signature(invokeList[1])) === -1) {
876+
onInvoke(invoke, signature(invokeList[1]));
877+
}
859878
}
860879
});
861880
} else {

0 commit comments

Comments
 (0)