authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-08-06 16:43:25+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-08-06 16:43:25+02:00
log059713478a06ac15295ead030e95dfc0a205541f
tree0745567526868aa60d80645a048e8d76b60d3905
parent86d9c3de2b6b43329c16678f1bd7eaddd3d218d7
parent7afe7de4f0949a8af0d89ccd4b26808a9c07cc5c
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #12343 from rudedogg/master

autodoc: only modify the DOM once to display the search results

1 files changed, 14 insertions(+), 15 deletions(-)

lib/docs/main.js+14-15
...@@ -3326,29 +3326,28 @@ var zigAnalysis;...@@ -3326,29 +3326,28 @@ var zigAnalysis;
3326 }3326 }
33273327
3328 if (matchedItems.length !== 0) {3328 if (matchedItems.length !== 0) {
3329 resizeDomList(
3330 domListSearchResults,
3331 matchedItems.length,
3332 '<li><a href="#"></a></li>'
3333 );
3334
3335 matchedItems.sort(function (a, b) {3329 matchedItems.sort(function (a, b) {
3336 let cmp = operatorCompare(b.points, a.points);3330 let cmp = operatorCompare(b.points, a.points);
3337 if (cmp != 0) return cmp;3331 if (cmp != 0) return cmp;
3338 return operatorCompare(a.decl.name, b.decl.name);3332 return operatorCompare(a.decl.name, b.decl.name);
3339 });3333 });
33403334
3335 // Build up the list of search results
3336 let matchedItemsHTML = "";
3337
3341 for (let i = 0; i < matchedItems.length; i += 1) {3338 for (let i = 0; i < matchedItems.length; i += 1) {
3342 let liDom = domListSearchResults.children[i];3339 const match = matchedItems[i];
3343 let aDom = liDom.children[0];3340 const lastPkgName = match.path.pkgNames[match.path.pkgNames.length - 1];
3344 let match = matchedItems[i];3341
3345 let lastPkgName = match.path.pkgNames[match.path.pkgNames.length - 1];3342 const text = lastPkgName + "." + match.path.declNames.join(".");
3346 aDom.textContent = lastPkgName + "." + match.path.declNames.join(".");3343 const href = navLink(match.path.pkgNames, match.path.declNames);
3347 aDom.setAttribute(3344
3348 "href",3345 matchedItemsHTML += `<li><a href="${href}">${text}</a></li>`;
3349 navLink(match.path.pkgNames, match.path.declNames)
3350 );
3351 }3346 }
3347
3348 // Replace the search results using our newly constructed HTML string
3349 domListSearchResults.innerHTML = matchedItemsHTML;
3350
3352 renderSearchCursor();3351 renderSearchCursor();
33533352
3354 domSectSearchResults.classList.remove("hidden");3353 domSectSearchResults.classList.remove("hidden");