mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-24 22:03:43 +00:00
revert: fix(location): fix parameter handling on search()
This reverts commit 90532f5e3c.
The commit contains references to minErr that are not available
in the stable branch.
This commit is contained in:
parent
90532f5e3c
commit
9c53d0769e
3 changed files with 11 additions and 51 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
@ngdoc error
|
|
||||||
@name $location:wpt
|
|
||||||
@fullName Wrong parameter type
|
|
||||||
@description
|
|
||||||
|
|
@ -349,24 +349,17 @@ LocationUrl.prototype = {
|
||||||
* @return {string} search
|
* @return {string} search
|
||||||
*/
|
*/
|
||||||
search: function(search, paramValue) {
|
search: function(search, paramValue) {
|
||||||
switch (arguments.length) {
|
if (isUndefined(search))
|
||||||
case 0:
|
return this.$$search;
|
||||||
return this.$$search;
|
|
||||||
case 1:
|
if (isDefined(paramValue)) {
|
||||||
if (isString(search)) {
|
if (paramValue === null) {
|
||||||
this.$$search = parseKeyValue(search);
|
delete this.$$search[search];
|
||||||
} else if (isObject(search)) {
|
} else {
|
||||||
this.$$search = search;
|
this.$$search[search] = paramValue;
|
||||||
} else {
|
}
|
||||||
throw $locationMinErr('wpt', 'First parameter of function must be string or an object.');
|
} else {
|
||||||
}
|
this.$$search = isString(search) ? parseKeyValue(search) : search;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (paramValue == undefined || paramValue == null) {
|
|
||||||
delete this.$$search[search];
|
|
||||||
} else {
|
|
||||||
this.$$search[search] = paramValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$$compose();
|
this.$$compose();
|
||||||
|
|
|
||||||
|
|
@ -78,35 +78,6 @@ describe('$location', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('search() should handle multiple value', function() {
|
|
||||||
url.search('a&b');
|
|
||||||
expect(url.search()).toEqual({a: true, b: true});
|
|
||||||
|
|
||||||
url.search('a', null);
|
|
||||||
|
|
||||||
expect(url.search()).toEqual({b: true});
|
|
||||||
|
|
||||||
url.search('b', undefined);
|
|
||||||
expect(url.search()).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('search() should handle single value', function() {
|
|
||||||
url.search('ignore');
|
|
||||||
expect(url.search()).toEqual({ignore: true});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('search() should throw error an incorrect argument', function() {
|
|
||||||
expect(function() {
|
|
||||||
url.search(null);
|
|
||||||
}).toThrow('[$location:wpt] First parameter of function must be string or an object.');
|
|
||||||
expect(function() {
|
|
||||||
url.search(undefined);
|
|
||||||
}).toThrow('[$location:wpt] First parameter of function must be string or an object.');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('hash() should change hash fragment', function() {
|
it('hash() should change hash fragment', function() {
|
||||||
url.hash('new-hash');
|
url.hash('new-hash');
|
||||||
expect(url.hash()).toBe('new-hash');
|
expect(url.hash()).toBe('new-hash');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue