Skip to content

Commit 4d05dfd

Browse files
committed
chore: update tests
1 parent a359aff commit 4d05dfd

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

packages/runtime-vapor/__tests__/vdomInterop.spec.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, h, renderSlot } from '@vue/runtime-dom'
1+
import { createVNode, defineComponent, h, renderSlot } from '@vue/runtime-dom'
22
import { makeInteropRender } from './_utils'
33
import { createComponent, defineVaporComponent } from '../src'
44

@@ -10,7 +10,7 @@ describe('vdomInterop', () => {
1010
describe.todo('emit', () => {})
1111

1212
describe('slots', () => {
13-
test('functional slot', () => {
13+
test('basic', () => {
1414
const VDomChild = defineComponent({
1515
setup(_, { slots }) {
1616
return () => renderSlot(slots, 'default')
@@ -38,6 +38,36 @@ describe('vdomInterop', () => {
3838

3939
expect(html()).toBe('default slot')
4040
})
41+
42+
test('functional slot', () => {
43+
const VDomChild = defineComponent({
44+
setup(_, { slots }) {
45+
console.log(slots.default)
46+
return () => createVNode(slots.default!)
47+
},
48+
})
49+
50+
const VaporChild = defineVaporComponent({
51+
setup() {
52+
return createComponent(
53+
VDomChild as any,
54+
null,
55+
{
56+
default: () => document.createTextNode('default slot'),
57+
},
58+
true,
59+
)
60+
},
61+
})
62+
63+
const { html } = define({
64+
setup() {
65+
return () => h(VaporChild as any)
66+
},
67+
}).render()
68+
69+
expect(html()).toBe('default slot')
70+
})
4171
})
4272

4373
describe.todo('provide', () => {})

packages/runtime-vapor/src/componentProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
186186
source = dynamicSources[i]
187187
isDynamic = isFunction(source)
188188
source = isDynamic ? (source as Function)() : source
189-
if (hasOwn(source, key)) {
189+
if (source && hasOwn(source, key)) {
190190
const value = isDynamic ? source[key] : source[key]()
191191
if (merged) {
192192
merged.push(value)

0 commit comments

Comments
 (0)