Skip to content

Commit c2b0d90

Browse files
authored
fix: drop componentInstanceCreatedListener (#1495)
1 parent 3a0e5ab commit c2b0d90

File tree

12 files changed

+1
-80
lines changed

12 files changed

+1
-80
lines changed

docs/.ja/api/legacy.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,25 +1363,6 @@ The list of available locales in messages in lexical order.
13631363

13641364
`[]`
13651365

1366-
### componentInstanceCreatedListener
1367-
1368-
**Signature:**
1369-
```typescript
1370-
componentInstanceCreatedListener?: ComponentInstanceCreatedListener;
1371-
```
1372-
1373-
**Details**
1374-
1375-
A handler for getting notified when component-local instance was created.
1376-
1377-
The handler gets called with new and old (root) VueI18n instances.
1378-
1379-
This handler is useful when extending the root VueI18n instance and wanting to also apply those extensions to component-local instance.
1380-
1381-
**Default Value**
1382-
1383-
`null`
1384-
13851366
### datetimeFormats
13861367

13871368
**Signature:**

packages/petite-vue-i18n/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export {
7979
VueI18nDateTimeFormatting,
8080
VueI18nNumberFormatting,
8181
VueI18nResolveLocaleMessageTranslation,
82-
ComponentInstanceCreatedListener,
8382
VueI18nExtender
8483
} from '../../vue-i18n-core/src/legacy'
8584
export {

packages/petite-vue-i18n/src/runtime.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export {
7676
VueI18nDateTimeFormatting,
7777
VueI18nNumberFormatting,
7878
VueI18nResolveLocaleMessageTranslation,
79-
ComponentInstanceCreatedListener,
8079
VueI18nExtender
8180
} from '../../vue-i18n-core/src/legacy'
8281
export {

packages/vue-i18n-bridge/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export {
8989
VueI18nDateTimeFormatting,
9090
VueI18nNumberFormatting,
9191
VueI18nResolveLocaleMessageTranslation,
92-
ComponentInstanceCreatedListener,
9392
VueI18nExtender
9493
} from '../../vue-i18n-core/src/legacy'
9594
export {

packages/vue-i18n-bridge/src/runtime.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export {
8686
VueI18nDateTimeFormatting,
8787
VueI18nNumberFormatting,
8888
VueI18nResolveLocaleMessageTranslation,
89-
ComponentInstanceCreatedListener,
9089
VueI18nExtender
9190
} from '../../vue-i18n-core/src/legacy'
9291
export {

packages/vue-i18n-core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export {
6666
VueI18nDateTimeFormatting,
6767
VueI18nNumberFormatting,
6868
VueI18nResolveLocaleMessageTranslation,
69-
ComponentInstanceCreatedListener,
7069
VueI18nExtender
7170
} from './legacy'
7271
export {

packages/vue-i18n-core/src/legacy.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ export interface Formatter {
8080
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8181
interpolate(message: string, values: any, path: string): Array<any> | null
8282
}
83-
export type ComponentInstanceCreatedListener = <
84-
Messages extends Record<string, any>
85-
>(
86-
target: VueI18n<Messages>,
87-
global: VueI18n<Messages>
88-
) => void
89-
9083
export type VueI18nExtender = (vueI18n: VueI18n) => Disposer | undefined
9184

9285
/**
@@ -330,17 +323,6 @@ export interface VueI18nOptions<
330323
* @defaultValue `true`
331324
*/
332325
sync?: boolean
333-
/**
334-
* @remarks
335-
* A handler for getting notified when component-local instance was created.
336-
*
337-
* The handler gets called with new and old (root) VueI18n instances.
338-
*
339-
* This handler is useful when extending the root VueI18n instance and wanting to also apply those extensions to component-local instance.
340-
*
341-
* @defaultValue `null`
342-
*/
343-
componentInstanceCreatedListener?: ComponentInstanceCreatedListener
344326
/**
345327
* @remarks
346328
* A message resolver to resolve [`messages`](legacy#messages).
@@ -1314,9 +1296,6 @@ export interface VueI18nInternal<
13141296
NumberFormats extends Record<string, any> = {}
13151297
> {
13161298
__composer: Composer<Messages, DateTimeFormats, NumberFormats>
1317-
__onComponentInstanceCreated(
1318-
target: VueI18n<Messages, DateTimeFormats, NumberFormats>
1319-
): void
13201299
__enableEmitter?: (emitter: VueDevToolsEmitter) => void
13211300
__disableEmitter?: () => void
13221301
__extender?: VueI18nExtender
@@ -1796,14 +1775,6 @@ export function createVueI18n(options: any = {}, VueI18nLegacy?: any): any {
17961775
__DEV__ &&
17971776
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX))
17981777
return -1
1799-
},
1800-
1801-
// for internal
1802-
__onComponentInstanceCreated(target: VueI18n<{}>): void {
1803-
const { componentInstanceCreatedListener } = options
1804-
if (componentInstanceCreatedListener) {
1805-
componentInstanceCreatedListener(target, vueI18n)
1806-
}
18071778
}
18081779
}
18091780

packages/vue-i18n-core/src/mixins/next.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ export function defineMixin(
9898
adjustI18nResources(composer, options as ComposerOptions, options)
9999
}
100100

101-
// TODO: remove `__onComponentInstanceCreated`, because nuxt i18n v8 does not require it.
102-
;(vuei18n as unknown as VueI18nInternal).__onComponentInstanceCreated(
103-
this.$i18n
104-
)
105-
106101
// defines vue-i18n legacy APIs
107102
this.$t = (...args: unknown[]): TranslateResult => this.$i18n.t(...args)
108103
this.$rt = (...args: unknown[]): TranslateResult => this.$i18n.rt(...args)

packages/vue-i18n-core/test/i18n.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ describe('Composer & VueI18n extend hooking', () => {
14311431
})
14321432
return { foo }
14331433
},
1434-
template: '<p class="child">{{ foo }}</p><GrandChild >'
1434+
template: '<p class="child">{{ foo }}</p><GrandChild />'
14351435
})
14361436

14371437
const App = defineComponent({

packages/vue-i18n-core/test/mixin.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -222,25 +222,6 @@ test('$i18n', async () => {
222222
expect((vm.$i18n! as VueI18n).t('hello')).toEqual('hello!')
223223
})
224224

225-
test('VueI18n componentInstanceCreatedListener option', async () => {
226-
const componentInstanceCreatedListener = vi.fn()
227-
const i18n = createI18n({
228-
legacy: true,
229-
locale: 'en',
230-
componentInstanceCreatedListener
231-
})
232-
233-
const App = defineComponent({
234-
template: '<br/>',
235-
i18n: {
236-
locale: 'ja'
237-
}
238-
})
239-
await mount(App, i18n)
240-
241-
expect(componentInstanceCreatedListener).toHaveBeenCalled()
242-
})
243-
244225
test.skip('beforeDestroy', async () => {
245226
const i18n = createI18n({
246227
legacy: true,

0 commit comments

Comments
 (0)