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

Commit be60ee9

Browse files
fix($browser): use location.hash if only the hash has changed
Closes #9635
1 parent 875f8f6 commit be60ee9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/browser.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ function Browser(window, document, $log, $sniffer) {
191191
}
192192
if (replace) {
193193
location.replace(url);
194-
} else {
194+
} else if (!sameBase) {
195195
location.href = url;
196+
} else {
197+
location.hash = getHash(url);
196198
}
197199
}
198200
return self;

test/ng/browserSpecs.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* global getHash:true, stripHash:true */
4+
35
var historyEntriesLength;
46
var sniffer = {};
57

@@ -51,6 +53,12 @@ function MockWindow(options) {
5153
mockWindow.history.state = null;
5254
historyEntriesLength++;
5355
},
56+
get hash() {
57+
return getHash(locationHref);
58+
},
59+
set hash(value) {
60+
locationHref = stripHash(locationHref) + '#' + value;
61+
},
5462
replace: function(url) {
5563
locationHref = url;
5664
mockWindow.history.state = null;

0 commit comments

Comments
 (0)