Skip to content

Commit 0a345ed

Browse files
committed
Auto merge of #3224 - plaets:issue-3108, r=Turbo87
Catch exceptions thrown when an anchor in a readme is invalid Implements a fix to #3108
2 parents f832e50 + e52140c commit 0a345ed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/initializers/hashchange.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ function findElementByFragmentName(document, name) {
1111
return;
1212
}
1313

14-
return document.querySelector(`#${name}`) || document.getElementsByName(name)[0];
14+
try {
15+
return document.querySelector(`#${name}`) || document.getElementsByName(name)[0];
16+
} catch {
17+
// Catches execptions thrown when an anchor in a readme was invalid (see issue #3108)
18+
return;
19+
}
1520
}
1621

1722
function hashchange() {

0 commit comments

Comments
 (0)