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

Commit fe7d9de

Browse files
chrisirhcbtford
authored andcommitted
fix($browser): handle async href on url change in <=IE9
Closes #9235
1 parent 029ac8c commit fe7d9de

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
@@ -641,6 +641,29 @@ describe('browser', function() {
641641
expect($location.path()).toBe('/someTestHash');
642642
});
643643
});
644+
645+
});
646+
647+
describe('integration test with $rootScope', function() {
648+
649+
beforeEach(module(function($provide, $locationProvider) {
650+
$provide.value('$browser', browser);
651+
browser.pollFns = [];
652+
}));
653+
654+
it('should not interfere with legacy browser url replace behavior', function() {
655+
inject(function($rootScope) {
656+
var current = fakeWindow.location.href;
657+
var newUrl = 'notyet';
658+
sniffer.history = false;
659+
browser.url(newUrl, true);
660+
expect(browser.url()).toBe(newUrl);
661+
$rootScope.$digest();
662+
expect(browser.url()).toBe(newUrl);
663+
expect(fakeWindow.location.href).toBe(current);
664+
});
665+
});
666+
644667
});
645668

646669
});

0 commit comments

Comments
 (0)