Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 63bdb08

Browse files
committed
fix($browser): handle async href on url change in <=IE9
Fixes #9235
1 parent 729c238 commit 63bdb08

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/ng/browser.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ function Browser(window, document, $log, $sniffer) {
184184

185185
function fireUrlChange() {
186186
newLocation = null;
187+
checkUrlChange();
188+
}
189+
190+
function checkUrlChange() {
187191
if (lastBrowserUrl == self.url()) return;
188192

189193
lastBrowserUrl = self.url();
@@ -239,7 +243,7 @@ function Browser(window, document, $log, $sniffer) {
239243
* Needs to be exported to be able to check for changes that have been done in sync,
240244
* as hashchange/popstate events fire in async.
241245
*/
242-
self.$$checkUrlChange = fireUrlChange;
246+
self.$$checkUrlChange = checkUrlChange;
243247

244248
//////////////////////////////////////////////////////////////
245249
// Misc API

test/ng/browserSpecs.js

+23
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,29 @@ describe('browser', function() {
646646
expect($location.path()).toBe('/someTestHash');
647647
});
648648
});
649+
650+
});
651+
652+
describe('integration test with $rootScope', function() {
653+
654+
beforeEach(module(function($provide, $locationProvider) {
655+
$provide.value('$browser', browser);
656+
browser.pollFns = [];
657+
}));
658+
659+
it('should not interfere with legacy browser url replace behavior', function() {
660+
inject(function($rootScope) {
661+
var current = fakeWindow.location.href;
662+
var newUrl = 'notyet';
663+
sniffer.history = false;
664+
browser.url(newUrl, true);
665+
expect(browser.url()).toBe(newUrl);
666+
$rootScope.$digest();
667+
expect(browser.url()).toBe(newUrl);
668+
expect(fakeWindow.location.href).toBe(current);
669+
});
670+
});
671+
649672
});
650673

651674
});

0 commit comments

Comments
 (0)