@@ -19,6 +19,9 @@ import { SearchLoading } from './SearchLoading.js'
1919
2020import '../styles/search-result.scss'
2121
22+ const wordToVNodes = ( display : Word [ ] ) : ( VNode | string ) [ ] =>
23+ display . map ( ( word ) => ( isString ( word ) ? word : h ( word [ 0 ] , word [ 1 ] ) ) )
24+
2225export default defineComponent ( {
2326 name : 'SearchResult' ,
2427
@@ -139,9 +142,6 @@ export default defineComponent({
139142 else activePreviousResult ( )
140143 }
141144
142- const getVNodes = ( display : Word [ ] ) : ( VNode | string ) [ ] =>
143- display . map ( ( word ) => ( isString ( word ) ? word : h ( word [ 0 ] , word [ 1 ] ) ) )
144-
145145 const getDisplay = ( matchedItem : MatchedItem ) : ( VNode | string ) [ ] => {
146146 if ( matchedItem . type === 'customField' ) {
147147 const formatterConfig =
@@ -152,11 +152,13 @@ export default defineComponent({
152152 : formatterConfig . split ( '$content' )
153153
154154 return matchedItem . display . map ( ( display ) =>
155- h ( 'div' , getVNodes ( [ prefix , ...display , suffix ] ) ) ,
155+ h ( 'div' , wordToVNodes ( [ prefix , ...display , suffix ] ) ) ,
156156 )
157157 }
158158
159- return matchedItem . display . map ( ( display ) => h ( 'div' , getVNodes ( display ) ) )
159+ return matchedItem . display . map ( ( display ) =>
160+ h ( 'div' , wordToVNodes ( display ) ) ,
161+ )
160162 }
161163
162164 const resetSearchResult = ( ) : void => {
@@ -269,7 +271,7 @@ export default defineComponent({
269271 h (
270272 'div' ,
271273 item . display . flatMap ( ( display ) =>
272- getVNodes ( display ) ,
274+ wordToVNodes ( display ) ,
273275 ) ,
274276 ) ,
275277 ] ) ,
0 commit comments