Просмотр исходного кода

fix(vapor): special handling vapor props in vdom interop

daiwei 1 год назад
Родитель
Сommit
9477b9198b

+ 3 - 2
packages-private/vapor-e2e-test/interop/VaporComp.vue

@@ -27,7 +27,8 @@ const slotProp = ref('slot prop')
         change slot prop
       </button>
       <div class="vdom-slot-in-vapor-default">
-        #default: <slot :foo="slotProp" />
+        #default:
+        <slot :foo="slotProp" />
       </div>
       <div class="vdom-slot-in-vapor-test">
         #test: <slot name="test">fallback content</slot>
@@ -40,7 +41,7 @@ const slotProp = ref('slot prop')
     >
       Toggle default slot to vdom
     </button>
-    <VdomComp :msg="msg">
+    <VdomComp :msg="msg" class="foo">
       <template #default="{ foo }" v-if="passSlot">
         <div>slot prop: {{ foo }}</div>
         <div>component prop: {{ msg }}</div>

+ 6 - 1
packages/runtime-core/src/vnode.ts

@@ -666,7 +666,12 @@ export function guardReactiveProps(
   props: (Data & VNodeProps) | null,
 ): (Data & VNodeProps) | null {
   if (!props) return null
-  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props
+  return isProxy(props) ||
+    isInternalObject(props) ||
+    // handling for vapor props
+    props.__vapor
+    ? extend({}, props)
+    : props
 }
 
 export function cloneVNode<T, U>(

+ 1 - 0
packages/runtime-vapor/src/componentProps.ts

@@ -172,6 +172,7 @@ export function getPropsProxyHandlers(
 
 export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
   if (key === '$') return
+  if (key === '__vapor') return true
   // need special merging behavior for class & style
   const merged = key === 'class' || key === 'style' ? ([] as any[]) : undefined
   const dynamicSources = rawProps.$