Skip to content

Commit 897e627

Browse files
committed
Auto merge of #1848 - rust-lang:fix-1847, r=sgrif
Make crate-readme component scroll to URL fragment if specified Fixes #1847
2 parents eb60255 + 02562c2 commit 897e627

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/components/crate-readme.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@ export default Component.extend({
77
this.$('pre > code').each(function() {
88
window.Prism.highlightElement(this);
99
});
10+
this.scrollToFragment();
11+
},
12+
13+
scrollToFragment() {
14+
if (location.hash) {
15+
let anchor_id = location.hash.substr(1);
16+
document.getElementById(anchor_id).scrollIntoView();
17+
}
1018
},
1119
});

0 commit comments

Comments
 (0)