fix(runtime-vapor): properly set ref on dynamic component + vdom component#14496
fix(runtime-vapor): properly set ref on dynamic component + vdom component#14496edison1105 merged 2 commits intovuejs:minorfrom
Conversation
…ain ref to vdom components
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/runtime-vapor/__tests__/vdomInterop.spec.ts (1)
738-769: Consider scopingvdomRefinside the test for better isolation.The test correctly validates the fix, but
vdomRefis declared outsideVaporChild(line 758) and referenced inside the component'srenderfunction (lines 748, 753). While this works, movingvdomRefdeclaration inside the test block beforeVaporChilddefinition would improve clarity about the data flow and prevent potential issues if tests are run in parallel or if another test accidentally references this variable.♻️ Suggested refactor for better scoping
it('dynamic component includes vdom component', async () => { + const vdomRef = ref<any>(null) + const VdomChild = defineComponent({ setup(_, { expose }) { expose({ name: 'vdomChild' }) return () => h('div', 'vdom child') }, }) const VaporChild = defineVaporComponent({ setup() { return { vdomRef } }, render() { const setRef = createTemplateRefSetter() const n0 = createDynamicComponent(() => VdomChild) setRef(n0, vdomRef, false, 'vdomRef') return n0 }, }) - const vdomRef = ref<any>(null) - define({🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/runtime-vapor/__tests__/vdomInterop.spec.ts` around lines 738 - 769, The vdomRef used by VaporChild and its render (symbols: vdomRef, VaporChild, VdomChild) is declared after VaporChild which reduces test isolation; move the const vdomRef = ref<any>(null) declaration to the top of this test block immediately before defining VaporChild (and ensure VaporChild’s render and any setRef calls still reference that local vdomRef) so the ref is scoped to the test and not shared across tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/runtime-vapor/__tests__/vdomInterop.spec.ts`:
- Around line 738-769: The vdomRef used by VaporChild and its render (symbols:
vdomRef, VaporChild, VdomChild) is declared after VaporChild which reduces test
isolation; move the const vdomRef = ref<any>(null) declaration to the top of
this test block immediately before defining VaporChild (and ensure VaporChild’s
render and any setRef calls still reference that local vdomRef) so the ref is
scoped to the test and not shared across tests.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/runtime-vapor/__tests__/vdomInterop.spec.tspackages/runtime-vapor/src/apiTemplateRef.ts
Problem Description
In vapor mode, dynamic components cannot obtain references to vdom components
Version
v3.6.0-beta.7
Link to minimal reproduction
Playground
What is expected?
Console prints
"comp"What is actually happening?
Console prints
"undefined"Summary by CodeRabbit
New Features
Tests
Refactor