From 1a30241a97177c84234fb9ee0be4333dd6b25bdb Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sun, 10 Nov 2013 22:42:11 +0000 Subject: [PATCH] fix(loader): don't rely on functions defined in Angular.js --- angularFiles.js | 1 + src/loader.js | 17 ++++++++++++++--- src/loader.prefix | 2 +- src/loader.suffix | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/angularFiles.js b/angularFiles.js index 9603c289abd8..9aa2ef7eda22 100755 --- a/angularFiles.js +++ b/angularFiles.js @@ -66,6 +66,7 @@ angularFiles = { ], 'angularLoader': [ + 'src/minErr.js', 'src/loader.js' ], diff --git a/src/loader.js b/src/loader.js index 0560595d5082..18fc5dfe1d1e 100644 --- a/src/loader.js +++ b/src/loader.js @@ -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.} */ var modules = {}; @@ -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; @@ -294,3 +303,5 @@ function setupModuleLoader(window) { }); } + +setupModuleLoader(window); \ No newline at end of file diff --git a/src/loader.prefix b/src/loader.prefix index 3ab7dd06e4fe..f5235392336c 100644 --- a/src/loader.prefix +++ b/src/loader.prefix @@ -4,4 +4,4 @@ * License: MIT */ 'use strict'; -( +(function(window) { diff --git a/src/loader.suffix b/src/loader.suffix index b8a5d43dc726..5a0d283d4ed9 100644 --- a/src/loader.suffix +++ b/src/loader.suffix @@ -1,4 +1,4 @@ -)(window); +})(window); /** * Closure compiler type information