diff options
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(); |
