Skip to content

Commit e73670b

Browse files
authored
Unrolled build for rust-lang#118977
Rollup merge of rust-lang#118977 - GuillaumeGomez:simplifysrc-script, r=notriddle Simplify `src-script.js` code Instead of keeping this value in the global scope and still use it in the function in case it wasn't used outside, let's just use it inside the function. r? ``@notriddle``
2 parents 3f39cae + 552143c commit e73670b

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/librustdoc/html/static/js/src-script.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,8 @@ function createSrcSidebar() {
146146
}
147147
}
148148

149-
const lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
150-
151-
function highlightSrcLines(match) {
152-
if (typeof match === "undefined") {
153-
match = window.location.hash.match(lineNumbersRegex);
154-
}
149+
function highlightSrcLines() {
150+
const match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
155151
if (!match) {
156152
return;
157153
}
@@ -233,12 +229,7 @@ const handleSrcHighlight = (function() {
233229
};
234230
}());
235231

236-
window.addEventListener("hashchange", () => {
237-
const match = window.location.hash.match(lineNumbersRegex);
238-
if (match) {
239-
return highlightSrcLines(match);
240-
}
241-
});
232+
window.addEventListener("hashchange", highlightSrcLines);
242233

243234
onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
244235
el.addEventListener("click", handleSrcHighlight);

0 commit comments

Comments
 (0)