$browser poller should notify $location only once per url change

This commit is contained in:
Igor Minar 2011-01-31 23:22:12 -08:00
parent c4497d60bc
commit 9462c78fbf
3 changed files with 7 additions and 0 deletions

View file

@ -243,6 +243,7 @@ function Browser(window, document, body, XHR, $log) {
self.addPollFn(function() {
if (lastBrowserUrl != self.getUrl()) {
listener();
lastBrowserUrl = self.getUrl();
}
});
}

View file

@ -92,6 +92,7 @@ function MockBrowser() {
function() {
if (self.lastUrl != self.url) {
listener();
self.lastUrl == self.url
}
}
);

View file

@ -358,6 +358,11 @@ describe('browser', function(){
expect(events).toEqual([]);
browser.poll();
expect(events).toEqual(['x']);
//don't do anything if url hasn't changed
events = [];
browser.poll();
expect(events).toEqual([]);
});