diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index bd02d07..18e364d 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -97,6 +97,10 @@ GameLib.Component.prototype.createInstance = function() { }; +/** + * Dependencies are everything which is either a string or an object with an id which is linked to this object + * @returns {Array} + */ GameLib.Component.prototype.getDependencies = function() { var dependencies = []; @@ -113,26 +117,24 @@ GameLib.Component.prototype.getDependencies = function() { } if (this[property] instanceof Array) { - this[property].map(function(arrayProperty){ + this[property].map( + function(arrayProperty) { - if (typeof arrayProperty === 'string') { - GameLib.Utils.PushUnique(dependencies, arrayProperty); - } + if (typeof arrayProperty === 'string') { + GameLib.Utils.PushUnique(dependencies, arrayProperty); + } - if (arrayProperty && - typeof arrayProperty === 'object' && - arrayProperty.hasOwnProperty('loaded') && - arrayProperty.loaded === false - ) { - GameLib.Utils.PushUnique(dependencies, arrayProperty.id); + if (arrayProperty && + arrayProperty instanceof GameLib.Component + ) { + GameLib.Utils.PushUnique(dependencies, arrayProperty.id); + } } - }); + ); } if (this[property] && - typeof this[property] === 'object' && - this[property].hasOwnProperty('loaded') && - this[property].loaded === false + this[property] instanceof GameLib.Component ) { GameLib.Utils.PushUnique(dependencies, this[property].id); }