Skip to content

Commit 180babb

Browse files
authored
fix(lang): provide lang at app level so that it's available in stores (#586)
1 parent 3db162f commit 180babb

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

lib/composables/Lang.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { inject, provide } from 'vue'
1+
import { type InjectionKey, getCurrentInstance, inject } from 'vue'
22

33
export type Lang = 'en' | 'ja'
44

@@ -15,7 +15,7 @@ export interface HasLang {
1515
lang: Lang
1616
}
1717

18-
export const SefirotLangKey = 'sefirot-lang-key'
18+
export const SefirotLangKey: InjectionKey<Lang> = Symbol.for('sefirot-lang-key')
1919

2020
export function useSetupLang(): (user?: HasLang | null) => void {
2121
const browserLang = useBrowserLang()
@@ -26,7 +26,7 @@ export function useSetupLang(): (user?: HasLang | null) => void {
2626
}
2727

2828
export function provideLang(lang: Lang) {
29-
provide(SefirotLangKey, lang)
29+
getCurrentInstance()?.appContext.app.provide(SefirotLangKey, lang)
3030
}
3131

3232
export function useLang(): Lang {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"dayjs": "^1.11.13",
100100
"eslint": "8.57.0",
101101
"fuse.js": "^7.1.0",
102-
"happy-dom": "^14.12.3",
102+
"happy-dom": "^17.1.8",
103103
"histoire": "0.16.5",
104104
"lodash-es": "^4.17.21",
105105
"markdown-it": "^14.1.0",

pnpm-lock.yaml

+13-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/components/SInputSelect.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ describe('components/SInputSelect', async () => {
7070
})
7171

7272
const selectElement = wrapper.find('select').element
73-
expect(selectElement.options[selectElement.selectedIndex].text).toBe('Placeholder')
73+
expect(selectElement.selectedOptions[0].text).toBe('Placeholder')
7474
})
7575
})

0 commit comments

Comments
 (0)