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

Commit 404b95f

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

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
@@ -182,6 +182,10 @@ function Browser(window, document, $log, $sniffer) {
182182

183183
function fireUrlChange() {
184184
newLocation = null;
185+
checkUrlChange();
186+
}
187+
188+
function checkUrlChange() {
185189
if (lastBrowserUrl == self.url()) return;
186190

187191
lastBrowserUrl = self.url();
@@ -237,7 +241,7 @@ function Browser(window, document, $log, $sniffer) {
237241
* Needs to be exported to be able to check for changes that have been done in sync,
238242
* as hashchange/popstate events fire in async.
239243
*/
240-
self.$$checkUrlChange = fireUrlChange;
244+
self.$$checkUrlChange = checkUrlChange;
241245

242246
//////////////////////////////////////////////////////////////
243247
// 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)