Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/runtime/components/Separator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import { tv } from '../utils/tv'
import UIcon from './Icon.vue'
import UAvatar from './Avatar.vue'

defineOptions({ inheritAttrs: false })

const _props = withDefaults(defineProps<SeparatorProps>(), {
orientation: 'horizontal',
position: 'center'
Expand Down Expand Up @@ -102,7 +104,7 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.separator ||
</div>
</DefineContainer>

<Separator v-bind="rootProps" data-slot="root" :class="ui.root({ class: [props.ui?.root, props.class] })">
<Separator v-bind="{ ...rootProps, ...$attrs }" data-slot="root" :class="ui.root({ class: [props.ui?.root, props.class] })">
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<ReuseContainer v-if="hasContent && props.position === 'start'" />

<div data-slot="border" :class="ui.border({ class: props.ui?.border })" />
Expand Down
20 changes: 19 additions & 1 deletion test/components/Separator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'
import { describe, it, expect, vi } from 'vitest'
import { axe } from 'vitest-axe'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { renderEach } from '../component-render'
Expand Down Expand Up @@ -26,6 +26,24 @@ describe('Separator', () => {
['with ui', { props: { ui: { label: 'text-lg' } } }]
])

it('forwards fall-through attributes to the root without warning', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})

const wrapper = await mountSuspended(Separator, {
props: { label: 'or' },
attrs: { 'id': 'my-separator', 'data-test': 'value' }
})

const root = wrapper.get('[data-slot="root"]')
expect(root.attributes('id')).toBe('my-separator')
expect(root.attributes('data-test')).toBe('value')

const warnings = warn.mock.calls.map(args => args.join(' ')).join('\n')
expect(warnings).not.toContain('Extraneous non-props attributes')

warn.mockRestore()
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

it('passes accessibility tests', async () => {
const wrapper = await mountSuspended(Separator, {
props: {
Expand Down
Loading