Skip to content

Commit 178efc3

Browse files
committed
[fixed] <Link href> when using HashHistory
1 parent ede0b53 commit 178efc3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

modules/HashHistory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ class HashHistory extends DOMHistory {
164164
this._notifyChange();
165165
}
166166

167-
makeHref(pathname, query) {
168-
return '#' + super.makeHref(pathname, query);
167+
makeHref(path) {
168+
return '#' + path;
169169
}
170170

171171
}

modules/RouterContextMixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ var RouterContextMixin = {
7171
* pathname and query.
7272
*/
7373
makeHref(pathname, query) {
74-
return this.makePath(pathname, query);
74+
var path = this.makePath(pathname, query);
75+
var { history } = this.props;
76+
77+
if (history && history.makeHref)
78+
return history.makeHref(path);
79+
80+
return path;
7581
},
7682

7783
/**

modules/__tests__/Link-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ describe('A <Link>', function () {
6464
});
6565

6666
render((
67-
<Router history={new HashHistory()}>
67+
<Router history={new HashHistory}>
6868
<Route path="/" component={LinkWrapper}/>
6969
</Router>
7070
), div, function () {
7171
var a = div.querySelector('a');
72-
expect(a.getAttribute('href')).toEqual('/#/hello/michael?the=query');
72+
expect(a.getAttribute('href')).toEqual('#/hello/michael?the=query');
7373
});
7474
});
7575

0 commit comments

Comments
 (0)