Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 20 additions & 1 deletion packages/runtime-vapor/__tests__/vdomInterop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@ import { createComponent, defineVaporComponent } from '../src'
const define = makeInteropRender()

describe('vdomInterop', () => {
describe.todo('props', () => {})
describe('props', () => {
test('prevent hasOwnProperty error when props is null', () => {
const VaporChild = defineVaporComponent({
props: {
msg: String,
},
setup(_, { attrs }) {
return [document.createTextNode(attrs.class || 'foo')]
},
})

const { html } = define({
setup() {
return () => h(VaporChild as any)
},
}).render()

expect(html()).toBe('foo')
})
})

describe.todo('emit', () => {})

Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-vapor/src/componentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
source = dynamicSources[i]
isDynamic = isFunction(source)
source = isDynamic ? (source as Function)() : source
if (hasOwn(source, key)) {
if (source && hasOwn(source, key)) {
const value = isDynamic ? source[key] : source[key]()
if (merged) {
merged.push(value)
Expand Down