-
-
Notifications
You must be signed in to change notification settings - Fork 9k
fix(compat): handle v-model deprecation warning with missing appContext #14203
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
base: main
Are you sure you want to change the base?
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughFixes a crash in compat component v-model warning by supplying an appContext in the deprecation warning payload; adds a test exercising v-model emissions when appContext is missing. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
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.
Pull request overview
This PR fixes a crash in the v-model deprecation warning system when appContext is not available. The issue occurred when the warning system tried to format component names but couldn't access the appContext.components registry, resulting in a null pointer error.
Key Changes
- Passes
appContextto the deprecation warning function with a fallback to an empty context - Adds a test case to verify the fix prevents crashes when
appContextis missing
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/runtime-core/src/compat/componentVModel.ts |
Imports createAppContext and passes appContext (from vnode.ctx or creates a new one) to warnDeprecation to prevent null pointer errors when formatting component names |
packages/vue-compat/__tests__/componentVModel.spec.ts |
Adds a regression test that verifies v-model functionality works correctly and doesn't crash when triggering the deprecation warning |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/runtime-core/src/compat/componentVModel.ts (1)
3-42: Prefer real vnode appContext before falling back tocreateAppContextThe new pseudo‑instance with an
appContextfixes the crash by guaranteeinginstance.appContextexists, which is good. However, whenvnode.ctxis missing you fall back directly tocreateAppContext(), which creates a fresh, empty context and ignores the real app’s configuration (global config, isNativeTag, etc.) that deprecation handling might rely on.Given that VNodes already carry their app context, consider sourcing it in this order instead:
appContext: vnode.appContext || (vnode.ctx && vnode.ctx.appContext) || createAppContext()This preserves the actual app context when available while still preventing the crash when it truly isn’t.
If you confirm that
vnode.appContextis always set in this compat path, you could even drop thecreateAppContext()fallback entirely and tighten the type accordingly.packages/vue-compat/__tests__/componentVModel.spec.ts (1)
144-179: Good regression coverage; consider slightly clarifying the clicked elementThis test nicely captures the #14202 scenario: it drives the compat
v-modelpath, asserts the deprecation warning, and verifies that the app continues to work and update state/DOM instead of crashing.One small readability tweak you might consider: the element selection
const child = vm.$el.querySelector('div') child.click()relies on
querySelectorreturning the inner child<div>rather than the root container. To make the intent more explicit, you could narrow the selector (e.g.'div > div') or add a brief comment that this is the child component’s root node. Not required, just a clarity improvement.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/runtime-core/src/compat/componentVModel.ts(2 hunks)packages/vue-compat/__tests__/componentVModel.spec.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/vue-compat/__tests__/componentVModel.spec.ts (1)
packages/runtime-core/src/index.ts (1)
DeprecationTypes(479-481)
packages/runtime-core/src/compat/componentVModel.ts (2)
packages/runtime-core/src/index.ts (1)
DeprecationTypes(479-481)packages/runtime-core/src/apiCreateApp.ts (1)
createAppContext(224-244)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Agent
close #14202
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.