This repository has been archived by the owner on May 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from panter/features/wait
Features/wait
- Loading branch information
Showing
7 changed files
with
370 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable no-param-reassign, no-unused-vars */ | ||
|
||
import { warn } from './utils'; | ||
|
||
function assert(vnode) { | ||
const vm = vnode.context; | ||
|
||
if (!vm.$i18n) { | ||
warn('No VueI18Next instance found in the Vue instance'); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function waitForIt(el, vnode) { | ||
if (vnode.context.$i18n.i18next.isInitialized) { | ||
el.hidden = false; | ||
} else { | ||
el.hidden = true; | ||
const initialized = () => { | ||
vnode.context.$forceUpdate(); | ||
// due to emitter removing issue in i18next we need to delay remove | ||
setTimeout(() => { | ||
if (vnode.context && vnode.context.$i18n) { | ||
vnode.context.$i18n.i18next.off('initialized', initialized); | ||
} | ||
}, 1000); | ||
}; | ||
vnode.context.$i18n.i18next.on('initialized', initialized); | ||
} | ||
} | ||
|
||
export function bind(el, binding, vnode) { | ||
if (!assert(vnode)) { | ||
return; | ||
} | ||
|
||
waitForIt(el, vnode); | ||
} | ||
|
||
export function update(el, binding, vnode, oldVNode) { | ||
if (vnode.context.$i18n.i18next.isInitialized) { | ||
el.hidden = false; | ||
} | ||
} | ||
|
||
export default { | ||
bind, | ||
update, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.