11import { createEmitter } from '@intlify/shared'
2- import { getCurrentInstance } from 'vue'
32import { addTimelineEvent } from './devtools'
43import { createI18nError , I18nErrorCodes } from './errors'
54import { createVueI18n } from './legacy'
65import { SetPluralRulesSymbol } from './symbols'
7- import { adjustI18nResources , getLocaleMessages } from './utils'
6+ import {
7+ adjustI18nResources ,
8+ getCurrentInstance ,
9+ getLocaleMessages
10+ } from './utils'
811
912import type { Locale , LocaleMessageValue } from '@intlify/core'
1013import type { Path } from '@intlify/core-base'
@@ -118,11 +121,14 @@ export function defineMixin(
118121 if (
119122 ( __DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__ ) &&
120123 ! __NODE_JS__ &&
121- this . $el &&
122124 this . $i18n
123125 ) {
126+ const instance = getCurrentInstance ( )
127+ if ( ! instance ) {
128+ return
129+ }
124130 const _vueI18n = this . $i18n as unknown as VueI18nInternal
125- this . $el . __VUE_I18N__ = _vueI18n . __composer
131+ instance . __VUE_I18N__ = _vueI18n . __composer
126132 const emitter : VueDevToolsEmitter = ( this . __v_emitter =
127133 createEmitter < VueDevToolsEmitterEvents > ( ) )
128134 _vueI18n . __enableEmitter && _vueI18n . __enableEmitter ( emitter )
@@ -143,16 +149,15 @@ export function defineMixin(
143149 if (
144150 ( __DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__ ) &&
145151 ! __NODE_JS__ &&
146- this . $el &&
147- this . $el . __VUE_I18N__
152+ instance . __VUE_I18N__
148153 ) {
149154 if ( this . __v_emitter ) {
150155 this . __v_emitter . off ( '*' , addTimelineEvent )
151156 delete this . __v_emitter
152157 }
153158 if ( this . $i18n ) {
154159 _vueI18n . __disableEmitter && _vueI18n . __disableEmitter ( )
155- delete this . $el . __VUE_I18N__
160+ delete instance . __VUE_I18N__
156161 }
157162 }
158163
0 commit comments