Skip to content

Commit 1761831

Browse files
authored
fix: scope execution context resolving (#1108)
* fix: scope execution context resolving related: #1096 #1107 * fix more another codes related #909
1 parent 3661d7b commit 1761831

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

examples/ssr/vite/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function createServer(
8686
}
8787

8888
if (!isTest) {
89-
createServer().then(({ app }) =>
89+
createServer().then(({ app, vite }) =>
9090
app.listen(3000, () => {
9191
console.log('http://localhost:3000')
9292
})

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
19141914
// eslint-disable-next-line prefer-const
19151915
let _context: CoreContext
19161916

1917-
function getCoreContext(): CoreContext {
1917+
const getCoreContext = (): CoreContext => {
19181918
_isGlobal && setFallbackContext(null)
19191919

19201920
const ctxOptions = {
@@ -2052,14 +2052,14 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
20522052
return type !== 'translate' || !arg.resolvedMessage
20532053
}
20542054

2055-
function wrapWithDeps<T, U = T>(
2055+
const wrapWithDeps = <T, U = T>(
20562056
fn: (context: unknown) => unknown,
20572057
argumentParser: () => unknown[],
20582058
warnType: ComposerWarnType,
20592059
fallbackSuccess: (root: Composer<T> & ComposerInternal) => U,
20602060
fallbackFail: (key: unknown) => U,
20612061
successCondition: (val: unknown) => boolean
2062-
): U {
2062+
): U => {
20632063
trackReactivityValues() // track reactive dependency
20642064
// NOTE: experimental !!
20652065
let ret: unknown

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function getComposer(
8888
export type TranslationDirective<T = HTMLElement> = ObjectDirective<T>
8989

9090
export function vTDirective(i18n: I18n): TranslationDirective<HTMLElement> {
91-
function process(binding: DirectiveBinding): [string, Composer] {
91+
const process = (binding: DirectiveBinding): [string, Composer] => {
9292
const { instance, modifiers, value } = binding
9393
/* istanbul ignore if */
9494
if (!instance || !instance.$) {
@@ -140,15 +140,16 @@ export function vTDirective(i18n: I18n): TranslationDirective<HTMLElement> {
140140
])
141141
}
142142
}
143+
const getSSRProps = (binding: DirectiveBinding) => {
144+
const [textContent] = process(binding)
145+
return { textContent }
146+
}
143147

144148
return {
145149
created: register,
146150
unmounted: unregister,
147151
beforeUpdate: update,
148-
getSSRProps: (binding: DirectiveBinding) => {
149-
const [textContent] = process(binding)
150-
return { textContent }
151-
}
152+
getSSRProps
152153
} as TranslationDirective<HTMLElement>
153154
}
154155

0 commit comments

Comments
 (0)