Skip to content

Commit

Permalink
chore: bump to 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Combe committed Jul 23, 2014
1 parent c590579 commit 5c8a04a
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 46 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<a name="0.3.2"></a>
# 0.3.2 (2014-07-23)


## Bug Fixes

- allow $ocLazyLoadProvider.config to be called multiple times
([c590579c](https://github.com/ocombe/ocLazyLoad/commit/c590579c9512e0dd3fae2c33c0aefc0bb0f7ca7e),
[#43](https://github.com/ocombe/ocLazyLoad/issues/43))
- prevent duplicate loadings
([12bc6b2b](https://github.com/ocombe/ocLazyLoad/commit/12bc6b2b2d1561517d56c14c56c15c332d578344),
[#35](https://github.com/ocombe/ocLazyLoad/issues/35),
[#38](https://github.com/ocombe/ocLazyLoad/issues/38))


<a name="0.3.1"></a>
# 0.3.1 (2014-07-14)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ocLazyLoad",
"version": "0.3.1",
"version": "0.3.2",
"description": "Load modules on demand (lazy load) with angularJS",
"main": "dist/ocLazyLoad.min.js",
"homepage": "https://github.com/ocombe/ocLazyLoad",
Expand Down
45 changes: 31 additions & 14 deletions dist/ocLazyLoad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* ocLazyLoad - Load modules on demand (lazy load) with angularJS
* @version v0.3.0
* @version v0.3.1
* @link https://github.com/ocombe/ocLazyLoad
* @license MIT
* @author Olivier Combe <olivier.combe@gmail.com>
Expand Down Expand Up @@ -204,11 +204,11 @@

angular.forEach(paths, function(path) {
if(angular.isUndefined(filesCache.get(path)) || params.cache === false) {
if(/\.css[^\.]*$/.test(path)) {
if(/\.css[^\.]*$/.test(path) && cssFiles.indexOf(path) === -1) {
cssFiles.push(path);
} else if(/\.(htm|html)[^\.]*$/.test(path)) {
} else if(/\.(htm|html)[^\.]*$/.test(path) && templatesFiles.indexOf(path) === -1) {
templatesFiles.push(path);
} else {
} else if (/\.(js)[^\.]*$/.test(path) && jsFiles.indexOf(path) === -1) {
jsFiles.push(path);
}
}
Expand Down Expand Up @@ -295,7 +295,9 @@
if(angular.isArray(module)) {
// Resubmit each entry as a single module
angular.forEach(module, function(m) {
deferredList.push(self.load(m, params));
if (m) {
deferredList.push(self.load(m, params));
}
});

// Resolve the promise once everything has loaded
Expand Down Expand Up @@ -360,6 +362,7 @@
var moduleName,
loadedModule,
requires,
diff,
promisesList = [];

moduleName = getModuleName(module);
Expand Down Expand Up @@ -392,10 +395,17 @@
// Check if this dependency has been loaded previously or is already in the moduleCache
if(moduleExists(requireEntry.name) || moduleCache.indexOf(requireEntry.name) !== -1) {
if(typeof module !== 'string') {
// The dependency exists, but it's being redefined, not inherited by a simple string reference, raise a warning and ignore the new config.
// TODO: This could be made smarter. There's no checking here yet to determine if the configurations are actually different.
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency "', requireEntry.name, '"\nExisting:', self.getModuleConfig(requireEntry.name), 'Ignored:', requireEntry);
}
// compare against the already loaded module to see if the new definition adds any new files
diff = requireEntry.files.filter(function (n) {
return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0
});
if (diff.length !== 0) {
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
promisesList.push(filesLoader(diff, params).then(function () {
return loadDependencies(requireEntry);
}));
}
}
return;
} else if(typeof requireEntry === 'object') {
if(requireEntry.hasOwnProperty('name') && requireEntry['name']) {
Expand All @@ -408,7 +418,7 @@
if(requireEntry.hasOwnProperty('css') && requireEntry['css'].length !== 0) {
// Locate the document insertion point
angular.forEach(requireEntry['css'], function(path) {
buildElement('css', path);
buildElement('css', path, params);
});
}
// CSS End.
Expand Down Expand Up @@ -460,17 +470,24 @@
}];

this.config = function(config) {
jsLoader = config.jsLoader || config.asyncLoader;

if(angular.isDefined() && !angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
if(angular.isDefined(config.jsLoader) || angular.isDefined(config.asyncLoader)) {
if(!angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
}
jsLoader = config.jsLoader || config.asyncLoader;
}

if(angular.isDefined(config.cssLoader)) {
if(!angular.isFunction(cssLoader)) {
throw('The css loader needs to be a function');
}
cssLoader = config.cssLoader;
}

if(angular.isDefined(config.templatesLoader)) {
if(!angular.isFunction(templatesLoader)) {
throw('The template loader needs to be a function');
}
templatesLoader = config.templatesLoader;
}

Expand Down
4 changes: 2 additions & 2 deletions dist/ocLazyLoad.min.js

Large diffs are not rendered by default.

45 changes: 31 additions & 14 deletions examples/example1/js/ocLazyLoad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* ocLazyLoad - Load modules on demand (lazy load) with angularJS
* @version v0.3.0
* @version v0.3.1
* @link https://github.com/ocombe/ocLazyLoad
* @license MIT
* @author Olivier Combe <olivier.combe@gmail.com>
Expand Down Expand Up @@ -204,11 +204,11 @@

angular.forEach(paths, function(path) {
if(angular.isUndefined(filesCache.get(path)) || params.cache === false) {
if(/\.css[^\.]*$/.test(path)) {
if(/\.css[^\.]*$/.test(path) && cssFiles.indexOf(path) === -1) {
cssFiles.push(path);
} else if(/\.(htm|html)[^\.]*$/.test(path)) {
} else if(/\.(htm|html)[^\.]*$/.test(path) && templatesFiles.indexOf(path) === -1) {
templatesFiles.push(path);
} else {
} else if (/\.(js)[^\.]*$/.test(path) && jsFiles.indexOf(path) === -1) {
jsFiles.push(path);
}
}
Expand Down Expand Up @@ -295,7 +295,9 @@
if(angular.isArray(module)) {
// Resubmit each entry as a single module
angular.forEach(module, function(m) {
deferredList.push(self.load(m, params));
if (m) {
deferredList.push(self.load(m, params));
}
});

// Resolve the promise once everything has loaded
Expand Down Expand Up @@ -360,6 +362,7 @@
var moduleName,
loadedModule,
requires,
diff,
promisesList = [];

moduleName = getModuleName(module);
Expand Down Expand Up @@ -392,10 +395,17 @@
// Check if this dependency has been loaded previously or is already in the moduleCache
if(moduleExists(requireEntry.name) || moduleCache.indexOf(requireEntry.name) !== -1) {
if(typeof module !== 'string') {
// The dependency exists, but it's being redefined, not inherited by a simple string reference, raise a warning and ignore the new config.
// TODO: This could be made smarter. There's no checking here yet to determine if the configurations are actually different.
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency "', requireEntry.name, '"\nExisting:', self.getModuleConfig(requireEntry.name), 'Ignored:', requireEntry);
}
// compare against the already loaded module to see if the new definition adds any new files
diff = requireEntry.files.filter(function (n) {
return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0
});
if (diff.length !== 0) {
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
promisesList.push(filesLoader(diff, params).then(function () {
return loadDependencies(requireEntry);
}));
}
}
return;
} else if(typeof requireEntry === 'object') {
if(requireEntry.hasOwnProperty('name') && requireEntry['name']) {
Expand All @@ -408,7 +418,7 @@
if(requireEntry.hasOwnProperty('css') && requireEntry['css'].length !== 0) {
// Locate the document insertion point
angular.forEach(requireEntry['css'], function(path) {
buildElement('css', path);
buildElement('css', path, params);
});
}
// CSS End.
Expand Down Expand Up @@ -460,17 +470,24 @@
}];

this.config = function(config) {
jsLoader = config.jsLoader || config.asyncLoader;

if(angular.isDefined() && !angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
if(angular.isDefined(config.jsLoader) || angular.isDefined(config.asyncLoader)) {
if(!angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
}
jsLoader = config.jsLoader || config.asyncLoader;
}

if(angular.isDefined(config.cssLoader)) {
if(!angular.isFunction(cssLoader)) {
throw('The css loader needs to be a function');
}
cssLoader = config.cssLoader;
}

if(angular.isDefined(config.templatesLoader)) {
if(!angular.isFunction(templatesLoader)) {
throw('The template loader needs to be a function');
}
templatesLoader = config.templatesLoader;
}

Expand Down
45 changes: 31 additions & 14 deletions examples/example2/js/ocLazyLoad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* ocLazyLoad - Load modules on demand (lazy load) with angularJS
* @version v0.3.0
* @version v0.3.1
* @link https://github.com/ocombe/ocLazyLoad
* @license MIT
* @author Olivier Combe <olivier.combe@gmail.com>
Expand Down Expand Up @@ -204,11 +204,11 @@

angular.forEach(paths, function(path) {
if(angular.isUndefined(filesCache.get(path)) || params.cache === false) {
if(/\.css[^\.]*$/.test(path)) {
if(/\.css[^\.]*$/.test(path) && cssFiles.indexOf(path) === -1) {
cssFiles.push(path);
} else if(/\.(htm|html)[^\.]*$/.test(path)) {
} else if(/\.(htm|html)[^\.]*$/.test(path) && templatesFiles.indexOf(path) === -1) {
templatesFiles.push(path);
} else {
} else if (/\.(js)[^\.]*$/.test(path) && jsFiles.indexOf(path) === -1) {
jsFiles.push(path);
}
}
Expand Down Expand Up @@ -295,7 +295,9 @@
if(angular.isArray(module)) {
// Resubmit each entry as a single module
angular.forEach(module, function(m) {
deferredList.push(self.load(m, params));
if (m) {
deferredList.push(self.load(m, params));
}
});

// Resolve the promise once everything has loaded
Expand Down Expand Up @@ -360,6 +362,7 @@
var moduleName,
loadedModule,
requires,
diff,
promisesList = [];

moduleName = getModuleName(module);
Expand Down Expand Up @@ -392,10 +395,17 @@
// Check if this dependency has been loaded previously or is already in the moduleCache
if(moduleExists(requireEntry.name) || moduleCache.indexOf(requireEntry.name) !== -1) {
if(typeof module !== 'string') {
// The dependency exists, but it's being redefined, not inherited by a simple string reference, raise a warning and ignore the new config.
// TODO: This could be made smarter. There's no checking here yet to determine if the configurations are actually different.
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency "', requireEntry.name, '"\nExisting:', self.getModuleConfig(requireEntry.name), 'Ignored:', requireEntry);
}
// compare against the already loaded module to see if the new definition adds any new files
diff = requireEntry.files.filter(function (n) {
return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0
});
if (diff.length !== 0) {
$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
promisesList.push(filesLoader(diff, params).then(function () {
return loadDependencies(requireEntry);
}));
}
}
return;
} else if(typeof requireEntry === 'object') {
if(requireEntry.hasOwnProperty('name') && requireEntry['name']) {
Expand All @@ -408,7 +418,7 @@
if(requireEntry.hasOwnProperty('css') && requireEntry['css'].length !== 0) {
// Locate the document insertion point
angular.forEach(requireEntry['css'], function(path) {
buildElement('css', path);
buildElement('css', path, params);
});
}
// CSS End.
Expand Down Expand Up @@ -460,17 +470,24 @@
}];

this.config = function(config) {
jsLoader = config.jsLoader || config.asyncLoader;

if(angular.isDefined() && !angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
if(angular.isDefined(config.jsLoader) || angular.isDefined(config.asyncLoader)) {
if(!angular.isFunction(jsLoader)) {
throw('The js loader needs to be a function');
}
jsLoader = config.jsLoader || config.asyncLoader;
}

if(angular.isDefined(config.cssLoader)) {
if(!angular.isFunction(cssLoader)) {
throw('The css loader needs to be a function');
}
cssLoader = config.cssLoader;
}

if(angular.isDefined(config.templatesLoader)) {
if(!angular.isFunction(templatesLoader)) {
throw('The template loader needs to be a function');
}
templatesLoader = config.templatesLoader;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ocLazyLoad",
"version": "0.3.1",
"version": "0.3.2",
"description": "Load modules on demand (lazy load) with angularJS",
"main": "dist/ocLazyLoad.min.js",
"author": "Olivier Combe <olivier.combe@gmail.com>",
Expand Down

0 comments on commit 5c8a04a

Please # to comment.