Skip to content

Commit 6ca4639

Browse files
Fix random failure when JS code is executed when the whole file was not read yet
1 parent 40daf23 commit 6ca4639

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5393,43 +5393,6 @@ function updateCrate(ev) {
53935393
search(true);
53945394
}
53955395

5396-
// @ts-expect-error
5397-
function initSearch(searchIndx) {
5398-
rawSearchIndex = searchIndx;
5399-
if (typeof window !== "undefined") {
5400-
// @ts-expect-error
5401-
docSearch = new DocSearch(rawSearchIndex, ROOT_PATH, searchState);
5402-
registerSearchEvents();
5403-
// If there's a search term in the URL, execute the search now.
5404-
if (window.searchState.getQueryStringParams().search) {
5405-
search();
5406-
}
5407-
} else if (typeof exports !== "undefined") {
5408-
// @ts-expect-error
5409-
docSearch = new DocSearch(rawSearchIndex, ROOT_PATH, searchState);
5410-
exports.docSearch = docSearch;
5411-
exports.parseQuery = DocSearch.parseQuery;
5412-
}
5413-
}
5414-
5415-
if (typeof exports !== "undefined") {
5416-
exports.initSearch = initSearch;
5417-
}
5418-
5419-
if (typeof window !== "undefined") {
5420-
// @ts-expect-error
5421-
window.initSearch = initSearch;
5422-
// @ts-expect-error
5423-
if (window.searchIndex !== undefined) {
5424-
// @ts-expect-error
5425-
initSearch(window.searchIndex);
5426-
}
5427-
} else {
5428-
// Running in Node, not a browser. Run initSearch just to produce the
5429-
// exports.
5430-
initSearch(new Map());
5431-
}
5432-
54335396
// Parts of this code are based on Lucene, which is licensed under the
54345397
// Apache/2.0 license.
54355398
// More information found here:
@@ -5908,3 +5871,40 @@ Lev1TParametricDescription.prototype.toStates3 = /*3 bits per value */ new Int32
59085871
Lev1TParametricDescription.prototype.offsetIncrs3 = /*2 bits per value */ new Int32Array([
59095872
0xa0fc0000,0x5555ba08,0x55555555,
59105873
]);
5874+
5875+
// @ts-expect-error
5876+
function initSearch(searchIndx) {
5877+
rawSearchIndex = searchIndx;
5878+
if (typeof window !== "undefined") {
5879+
// @ts-expect-error
5880+
docSearch = new DocSearch(rawSearchIndex, ROOT_PATH, searchState);
5881+
registerSearchEvents();
5882+
// If there's a search term in the URL, execute the search now.
5883+
if (window.searchState.getQueryStringParams().search) {
5884+
search();
5885+
}
5886+
} else if (typeof exports !== "undefined") {
5887+
// @ts-expect-error
5888+
docSearch = new DocSearch(rawSearchIndex, ROOT_PATH, searchState);
5889+
exports.docSearch = docSearch;
5890+
exports.parseQuery = DocSearch.parseQuery;
5891+
}
5892+
}
5893+
5894+
if (typeof exports !== "undefined") {
5895+
exports.initSearch = initSearch;
5896+
}
5897+
5898+
if (typeof window !== "undefined") {
5899+
// @ts-expect-error
5900+
window.initSearch = initSearch;
5901+
// @ts-expect-error
5902+
if (window.searchIndex !== undefined) {
5903+
// @ts-expect-error
5904+
initSearch(window.searchIndex);
5905+
}
5906+
} else {
5907+
// Running in Node, not a browser. Run initSearch just to produce the
5908+
// exports.
5909+
initSearch(new Map());
5910+
}

0 commit comments

Comments
 (0)