Skip to content

Commit

Permalink
fix: Ensure that the order at desroy is the same as before change to …
Browse files Browse the repository at this point in the history
…from (#1278)
  • Loading branch information
kazupon committed Jun 19, 2021
1 parent 4219005 commit 4341afc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
isFunction,
looseClone,
remove,
arrayFrom,
includes,
merge,
numberFormatKeys,
Expand Down Expand Up @@ -250,11 +251,13 @@ export default class VueI18n {
watchI18nData (): Function {
const self = this
return this._vm.$watch('$data', () => {
self._dataListeners.forEach(e => {
const listeners = arrayFrom(this._dataListeners)
let i = listeners.length
while(i--) {
Vue.nextTick(() => {
e && e.$forceUpdate()
listeners[i] && listeners[i].$forceUpdate()
})
})
}
}, { deep: true })
}

Expand Down
6 changes: 6 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export function remove (arr: Set<any>, item: any): Set<any> | void {
}
}

export function arrayFrom (arr: Set<any>): Array<any> {
const ret = []
arr.forEach(a => ret.push(a))
return ret
}

export function includes (arr: Array<any>, item: any): boolean {
return !!~arr.indexOf(item)
}
Expand Down

0 comments on commit 4341afc

Please sign in to comment.