mirror of https://github.com/vuejs/core.git
wip: save
This commit is contained in:
parent
b92ea0a38a
commit
e3f8ba4bf5
|
@ -7,7 +7,6 @@ import {
|
||||||
assertNumber,
|
assertNumber,
|
||||||
compatUtils,
|
compatUtils,
|
||||||
h,
|
h,
|
||||||
isVNode,
|
|
||||||
} from '@vue/runtime-core'
|
} from '@vue/runtime-core'
|
||||||
import { extend, isArray, isObject, toNumber } from '@vue/shared'
|
import { extend, isArray, isObject, toNumber } from '@vue/shared'
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ export interface VaporTransitionInterface {
|
||||||
applyTransition: (
|
applyTransition: (
|
||||||
props: TransitionProps,
|
props: TransitionProps,
|
||||||
slots: { default: () => any },
|
slots: { default: () => any },
|
||||||
) => void
|
) => any
|
||||||
}
|
}
|
||||||
|
|
||||||
let vaporTransitionImpl: VaporTransitionInterface | null = null
|
let vaporTransitionImpl: VaporTransitionInterface | null = null
|
||||||
|
@ -101,19 +100,13 @@ const decorate = (t: typeof Transition) => {
|
||||||
*/
|
*/
|
||||||
export const Transition: FunctionalComponent<TransitionProps> =
|
export const Transition: FunctionalComponent<TransitionProps> =
|
||||||
/*@__PURE__*/ decorate((props, { slots }) => {
|
/*@__PURE__*/ decorate((props, { slots }) => {
|
||||||
const children = slots.default && slots.default()
|
|
||||||
const isVNodeChildren = isArray(children) && children.some(c => isVNode(c))
|
|
||||||
const resolvedProps = resolveTransitionProps(props)
|
const resolvedProps = resolveTransitionProps(props)
|
||||||
if (isVNodeChildren) {
|
if (slots._vapor) {
|
||||||
return h(BaseTransition, resolvedProps, {
|
// vapor transition
|
||||||
default: () => children,
|
return vaporTransitionImpl!.applyTransition(resolvedProps, slots as any)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vapor transition
|
return h(BaseTransition, resolvedProps, slots)
|
||||||
return vaporTransitionImpl!.applyTransition(resolvedProps, {
|
|
||||||
default: () => children,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,6 +56,7 @@ import {
|
||||||
type VaporSlot,
|
type VaporSlot,
|
||||||
dynamicSlotsProxyHandlers,
|
dynamicSlotsProxyHandlers,
|
||||||
getSlot,
|
getSlot,
|
||||||
|
vaporSlotsProxyHandler,
|
||||||
} from './componentSlots'
|
} from './componentSlots'
|
||||||
import { hmrReload, hmrRerender } from './hmr'
|
import { hmrReload, hmrRerender } from './hmr'
|
||||||
|
|
||||||
|
@ -416,7 +417,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
|
||||||
this.slots = rawSlots
|
this.slots = rawSlots
|
||||||
? rawSlots.$
|
? rawSlots.$
|
||||||
? new Proxy(rawSlots, dynamicSlotsProxyHandlers)
|
? new Proxy(rawSlots, dynamicSlotsProxyHandlers)
|
||||||
: rawSlots
|
: new Proxy(rawSlots, vaporSlotsProxyHandler)
|
||||||
: EMPTY_OBJ
|
: EMPTY_OBJ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,24 @@ export type DynamicSlot = { name: string; fn: VaporSlot }
|
||||||
export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
|
export type DynamicSlotFn = () => DynamicSlot | DynamicSlot[]
|
||||||
export type DynamicSlotSource = StaticSlots | DynamicSlotFn
|
export type DynamicSlotSource = StaticSlots | DynamicSlotFn
|
||||||
|
|
||||||
|
export const vaporSlotsProxyHandler: ProxyHandler<any> = {
|
||||||
|
get(target, key) {
|
||||||
|
if (key === '_vapor') {
|
||||||
|
return target
|
||||||
|
} else {
|
||||||
|
return target[key]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export const dynamicSlotsProxyHandlers: ProxyHandler<RawSlots> = {
|
export const dynamicSlotsProxyHandlers: ProxyHandler<RawSlots> = {
|
||||||
get: getSlot,
|
get: (target, key: string) => {
|
||||||
|
if (key === '_vapor') {
|
||||||
|
return target
|
||||||
|
} else {
|
||||||
|
return getSlot(target, key)
|
||||||
|
}
|
||||||
|
},
|
||||||
has: (target, key: string) => !!getSlot(target, key),
|
has: (target, key: string) => !!getSlot(target, key),
|
||||||
getOwnPropertyDescriptor(target, key: string) {
|
getOwnPropertyDescriptor(target, key: string) {
|
||||||
const slot = getSlot(target, key)
|
const slot = getSlot(target, key)
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const vaporTransitionImpl: VaporTransitionInterface = {
|
||||||
applyTransition: (
|
applyTransition: (
|
||||||
props: TransitionProps,
|
props: TransitionProps,
|
||||||
slots: { default: () => Block },
|
slots: { default: () => Block },
|
||||||
) => {
|
): Block | undefined => {
|
||||||
const children = slots.default && slots.default()
|
const children = slots.default && slots.default()
|
||||||
if (!children) return
|
if (!children) return
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,11 @@ import {
|
||||||
import { type Block, VaporFragment, insert, remove } from './block'
|
import { type Block, VaporFragment, insert, remove } from './block'
|
||||||
import { EMPTY_OBJ, extend, isFunction } from '@vue/shared'
|
import { EMPTY_OBJ, extend, isFunction } from '@vue/shared'
|
||||||
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
|
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
|
||||||
import type { RawSlots, VaporSlot } from './componentSlots'
|
import {
|
||||||
|
type RawSlots,
|
||||||
|
type VaporSlot,
|
||||||
|
vaporSlotsProxyHandler,
|
||||||
|
} from './componentSlots'
|
||||||
import { renderEffect } from './renderEffect'
|
import { renderEffect } from './renderEffect'
|
||||||
import { createTextNode } from './dom/node'
|
import { createTextNode } from './dom/node'
|
||||||
import { optimizePropertyLookup } from './dom/prop'
|
import { optimizePropertyLookup } from './dom/prop'
|
||||||
|
@ -129,16 +133,6 @@ const vaporSlotPropsProxyHandler: ProxyHandler<
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const vaporSlotsProxyHandler: ProxyHandler<any> = {
|
|
||||||
get(target, key) {
|
|
||||||
if (key === '_vapor') {
|
|
||||||
return target
|
|
||||||
} else {
|
|
||||||
return target[key]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mount vdom component in vapor
|
* Mount vdom component in vapor
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue