diff options
| author | Misko Hevery | 2013-07-31 16:54:21 -0700 |
|---|---|---|
| committer | Misko Hevery | 2013-07-31 16:55:06 -0700 |
| commit | 705c9d95bc3157547ac6008d2f0a6a0c0e0ca60a (patch) | |
| tree | f88e8de9e31fba05b232fe6bf841bd62cf886988 /src/ng/location.js | |
| parent | 61906d3517428b6d52d3284b8d26d1a46e01dad7 (diff) | |
| download | angular.js-705c9d95bc3157547ac6008d2f0a6a0c0e0ca60a.tar.bz2 | |
fix(location): fix parameter handling on search()
Diffstat (limited to 'src/ng/location.js')
| -rw-r--r-- | src/ng/location.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ng/location.js b/src/ng/location.js index 6ae1066c..730d2433 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -353,17 +353,24 @@ LocationHashbangInHtml5Url.prototype = * @return {string} search */ search: function(search, paramValue) { - if (isUndefined(search)) - return this.$$search; - - if (isDefined(paramValue)) { - if (paramValue === null) { - delete this.$$search[search]; - } else { - this.$$search[search] = paramValue; - } - } else { - this.$$search = isString(search) ? parseKeyValue(search) : search; + switch (arguments.length) { + case 0: + return this.$$search; + case 1: + if (isString(search)) { + this.$$search = parseKeyValue(search); + } else if (isObject(search)) { + this.$$search = search; + } else { + throw $locationMinErr('wpt', 'First parameter of function must be string or an object.'); + } + break; + default: + if (paramValue == undefined || paramValue == null) { + delete this.$$search[search]; + } else { + this.$$search[search] = paramValue; + } } this.$$compose(); |
