$cookie factory fn should not run $eval

This commit is contained in:
Igor Minar 2011-02-27 15:54:06 -08:00
parent edbe9d8ca8
commit 65585a2d3c

View file

@ -16,7 +16,8 @@ angularServiceInject('$cookies', function($browser) {
var rootScope = this, var rootScope = this,
cookies = {}, cookies = {},
lastCookies = {}, lastCookies = {},
lastBrowserCookies; lastBrowserCookies,
runEval = false;
//creates a poller fn that copies all cookies from the $browser to service & inits the service //creates a poller fn that copies all cookies from the $browser to service & inits the service
$browser.addPollFn(function() { $browser.addPollFn(function() {
@ -25,10 +26,12 @@ angularServiceInject('$cookies', function($browser) {
lastBrowserCookies = currentCookies; lastBrowserCookies = currentCookies;
copy(currentCookies, lastCookies); copy(currentCookies, lastCookies);
copy(currentCookies, cookies); copy(currentCookies, cookies);
rootScope.$eval(); if (runEval) rootScope.$eval();
} }
})(); })();
runEval = true;
//at the end of each eval, push cookies //at the end of each eval, push cookies
//TODO: this should happen before the "delayed" watches fire, because if some cookies are not //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. // strings or browser refuses to store some cookies, we update the model in the push fn.