Skip to content
Closed
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
21 changes: 21 additions & 0 deletions packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,27 @@ describe('attribute fallthrough', () => {
expect(node.hasAttribute('foo')).toBe(false)
})

it('should fallthrough with inheritAttrs: true and no declared props', () => {
const Parent = {
render() {
return h(Child, { class: 'parent' })
}
}

const Child = defineComponent({
inheritAttrs: true,
render() {
return h('div')
}
})

const root = document.createElement('div')
document.body.appendChild(root)
render(h(Parent), root)

expect(root.innerHTML).toMatch(`<div class="parent"></div>`)
})

it('should not fallthrough with inheritAttrs: false', () => {
const Parent = {
render() {
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export function renderComponentRoot(

// attr merging
if (
Component.props != null &&
Component.inheritAttrs !== false &&
(Component.inheritAttrs ||
(Component.props != null && Component.inheritAttrs !== false)) &&
attrs !== EMPTY_OBJ &&
Object.keys(attrs).length
) {
Expand Down