mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Searchtools: don't assume that all themes define some elements
When retrieving a non-existent element, jQuery would still return an
object (kind of empty one, so method calls won't raise a null
exception), but now `getElementById` will return null and raise an
exception when trying to call a method on that value.
This mainly affects the rtd theme,
which completely overrides the search page
d64dadf1ce/sphinx_rtd_theme/search.html
This commit is contained in:
parent
3b01fbe2ad
commit
6605bfbf7c
@ -48,7 +48,7 @@ if (!Scorer) {
|
||||
}
|
||||
|
||||
const _removeChildren = (element) => {
|
||||
while (element.lastChild) element.removeChild(element.lastChild);
|
||||
while (element && element.lastChild) element.removeChild(element.lastChild);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -208,9 +208,11 @@ const Search = {
|
||||
Search.status = out.appendChild(searchSummary);
|
||||
Search.output = out.appendChild(searchList);
|
||||
|
||||
document.getElementById("search-progress").innerText = _(
|
||||
"Preparing search..."
|
||||
);
|
||||
const searchProgress = document.getElementById("search-progress");
|
||||
// Not all themes may have this element.
|
||||
if (searchProgress) {
|
||||
searchProgress.innerText = _("Preparing search...");
|
||||
}
|
||||
Search.startPulse();
|
||||
|
||||
// index already loaded, the browser was quick!
|
||||
|
Loading…
Reference in New Issue
Block a user