Skip to content

fix(runtime-vapor): handle vapor attrs fallthrough to vdom component #13551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: minor
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions packages/runtime-vapor/__tests__/vdomInterop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ describe('vdomInterop', () => {
describe.todo('dynamic component', () => {})

describe('attribute fallthrough', () => {
it('should fallthrough attrs to vdom child', () => {
const VDomChild = defineComponent({
setup() {
return () => h('div')
},
})

const VaporChild = defineVaporComponent({
setup() {
return createComponent(
VDomChild as any,
{ foo: () => 'vapor foo' },
null,
true,
)
},
})

const { html } = define({
setup() {
return () => h(VaporChild as any, { foo: 'foo', bar: 'bar' })
},
}).render()
expect(html()).toBe('<div foo="foo" bar="bar"></div>')
})

it('should not fallthrough emit handlers to vdom child', () => {
const VDomChild = defineComponent({
emits: ['click'],
Expand Down
26 changes: 13 additions & 13 deletions packages/runtime-vapor/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,6 @@ export function createComponent(
resetInsertionState()
}

// vdom interop enabled and component is not an explicit vapor component
if (appContext.vapor && !component.__vapor) {
const frag = appContext.vapor.vdomMount(
component as any,
rawProps,
rawSlots,
)
if (!isHydrating && _insertionParent) {
insert(frag, _insertionParent, _insertionAnchor)
}
return frag
}

if (
isSingleRoot &&
component.inheritAttrs !== false &&
Expand All @@ -180,6 +167,19 @@ export function createComponent(
}
}

// vdom interop enabled and component is not an explicit vapor component
if (appContext.vapor && !component.__vapor) {
const frag = appContext.vapor.vdomMount(
component as any,
rawProps,
rawSlots,
)
if (!isHydrating && _insertionParent) {
insert(frag, _insertionParent, _insertionAnchor)
}
return frag
}

const instance = new VaporComponentInstance(
component,
rawProps as RawProps,
Expand Down