diff options
| author | Igor Minar | 2011-01-20 21:28:27 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-24 14:03:41 -0800 |
| commit | 94737cd01747e5c7b9b204590f812e4769add0e8 (patch) | |
| tree | faa3a19f418694e3453382bb8145d0727c834ec8 /src/services.js | |
| parent | c8bb044be13f33ef4c661ac9dbf7033b50a45d03 (diff) | |
| download | angular.js-94737cd01747e5c7b9b204590f812e4769add0e8.tar.bz2 | |
$cookies service should not call $eval during $eval
- added comment
- removed $eval call
- changed the code to not require $eval
- updated specs
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/services.js b/src/services.js index 7742b174..de65e30f 100644 --- a/src/services.js +++ b/src/services.js @@ -1118,6 +1118,8 @@ angularServiceInject('$cookies', function($browser) { })(); //at the end of each eval, push cookies + //TODO: this should happen before the "delayed" watches fire, because if some cookies are not + // strings or browser refuses to store some cookies, we update the model in the push fn. this.$onEval(PRIORITY_LAST, push); return cookies; @@ -1128,6 +1130,7 @@ angularServiceInject('$cookies', function($browser) { */ function push(){ var name, + value, browserCookies, updated; @@ -1140,15 +1143,22 @@ angularServiceInject('$cookies', function($browser) { //update all cookies updated in $cookies for(name in cookies) { - if (cookies[name] !== lastCookies[name]) { - $browser.cookies(name, cookies[name]); + value = cookies[name]; + if (!isString(value)) { + if (isDefined(lastCookies[name])) { + cookies[name] = lastCookies[name]; + } else { + delete cookies[name]; + } + } else if (value !== lastCookies[name]) { + $browser.cookies(name, value); updated = true; } } //verify what was actually stored if (updated){ - updated = !updated; + updated = false; browserCookies = $browser.cookies(); for (name in cookies) { @@ -1161,11 +1171,6 @@ angularServiceInject('$cookies', function($browser) { } updated = true; } - - } - - if (updated) { - rootScope.$eval(); } } } |
