Skip to content

Commit 24e73e3

Browse files
authored
fix: avoid undefined read (#907)
* fix: avoid undefined read * fix: remove
1 parent 7ef4aaa commit 24e73e3

File tree

1 file changed

+37
-38
lines changed
  • packages/vue-i18n-core/src/mixins

1 file changed

+37
-38
lines changed

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

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCurrentInstance, nextTick } from 'vue'
1+
import { getCurrentInstance } from 'vue'
22
import { createVueI18n } from '../legacy'
33
import { createI18nError, I18nErrorCodes } from '../errors'
44
import { SetPluralRulesSymbol } from '../symbols'
@@ -100,21 +100,20 @@ export function defineMixin(
100100
},
101101

102102
mounted(): void {
103-
nextTick(() => {
104-
/* istanbul ignore if */
105-
if (
106-
(__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) &&
107-
!__NODE_JS__ &&
108-
this.$el
109-
) {
110-
this.$el.__VUE_I18N__ = this.$i18n.__composer
111-
const emitter: VueDevToolsEmitter = (this.__v_emitter =
112-
createEmitter<VueDevToolsEmitterEvents>())
113-
const _vueI18n = this.$i18n as unknown as VueI18nInternal
114-
_vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter)
115-
emitter.on('*', addTimelineEvent)
116-
}
117-
})
103+
/* istanbul ignore if */
104+
if (
105+
(__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) &&
106+
!__NODE_JS__ &&
107+
this.$el &&
108+
this.$i18n
109+
) {
110+
this.$el.__VUE_I18N__ = this.$i18n.__composer
111+
const emitter: VueDevToolsEmitter = (this.__v_emitter =
112+
createEmitter<VueDevToolsEmitterEvents>())
113+
const _vueI18n = this.$i18n as unknown as VueI18nInternal
114+
_vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter)
115+
emitter.on('*', addTimelineEvent)
116+
}
118117
},
119118

120119
unmounted(): void {
@@ -124,34 +123,34 @@ export function defineMixin(
124123
throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR)
125124
}
126125

127-
nextTick(() => {
128-
/* istanbul ignore if */
129-
if (
130-
(__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) &&
131-
!__NODE_JS__ &&
132-
this.$el &&
133-
this.$el.__VUE_I18N__
134-
) {
135-
if (this.__v_emitter) {
136-
this.__v_emitter.off('*', addTimelineEvent)
137-
delete this.__v_emitter
138-
}
126+
/* istanbul ignore if */
127+
if (
128+
(__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) &&
129+
!__NODE_JS__ &&
130+
this.$el &&
131+
this.$el.__VUE_I18N__
132+
) {
133+
if (this.__v_emitter) {
134+
this.__v_emitter.off('*', addTimelineEvent)
135+
delete this.__v_emitter
136+
}
137+
if (this.$i18n) {
139138
const _vueI18n = this.$i18n as unknown as VueI18nInternal
140139
_vueI18n.__disableEmitter && _vueI18n.__disableEmitter()
141140
delete this.$el.__VUE_I18N__
142141
}
142+
}
143143

144-
delete this.$t
145-
delete this.$rt
146-
delete this.$tc
147-
delete this.$te
148-
delete this.$d
149-
delete this.$n
150-
delete this.$tm
144+
delete this.$t
145+
delete this.$rt
146+
delete this.$tc
147+
delete this.$te
148+
delete this.$d
149+
delete this.$n
150+
delete this.$tm
151151

152-
i18n.__deleteInstance(instance)
153-
delete this.$i18n
154-
})
152+
i18n.__deleteInstance(instance)
153+
delete this.$i18n
155154
}
156155
}
157156
}

0 commit comments

Comments
 (0)