Selaa lähdekoodia

fix(runtime-vapor): avoid retaining vdom interop from emits

daiwei 1 kuukausi sitten
vanhempi
commit
50d4d63a12

+ 2 - 2
packages/runtime-vapor/src/componentEmits.ts

@@ -2,7 +2,7 @@ import { type ObjectEmitsOptions, baseEmit } from '@vue/runtime-dom'
 import type { VaporComponent, VaporComponentInstance } from './component'
 import { EMPTY_OBJ, hasOwn, isArray, isFunction, isOn } from '@vue/shared'
 import { type RawProps, resolveSource } from './componentProps'
-import { interopKey } from './vdomInterop'
+import { interopKey, isInteropEnabled } from './vdomInteropState'
 
 /**
  * The logic from core isn't too reusable so it's better to duplicate here
@@ -49,7 +49,7 @@ function propGetter(rawProps: RawProps, key: string) {
       const source = resolveSource(dynamicSources[i])
       if (hasOwn(source, key))
         // for props passed from VDOM component, no need to resolve
-        return dynamicSources[interopKey] ||
+        return (isInteropEnabled && dynamicSources[interopKey]) ||
           (isOn(key) && isFunction(dynamicSources[i]))
           ? source[key]
           : resolveSource(source[key])

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

@@ -30,7 +30,7 @@ import {
 import { normalizeEmitsOptions } from './componentEmits'
 import { renderEffect } from './renderEffect'
 import { pauseTracking, resetTracking } from '@vue/reactivity'
-import type { interopKey } from './vdomInterop'
+import type { interopKey } from './vdomInteropState'
 
 export type RawProps = Record<string, () => unknown> & {
   // generated by compiler for :[key]="x" or v-bind="x"

+ 1 - 2
packages/runtime-vapor/src/vdomInterop.ts

@@ -127,6 +127,7 @@ import {
   setTransitionHooks as setVaporTransitionHooks,
 } from './components/Transition'
 import {
+  interopKey,
   isCollectingVdomSlotVNodes,
   setInteropEnabled,
   withVdomSlotVNodeCollection,
@@ -149,8 +150,6 @@ import {
   setParentSuspense,
 } from './suspense'
 
-export const interopKey: unique symbol = Symbol(`interop`)
-
 function filterReservedProps(props: VNode['props']): VNode['props'] {
   const filtered: VNode['props'] = {}
   for (const key in props) {

+ 2 - 0
packages/runtime-vapor/src/vdomInteropState.ts

@@ -6,6 +6,8 @@ export function setInteropEnabled(): void {
   isInteropEnabled = true
 }
 
+export const interopKey: unique symbol = Symbol(`interop`)
+
 // Active while probing a Vapor slot for VDOM child metadata. This dry pass must
 // not mount or hydrate the real slot output.
 export let isCollectingVdomSlotVNodes = false