Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(loader): don't rely on functions defined in Angular.js #4874

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ angularFiles = {
],

'angularLoader': [
'src/minErr.js',
'src/loader.js'
],

Expand Down
17 changes: 14 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

function setupModuleLoader(window) {

var $injectorMinErr = minErr('$injector');

function ensure(obj, name, factory) {
return obj[name] || (obj[name] = factory());
}

return ensure(ensure(window, 'angular', Object), 'module', function() {
var angular = ensure(window, 'angular', Object);
angular.$$minErr = angular.$$minErr || minErr;

return ensure(angular, 'module', function() {
/** @type {Object.<string, angular.Module>} */
var modules = {};

Expand Down Expand Up @@ -71,6 +72,14 @@ function setupModuleLoader(window) {
* @returns {module} new module with the {@link angular.Module} api.
*/
return function module(name, requires, configFn) {
var $injectorMinErr = minErr('$injector');
var ngMinErr = minErr('ng');
var assertNotHasOwnProperty = function(name, context) {
if (name === 'hasOwnProperty') {
throw ngMinErr('badname', "hasOwnProperty is not a valid {0} name", context);
}
};

assertNotHasOwnProperty(name, 'module');
if (requires && modules.hasOwnProperty(name)) {
modules[name] = null;
Expand Down Expand Up @@ -294,3 +303,5 @@ function setupModuleLoader(window) {
});

}

setupModuleLoader(window);
2 changes: 1 addition & 1 deletion src/loader.prefix
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* License: MIT
*/
'use strict';
(
(function(window) {
2 changes: 1 addition & 1 deletion src/loader.suffix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
)(window);
})(window);

/**
* Closure compiler type information
Expand Down