Skip to content

Commit e3f8ba4

Browse files
committed
wip: save
1 parent b92ea0a commit e3f8ba4

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

packages/runtime-dom/src/components/Transition.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
assertNumber,
88
compatUtils,
99
h,
10-
isVNode,
1110
} from '@vue/runtime-core'
1211
import { extend, isArray, isObject, toNumber } from '@vue/shared'
1312

@@ -37,7 +36,7 @@ export interface VaporTransitionInterface {
3736
applyTransition: (
3837
props: TransitionProps,
3938
slots: { default: () => any },
40-
) => void
39+
) => any
4140
}
4241

4342
let vaporTransitionImpl: VaporTransitionInterface | null = null
@@ -101,19 +100,13 @@ const decorate = (t: typeof Transition) => {
101100
*/
102101
export const Transition: FunctionalComponent<TransitionProps> =
103102
/*@__PURE__*/ decorate((props, { slots }) => {
104-
const children = slots.default && slots.default()
105-
const isVNodeChildren = isArray(children) && children.some(c => isVNode(c))
106103
const resolvedProps = resolveTransitionProps(props)
107-
if (isVNodeChildren) {
108-
return h(BaseTransition, resolvedProps, {
109-
default: () => children,
110-
})
104+
if (slots._vapor) {
105+
// vapor transition
106+
return vaporTransitionImpl!.applyTransition(resolvedProps, slots as any)
111107
}
112108

113-
// vapor transition
114-
return vaporTransitionImpl!.applyTransition(resolvedProps, {
115-
default: () => children,
116-
})
109+
return h(BaseTransition, resolvedProps, slots)
117110
})
118111

119112
/**

packages/runtime-vapor/src/component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
type VaporSlot,
5757
dynamicSlotsProxyHandlers,
5858
getSlot,
59+
vaporSlotsProxyHandler,
5960
} from './componentSlots'
6061
import { hmrReload, hmrRerender } from './hmr'
6162

@@ -416,7 +417,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
416417
this.slots = rawSlots
417418
? rawSlots.$
418419
? new Proxy(rawSlots, dynamicSlotsProxyHandlers)
419-
: rawSlots
420+
: new Proxy(rawSlots, vaporSlotsProxyHandler)
420421
: EMPTY_OBJ
421422
}
422423

packages/runtime-vapor/src/componentSlots.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,24 @@ export type DynamicSlot = { name: string; fn: VaporSlot }
1616
export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
1717
export type DynamicSlotSource = StaticSlots | DynamicSlotFn
1818

19+
export const vaporSlotsProxyHandler: ProxyHandler<any> = {
20+
get(target, key) {
21+
if (key === '_vapor') {
22+
return target
23+
} else {
24+
return target[key]
25+
}
26+
},
27+
}
28+
1929
export const dynamicSlotsProxyHandlers: ProxyHandler<RawSlots> = {
20-
get: getSlot,
30+
get: (target, key: string) => {
31+
if (key === '_vapor') {
32+
return target
33+
} else {
34+
return getSlot(target, key)
35+
}
36+
},
2137
has: (target, key: string) => !!getSlot(target, key),
2238
getOwnPropertyDescriptor(target, key: string) {
2339
const slot = getSlot(target, key)

packages/runtime-vapor/src/components/Transition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const vaporTransitionImpl: VaporTransitionInterface = {
2626
applyTransition: (
2727
props: TransitionProps,
2828
slots: { default: () => Block },
29-
) => {
29+
): Block | undefined => {
3030
const children = slots.default && slots.default()
3131
if (!children) return
3232

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import {
2929
import { type Block, VaporFragment, insert, remove } from './block'
3030
import { EMPTY_OBJ, extend, isFunction } from '@vue/shared'
3131
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
32-
import type { RawSlots, VaporSlot } from './componentSlots'
32+
import {
33+
type RawSlots,
34+
type VaporSlot,
35+
vaporSlotsProxyHandler,
36+
} from './componentSlots'
3337
import { renderEffect } from './renderEffect'
3438
import { createTextNode } from './dom/node'
3539
import { optimizePropertyLookup } from './dom/prop'
@@ -129,16 +133,6 @@ const vaporSlotPropsProxyHandler: ProxyHandler<
129133
},
130134
}
131135

132-
const vaporSlotsProxyHandler: ProxyHandler<any> = {
133-
get(target, key) {
134-
if (key === '_vapor') {
135-
return target
136-
} else {
137-
return target[key]
138-
}
139-
},
140-
}
141-
142136
/**
143137
* Mount vdom component in vapor
144138
*/

0 commit comments

Comments
 (0)