aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCaitlin Potter2014-03-18 13:13:08 -0400
committerTobias Bosch2014-03-21 13:05:29 -0700
commit93d1c95c61dbfa565333bb64527a103242175af7 (patch)
tree45e6792dd6aa79dfedfbac89a5cc81189e357b5b /src
parent01a34f513bb567ed6d4c81d00d7c2a777c0dae01 (diff)
downloadangular.js-93d1c95c61dbfa565333bb64527a103242175af7.tar.bz2
fix(ngCookie): convert non-string values to string
Previously, non-string values stored in $cookies would be removed, without warning the user, and causing difficulty debugging. Now, the value is converted to string before being stored, and the value is not dropped. Serialization may be customized using the toString() method of an object's prototype. Closes #6151 Closes #6220
Diffstat (limited to 'src')
-rw-r--r--src/ngCookies/cookies.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ngCookies/cookies.js b/src/ngCookies/cookies.js
index ccfae23b..4f97c8dd 100644
--- a/src/ngCookies/cookies.js
+++ b/src/ngCookies/cookies.js
@@ -95,12 +95,10 @@ angular.module('ngCookies', ['ng']).
for(name in cookies) {
value = cookies[name];
if (!angular.isString(value)) {
- if (angular.isDefined(lastCookies[name])) {
- cookies[name] = lastCookies[name];
- } else {
- delete cookies[name];
- }
- } else if (value !== lastCookies[name]) {
+ value = '' + value;
+ cookies[name] = value;
+ }
+ if (value !== lastCookies[name]) {
$browser.cookies(name, value);
updated = true;
}