mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
$browser poller should notify $location only once per url change
This commit is contained in:
parent
c4497d60bc
commit
9462c78fbf
3 changed files with 7 additions and 0 deletions
|
|
@ -243,6 +243,7 @@ function Browser(window, document, body, XHR, $log) {
|
|||
self.addPollFn(function() {
|
||||
if (lastBrowserUrl != self.getUrl()) {
|
||||
listener();
|
||||
lastBrowserUrl = self.getUrl();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
1
src/angular-mocks.js
vendored
1
src/angular-mocks.js
vendored
|
|
@ -92,6 +92,7 @@ function MockBrowser() {
|
|||
function() {
|
||||
if (self.lastUrl != self.url) {
|
||||
listener();
|
||||
self.lastUrl == self.url
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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([]);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue