diff options
author | Jan Vojt <jan@vojt.net> | 2020-10-27 12:37:45 +0300 |
---|---|---|
committer | Jan Vojt <jan@vojt.net> | 2020-10-27 12:44:20 +0300 |
commit | 46638bc01b4a52cd314c7d06ac110361d95b852e (patch) | |
tree | 1f411042494d8bf21806931d1e9f9e0e799cdc98 /sphinx/themes | |
parent | f2a31185a65b31883846e5d127bf9a7dfe968db0 (diff) |
Fix unnecessary load of images when parsing the document text for search function.
The issue was, that when searching, new element with all the HTML content
was created. This caused loading of all images in the background. However, in
the end, these images are stripped from search result anyway, so there is no
point in loading them.
In cases where images were included in HTML files in a different directory from
search.html, this behaviour was even causing 404 errors because of wrong relative URLs.
This commit fixes the issue by creating virtual document and using that as the owner
document of temporary meta-element used for searching and parsing purposes.
The virtual owner document causes browser to not load the images.
Diffstat (limited to 'sphinx/themes')
-rw-r--r-- | sphinx/themes/basic/static/searchtools.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index 970d0d975..261ecaa92 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -59,10 +59,10 @@ var Search = { _pulse_status : -1, htmlToText : function(htmlString) { - var htmlElement = document.createElement('span'); - htmlElement.innerHTML = htmlString; - $(htmlElement).find('.headerlink').remove(); - docContent = $(htmlElement).find('[role=main]')[0]; + var virtualDocument = document.implementation.createHTMLDocument('virtual'); + var htmlElement = $(htmlString, virtualDocument); + htmlElement.find('.headerlink').remove(); + docContent = htmlElement.find('[role=main]')[0]; if(docContent === undefined) { console.warn("Content block not found. Sphinx search tries to obtain it " + "via '[role=main]'. Could you check your theme or template."); |