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

Commit 764fa86

Browse files
thorn0pkozlowski-opensource
authored andcommitted
fix($browser): allow chaining url() calls in setter mode
Closes #10157
1 parent 7812dfc commit 764fa86

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ng/browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function Browser(window, document, $log, $sniffer) {
170170
// IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode.
171171
// See https://github.com/angular/angular.js/commit/ffb2701
172172
if (lastBrowserUrl === url && (!$sniffer.history || sameState)) {
173-
return;
173+
return self;
174174
}
175175
var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url);
176176
lastBrowserUrl = url;

test/ng/browserSpecs.js

+6
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,12 @@ describe('browser', function() {
576576
expect(browser.url('http://any.com')).toBe(browser);
577577
});
578578

579+
it('should return $browser to allow chaining even if the previous and current URLs and states match', function() {
580+
expect(browser.url('http://any.com').url('http://any.com')).toBe(browser);
581+
var state = { any: 'foo' };
582+
expect(browser.url('http://any.com', false, state).url('http://any.com', false, state)).toBe(browser);
583+
expect(browser.url('http://any.com', true, state).url('http://any.com', true, state)).toBe(browser);
584+
});
579585

580586
it('should decode single quotes to work around FF bug 407273', function() {
581587
fakeWindow.location.href = "http://ff-bug/?single%27quote";

0 commit comments

Comments
 (0)