-
-
Notifications
You must be signed in to change notification settings - Fork 379
feat: compatible Vue3 vapor mode for v11 #2320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,12 +10,14 @@ import { | |
| isString, | ||
| warn | ||
| } from '@intlify/shared' | ||
| import * as Vue from 'vue' | ||
| import { Text, createVNode } from 'vue' | ||
| import { I18nWarnCodes, getWarnMessage } from './warnings' | ||
|
Comment on lines
+13
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainCentralized Importing Also applies to: 19-23, 168-172, 222-228 🏁 Script executed: #!/bin/bash
# Check for any remaining direct `getCurrentInstance` imports/usages now that utils exposes a wrapper.
rg -n "getCurrentInstance" packages/vue-i18n-core -C3Length of output: 9739 Update The centralization goal is undermined: Change line 2 in mixins.ts: 🤖 Prompt for AI Agents |
||
|
|
||
| import type { Locale, MessageResolver } from '@intlify/core-base' | ||
| import type { | ||
| ComponentInternalInstance, | ||
| GenericComponentInstance, | ||
| RendererElement, | ||
| RendererNode | ||
| } from 'vue' | ||
|
|
@@ -163,7 +165,9 @@ export function getLocaleMessages<Messages = {}>( | |
| return ret as { [K in keyof Messages]: Messages[K] } | ||
| } | ||
|
|
||
| export function getComponentOptions(instance: ComponentInternalInstance): any { | ||
| export function getComponentOptions( | ||
| instance: ComponentInternalInstance | GenericComponentInstance | ||
| ): any { | ||
| return instance.type | ||
| } | ||
|
|
||
|
|
@@ -214,3 +218,11 @@ export function adjustI18nResources( | |
| export function createTextNode(key: string): any { | ||
| return createVNode(Text, null, key, 0) | ||
| } | ||
|
|
||
| export function getCurrentInstance(): | ||
| | GenericComponentInstance | ||
| | ComponentInternalInstance | ||
| | null { | ||
| // @ts-ignore -- NOTE(kazupon): for Vue 3.6 | ||
| return Vue.currentInstance || Vue.getCurrentInstance() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Devtools now bind to
instance.__VUE_I18N__, consistent with new lifecycle wiringReading the composer from
componentInstance.__VUE_I18N__(and tagging tree nodes only when it differs from the global composer) matches howsetupLifeCycleini18n.tsnow attaches/removes the composer on component instances, including generic ones. The widenedrootsandgetComponentInstancetypings toComponentInternalInstance | GenericComponentInstanceare in line with that model.Also applies to: 72-97, 115-118, 168-189, 321-327
🏁 Script executed:
Length of output: 7001
Critical inconsistency: devtools reads from component instance, but mixin still attaches to DOM element
The verification reveals a mismatch between binding locations:
i18n.ts(setupLifeCycle, composition API): attaches__VUE_I18N__to the component instance (target.__VUE_I18N__)devtools.ts: reads from the component instance (componentInstance.__VUE_I18N__)mixins.ts(options API): attaches__VUE_I18N__to the DOM element (this.$el.__VUE_I18N__)The devtools code will not discover composers attached via the mixin path, breaking devtools inspection for legacy/options-API components. Either
mixins.tsneeds to attach to the component instance instead of the DOM element, or devtools needs to fall back to checking the DOM element for legacy compatibility.🤖 Prompt for AI Agents