Do not run `window.history.replaceState()` unconditionally (#13918)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Harmen StoppelsandAdam Turner authored and GitHub committed 2025-11-24 22:24:23 +00:00
1 parent c06bfceee2
commit 401d81f024
2 files changed
+8 -2

No files matched your search

+2
View File
@@ -148,6 +148,8 @@ Bugs fixed
* #14059: LaTeX: Footnotes cause pdflatex error with French language
(since late June 2025 upstream change to LaTeX ``babel-french``).
Patch by Jean-François B.
* #13916: HTML Search: do not clear text fragments from the URL on page load.
Patch by Harmen Stoppels.
Testing
@@ -80,8 +80,12 @@ const SphinxHighlight = {
|| url.searchParams.get("highlight")
|| "";
localStorage.removeItem("sphinx_highlight_terms");
url.searchParams.delete("highlight");
window.history.replaceState({}, "", url);
// Update history only if '?highlight' is present; otherwise it
// clears text fragments (not set in window.location by the browser)
if (url.searchParams.has("highlight")) {
url.searchParams.delete("highlight");
window.history.replaceState({}, "", url);
}
// get individual terms from highlight string
const terms = highlight