Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/runtime-core/src/apiCreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ export interface VaporInteropInterface {
transition: TransitionHooks,
): void

vdomMount: (component: ConcreteComponent, props?: any, slots?: any) => any
vdomMount: (
component: ConcreteComponent,
parentComponent: any,
props?: any,
slots?: any,
) => any
vdomUnmount: UnmountComponentFn
vdomSlot: (
slots: any,
Expand Down
29 changes: 29 additions & 0 deletions packages/runtime-vapor/__tests__/apiInject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import {
} from '@vue/runtime-dom'
import {
createComponent,
createSlot,
createTextNode,
createVaporApp,
defineVaporComponent,
renderEffect,
withVaporCtx,
} from '../src'
import { makeRender } from './_utils'
import { setElementText } from '../src/dom/prop'
Expand Down Expand Up @@ -368,6 +371,32 @@ describe('api: provide/inject', () => {
expect(host.innerHTML).toBe('')
})

it('should work with slots', () => {
const Parent = defineVaporComponent({
setup() {
provide('test', 'hello')
return createSlot('default', null)
},
})

const Child = defineVaporComponent({
setup() {
const test = inject('test')
return createTextNode(toDisplayString(test))
},
})

const { host } = define({
setup() {
return createComponent(Parent, null, {
default: withVaporCtx(() => createComponent(Child)),
})
},
}).render()

expect(host.innerHTML).toBe('hello<!--slot-->')
})

describe('hasInjectionContext', () => {
it('should be false outside of setup', () => {
expect(hasInjectionContext()).toBe(false)
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime-vapor/__tests__/apiSetupContext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
setDynamicProps,
setText,
template,
withVaporCtx,
} from '../src'
import { nextTick, reactive, ref, watchEffect } from '@vue/runtime-dom'
import { makeRender } from './_utils'
Expand Down Expand Up @@ -113,11 +114,11 @@ describe('api: setup context', () => {
inheritAttrs: false,
setup(_: any, { attrs }: any) {
const n0 = createComponent(Wrapper, null, {
default: () => {
default: withVaporCtx(() => {
const n0 = template('<div>')() as HTMLDivElement
renderEffect(() => setDynamicProps(n0, [attrs]))
return n0
},
}),
})
return n0
},
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime-vapor/__tests__/componentAttrs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
setProp,
setStyle,
template,
withVaporCtx,
} from '../src'
import { makeRender } from './_utils'
import { stringifyStyle } from '@vue/shared'
Expand Down Expand Up @@ -286,10 +287,10 @@ describe('attribute fallthrough', () => {
() => 'button',
null,
{
default: () => {
default: withVaporCtx(() => {
const n0 = createSlot('default', null)
return n0
},
}),
},
true,
)
Expand Down
Loading
Loading