Skip to content

Commit 63e1dac

Browse files
Fix JS error when hasFocus method is overwritten on search index load
1 parent f3ee794 commit 63e1dac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/renderer/html_handlebars/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn create_files(
6969
// To reduce the size of the generated JSON by preventing all `"` characters to be
7070
// escaped, we instead surround the string with much less common `'` character.
7171
format!(
72-
"window.search = JSON.parse('{}');",
72+
"window.search = Object.assign(window.search, JSON.parse('{}'));",
7373
index.replace("\\", "\\\\").replace("'", "\\'")
7474
)
7575
.as_bytes(),

tests/gui/search.goml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This tests basic search behavior.
22

3+
fail-on-js-error: true
34
go-to: |DOC_PATH| + "index.html"
45

56
define-function: (
@@ -41,6 +42,9 @@ press-key: 's'
4142
wait-for-css-false: ("#search-wrapper", {"display": "none"})
4243
// We ensure the search bar has the focus.
4344
assert: "#searchbar:focus"
45+
// Pressing a key will therefore update the search input.
46+
press-key: 't'
47+
assert-text: ("#searchbar", "t")
4448

4549
// Now we press `Escape` to ensure that the search input disappears again.
4650
press-key: 'Escape'

0 commit comments

Comments
 (0)