mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-11 08:13:10 +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() {
|
self.addPollFn(function() {
|
||||||
if (lastBrowserUrl != self.getUrl()) {
|
if (lastBrowserUrl != self.getUrl()) {
|
||||||
listener();
|
listener();
|
||||||
|
lastBrowserUrl = self.getUrl();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
src/angular-mocks.js
vendored
1
src/angular-mocks.js
vendored
|
|
@ -92,6 +92,7 @@ function MockBrowser() {
|
||||||
function() {
|
function() {
|
||||||
if (self.lastUrl != self.url) {
|
if (self.lastUrl != self.url) {
|
||||||
listener();
|
listener();
|
||||||
|
self.lastUrl == self.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,11 @@ describe('browser', function(){
|
||||||
expect(events).toEqual([]);
|
expect(events).toEqual([]);
|
||||||
browser.poll();
|
browser.poll();
|
||||||
expect(events).toEqual(['x']);
|
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