refactor(api): cleaned up the externalization of angular API methods

This commit is contained in:
Misko Hevery 2011-11-01 14:27:22 -07:00
parent 9062996a0e
commit 4c10d33eb4
3 changed files with 31 additions and 54 deletions

View file

@ -1015,6 +1015,34 @@ function assertArgFn(arg, name) {
return arg;
}
function publishExternalAPI(angular){
extend(angular, {
// disabled for now until we agree on public name
//'annotate': annotate,
'copy': copy,
'extend': extend,
'equals': equals,
'forEach': forEach,
'injector': createInjector,
'noop':noop,
'bind':bind,
'toJson': toJson,
'fromJson': fromJson,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
'isFunction': isFunction,
'isObject': isObject,
'isNumber': isNumber,
'isArray': isArray,
'version': version,
'isDate': isDate,
'lowercase': lowercase,
'uppercase': uppercase
});
}
/**
* @ngdoc property

View file

@ -11,31 +11,7 @@ angularService('$browser', function($log, $sniffer) {
}, {$inject: ['$log', '$sniffer']});
extend(angular, {
// disabled for now until we agree on public name
//'annotate': annotate,
'copy': copy,
'extend': extend,
'equals': equals,
'forEach': forEach,
'injector': createInjector,
'noop':noop,
'bind':bind,
'toJson': toJson,
'fromJson': fromJson,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
'isFunction': isFunction,
'isObject': isObject,
'isNumber': isNumber,
'isArray': isArray,
'version': version,
'isDate': isDate,
'lowercase': lowercase,
'uppercase': uppercase
});
publishExternalAPI(angular);
//try to bind to jquery now so that one can write angular.element().read()
//but we will rebind on bootstrap again.

View file

@ -46,7 +46,9 @@ function dumpScope(scope, offset) {
return log.join('\n' + offset);
}
publishExternalAPI(angular)
beforeEach(function() {
publishExternalAPI(angular)
// This is to reset parsers global cache of expressions.
compileCache = {};
@ -80,7 +82,6 @@ beforeEach(function() {
$logMock.info.logs = [];
$logMock.error.logs = [];
resetAngularPublic()
});
function inject(){
@ -118,34 +119,6 @@ function inject(){
};
}
/**
* This method republishes the public angular API. It should probably be cleaned up somehow.
* //TODO: remove this method and merge it with the angularPublic.js class
*/
function resetAngularPublic() {
extend(angular, {
'element': jqLite,
'copy': copy,
'extend': extend,
'equals': equals,
'forEach': forEach,
'noop': noop,
'bind': bind,
'toJson': toJson,
'fromJson': fromJson,
'identity':identity,
'injector': createInjector,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
'isFunction': isFunction,
'isObject': isObject,
'isNumber': isNumber,
'isArray': isArray
});
}
resetAngularPublic();
afterEach(inject(function($rootScope) {
// release the injector