diff options
| author | Misko Hevery | 2013-07-31 16:54:21 -0700 |
|---|---|---|
| committer | Misko Hevery | 2013-07-31 17:10:10 -0700 |
| commit | 90532f5e3c2016c99833a4dd779a5c4718c84f4d (patch) | |
| tree | 5c0763df89bc1c5c10e10895b9776b597d23c533 /src/ng/location.js | |
| parent | 2bc04d23fbc302e6dd52ab80a621aa264548d9e3 (diff) | |
| download | angular.js-90532f5e3c2016c99833a4dd779a5c4718c84f4d.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 e99137d5..9ec6300f 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -349,17 +349,24 @@ LocationUrl.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(); |
