]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(vapor): ensure props are shallow reactive to prevent DEV warnings
authordaiwei <daiwei521@126.com>
Mon, 26 May 2025 08:31:02 +0000 (16:31 +0800)
committerdaiwei <daiwei521@126.com>
Mon, 26 May 2025 08:31:02 +0000 (16:31 +0800)
packages/runtime-vapor/src/vdomInterop.ts

index 77228fd72a02fe85a5496daf7d89bc37e197a4d2..a824fb08712b0606fa32cf1940a150f84aaf820e 100644 (file)
@@ -14,6 +14,7 @@ import {
   ensureRenderer,
   onScopeDispose,
   renderSlot,
+  shallowReactive,
   shallowRef,
   simpleSetCurrentInstance,
 } from '@vue/runtime-dom'
@@ -161,7 +162,15 @@ function createVDOMComponent(
 
   // overwrite how the vdom instance handles props
   vnode.vi = (instance: ComponentInternalInstance) => {
-    instance.props = wrapper.props
+    // Ensure props are shallow reactive to align with VDOM behavior.
+    // This enables direct watching of props and prevents DEV warnings.
+    //
+    // Example:
+    // const props = defineProps(...)
+    // watch(props, () => { ... }) // props must be reactive for this to work
+    //
+    // Without reactivity, Vue will warn in DEV about non-reactive watch sources
+    instance.props = shallowReactive(wrapper.props)
     instance.attrs = wrapper.attrs
     instance.slots =
       wrapper.slots === EMPTY_OBJ