File tree Expand file tree Collapse file tree 2 files changed +39
-10
lines changed Expand file tree Collapse file tree 2 files changed +39
-10
lines changed Original file line number Diff line number Diff line change 1- import { Fragment } from 'vue'
2- import { isArray } from '@intlify/shared'
1+ import { Fragment , VNode } from 'vue'
32
43import type { NamedValue } from '@intlify/core-base'
5-
64export function getInterpolateArg (
75 // eslint-disable-next-line @typescript-eslint/no-explicit-any
86 { slots } : any , // SetupContext,
97 keys : string [ ]
108) : NamedValue | unknown [ ] {
119 if ( keys . length === 1 && keys [ 0 ] === 'default' ) {
1210 // default slot with list
13- const ret = slots . default ? slots . default ( ) : [ ]
11+ const ret : VNode [ ] = slots . default ? slots . default ( ) : [ ]
1412 // eslint-disable-next-line @typescript-eslint/no-explicit-any
15- return ret . reduce ( ( slot : any [ ] , current : any ) => {
16- return ( slot = [
13+ return ret . reduce ( ( slot : ( VNode | typeof Fragment ) [ ] , current : any ) => {
14+ return [
1715 ...slot ,
18- ...( isArray ( current . children ) ? current . children : [ current ] )
19- ] )
16+ ...( current . type === Fragment ? current . children : [ current ] )
17+ ]
2018 } , [ ] )
2119 } else {
2220 // named slots
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ test('issue #708', async () => {
9696 <strong>{{ $t("world") }}</strong>
9797 </template>
9898 </i18n-t>
99-
99+
100100 <br />
101-
101+
102102 <C2>
103103 <div>{{ $t("hello", { world: $t("world") }) }}</div>
104104 <i18n-t keypath="hello" tag="div">
@@ -685,3 +685,34 @@ test('issue #1083', async () => {
685685 await nextTick ( )
686686 expect ( dirEl ! . textContent ) . toEqual ( 'Hello World!' )
687687} )
688+
689+ test ( 'issue #1123' , async ( ) => {
690+ const i18n = createI18n ( {
691+ legacy : false ,
692+ locale : 'en' ,
693+ messages
694+ } )
695+
696+ const App = defineComponent ( {
697+ setup ( ) {
698+ useI18n ( )
699+ const values = ref ( [ 'kazupon' , 'oranges' ] )
700+ return { values }
701+ } ,
702+ template : `
703+ <i18n-t keypath="message.list_multi" locale="en">
704+ <span>Hello</span>
705+ <a
706+ >
707+ <strong>Vue </strong>
708+ I18n
709+ </a>
710+ </i18n-t>
711+ `
712+ } )
713+ const wrapper = await mount ( App , i18n )
714+
715+ expect ( wrapper . html ( ) ) . toEqual (
716+ `hello, <span>Hello</span>! Do you like <a><strong>Vue </strong> I18n </a>?`
717+ )
718+ } )
You can’t perform that action at this time.
0 commit comments