Skip to content

Commit 791f45a

Browse files
author
Timothy Johnson
committed
Fix undefined text
1 parent e06e916 commit 791f45a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/nodes/SearchTerm.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
export let text
55
6-
$: i = text.indexOf($searchValue)
7-
$: pre = text.substring(0, i)
8-
$: highlight = text.substring(i, i + $searchValue.length)
9-
$: post = text.substring(i + $searchValue.length)
6+
$: i = text ? text.indexOf($searchValue) : -1
7+
$: pre = text ? text.substring(0, i) : ''
8+
$: highlight = text ? text.substring(i, i + $searchValue.length) : ''
9+
$: post = text ? text.substring(i + $searchValue.length) : ''
1010
</script>
1111

1212
<style>

0 commit comments

Comments
 (0)