browser is now injectable into the system

This commit is contained in:
Misko Hevery 2010-04-03 20:19:55 -07:00
parent a80a61839a
commit 5dcf9bb4fe
6 changed files with 22 additions and 21 deletions

View file

@ -33,22 +33,6 @@ function angularAlert(){
log(arguments); window.alert.apply(window, arguments);
}
extend(angular, {
'compile': compile,
'copy': copy,
'extend': extend,
'foreach': foreach,
'noop':noop,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
'isFunction': isFunction,
'isNumber': isNumber,
'isArray': isArray,
'alert': angularAlert
});
function foreach(obj, iterator, context) {
var key;
if (obj) {

17
src/AngularPublic.js Normal file
View file

@ -0,0 +1,17 @@
extend(angular, {
'element': jqLite,
'compile': compile,
'scope': createScope,
'copy': copy,
'extend': extend,
'foreach': foreach,
'noop':noop,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
'isFunction': isFunction,
'isNumber': isNumber,
'isArray': isArray
});

View file

@ -37,7 +37,6 @@ Browser.prototype = {
existingURL += '#';
if (existingURL != url)
this.location.href = url;
this.existingURL = url;
},
getUrl: function() {

View file

@ -47,6 +47,7 @@
addScript("/Parser.js");
addScript("/Resource.js");
addScript("/Browser.js");
addScript("/AngularPublic.js");
// Extension points
addScript("/apis.js");

View file

@ -24,9 +24,9 @@ angularService("$location", function(browser){
}
}
var hashKeyValue = toKeyValue(location.hashSearch);
return location.href +
(location.hashPath ? location.hashPath : '') +
var hash = (location.hashPath ? location.hashPath : '') +
(hashKeyValue ? '?' + hashKeyValue : '');
return location.href.split('#')[0] + '#' + (hash ? hash : '');
}
browser.watchUrl(function(url){
location(url);

View file

@ -24,7 +24,7 @@ describe("services", function(){
scope.$location.hashPath = 'page=http://path';
scope.$location.hashSearch = {k:'a=b'};
expect(scope.$location()).toEqual('http://host:123/p/a/t/h.html?query=value#path?key=valuepage=http://path?k=a%3Db');
expect(scope.$location()).toEqual('http://host:123/p/a/t/h.html?query=value#page=http://path?k=a%3Db');
});
it('should parse file://', function(){
@ -39,7 +39,7 @@ describe("services", function(){
expect(scope.$location.hashPath).toEqual('');
expect(scope.$location.hashSearch).toEqual({});
expect(scope.$location()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');
expect(scope.$location()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html#');
});
xit('should add stylesheets', function(){