diff options
| author | Loris Cro <kappaloris@gmail.com> | 2022-08-06 16:43:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-06 16:43:25 +0200 |
| commit | 059713478a06ac15295ead030e95dfc0a205541f (patch) | |
| tree | 0745567526868aa60d80645a048e8d76b60d3905 /lib/docs | |
| parent | 86d9c3de2b6b43329c16678f1bd7eaddd3d218d7 (diff) | |
| parent | 7afe7de4f0949a8af0d89ccd4b26808a9c07cc5c (diff) | |
| download | zig-059713478a06ac15295ead030e95dfc0a205541f.tar.gz zig-059713478a06ac15295ead030e95dfc0a205541f.zip | |
Merge pull request #12343 from rudedogg/master
autodoc: only modify the DOM once to display the search results
Diffstat (limited to 'lib/docs')
| -rw-r--r-- | lib/docs/main.js | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/docs/main.js b/lib/docs/main.js index 41a03322d9..2b6417c015 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -3326,29 +3326,28 @@ var zigAnalysis; } if (matchedItems.length !== 0) { - resizeDomList( - domListSearchResults, - matchedItems.length, - '<li><a href="#"></a></li>' - ); - matchedItems.sort(function (a, b) { let cmp = operatorCompare(b.points, a.points); if (cmp != 0) return cmp; return operatorCompare(a.decl.name, b.decl.name); }); + // Build up the list of search results + let matchedItemsHTML = ""; + for (let i = 0; i < matchedItems.length; i += 1) { - let liDom = domListSearchResults.children[i]; - let aDom = liDom.children[0]; - let match = matchedItems[i]; - let lastPkgName = match.path.pkgNames[match.path.pkgNames.length - 1]; - aDom.textContent = lastPkgName + "." + match.path.declNames.join("."); - aDom.setAttribute( - "href", - navLink(match.path.pkgNames, match.path.declNames) - ); + const match = matchedItems[i]; + const lastPkgName = match.path.pkgNames[match.path.pkgNames.length - 1]; + + const text = lastPkgName + "." + match.path.declNames.join("."); + const href = navLink(match.path.pkgNames, match.path.declNames); + + matchedItemsHTML += `<li><a href="${href}">${text}</a></li>`; } + + // Replace the search results using our newly constructed HTML string + domListSearchResults.innerHTML = matchedItemsHTML; + renderSearchCursor(); domSectSearchResults.classList.remove("hidden"); |
