mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-20 04:11:51 +00:00
$location.updateHash should not preserve hashSearch when hashSearch is undefined
This commit is contained in:
parent
a6c45c3e66
commit
bf8013ad57
2 changed files with 9 additions and 2 deletions
|
|
@ -172,8 +172,7 @@ angularServiceInject("$location", function($browser) {
|
||||||
|
|
||||||
if (isString(path)) {
|
if (isString(path)) {
|
||||||
hash.hashPath = path;
|
hash.hashPath = path;
|
||||||
if (isDefined(search))
|
hash.hashSearch = search || {};
|
||||||
hash.hashSearch = search;
|
|
||||||
} else
|
} else
|
||||||
hash.hashSearch = path;
|
hash.hashSearch = path;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,14 @@ describe("service", function(){
|
||||||
expect($location.hashPath).toEqual('path');
|
expect($location.hashPath).toEqual('path');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should reset hashSearch when updating with a single string', function() {
|
||||||
|
$location.updateHash({foo:'bar'}); //set some initial state for hashSearch
|
||||||
|
|
||||||
|
$location.updateHash('path');
|
||||||
|
expect($location.hashPath).toEqual('path');
|
||||||
|
expect($location.hashSearch).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
it('should accept single object argument to update search', function() {
|
it('should accept single object argument to update search', function() {
|
||||||
$location.updateHash({a: 'b'});
|
$location.updateHash({a: 'b'});
|
||||||
expect($location.hash).toEqual('?a=b');
|
expect($location.hash).toEqual('?a=b');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue