Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const computeAttrs = (props, data) => {
const nonStandardTag = isNonStandardTag(props)
const hashLink = link && props.href === '#'
const role = data.attrs && data.attrs.role ? data.attrs.role : null
const ariaDisabled =
data.attrs && data.attrs['aria-disabled'] ? data.attrs['aria-disabled'] : null
let tabindex = data.attrs ? data.attrs.tabindex : null
if (nonStandardTag || hashLink) {
tabindex = '0'
Expand All @@ -98,7 +100,7 @@ const computeAttrs = (props, data) => {
// Except when link has `href` of `#`
role: nonStandardTag || hashLink ? 'button' : role,
// We set the `aria-disabled` state for non-standard tags
'aria-disabled': nonStandardTag ? String(props.disabled) : null,
'aria-disabled': nonStandardTag ? String(props.disabled) : ariaDisabled,
// For toggles, we need to set the pressed state for ARIA
'aria-pressed': toggle ? String(props.pressed) : null,
// `autocomplete="off"` is needed in toggle mode to prevent some browsers
Expand Down
12 changes: 12 additions & 0 deletions src/components/button/button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ describe('button', () => {
wrapper.destroy()
})

it('button has aria-disabled attribute when explicitly set', () => {
const wrapper = mount(BButton, {
attrs: {
'aria-disabled': 'true'
}
})

expect(wrapper.attributes('aria-disabled')).toBe('true')

wrapper.destroy()
})

it('link has attribute aria-disabled when disabled set', async () => {
const wrapper = mount(BButton, {
propsData: {
Expand Down