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'
3
2
4
3
import type { NamedValue } from '@intlify/core-base'
5
-
6
4
export function getInterpolateArg (
7
5
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8
6
{ slots } : any , // SetupContext,
9
7
keys : string [ ]
10
8
) : NamedValue | unknown [ ] {
11
9
if ( keys . length === 1 && keys [ 0 ] === 'default' ) {
12
10
// default slot with list
13
- const ret = slots . default ? slots . default ( ) : [ ]
11
+ const ret : VNode [ ] = slots . default ? slots . default ( ) : [ ]
14
12
// 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 [
17
15
...slot ,
18
- ...( isArray ( current . children ) ? current . children : [ current ] )
19
- ] )
16
+ ...( current . type === Fragment ? current . children : [ current ] )
17
+ ]
20
18
} , [ ] )
21
19
} else {
22
20
// named slots
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ test('issue #708', async () => {
96
96
<strong>{{ $t("world") }}</strong>
97
97
</template>
98
98
</i18n-t>
99
-
99
+
100
100
<br />
101
-
101
+
102
102
<C2>
103
103
<div>{{ $t("hello", { world: $t("world") }) }}</div>
104
104
<i18n-t keypath="hello" tag="div">
@@ -685,3 +685,34 @@ test('issue #1083', async () => {
685
685
await nextTick ( )
686
686
expect ( dirEl ! . textContent ) . toEqual ( 'Hello World!' )
687
687
} )
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