mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-27 05:49:07 +02:00
Only change aria-pressed if it's not an input-based radio or checkbox group
* Only change aria-pressed if it's not an input-based radio or checkbox group aria-pressed="true"/aria-pressed="false" is really only useful for making on/off toggles out of, say, `<button>` elements. the attribute is useless (and potentially confusing/conflicting) on, say, `<label>` elements for an existing `<input type="radio">` or similar. * Add unit test for buttons.js and radio/checkbox inputs in button groups
This commit is contained in:
@@ -66,6 +66,7 @@ const Button = (($) => {
|
||||
|
||||
toggle() {
|
||||
let triggerChangeEvent = true
|
||||
let addAriaPressed = true
|
||||
const rootElement = $(this._element).closest(
|
||||
Selector.DATA_TOGGLE
|
||||
)[0]
|
||||
@@ -94,12 +95,15 @@ const Button = (($) => {
|
||||
}
|
||||
|
||||
input.focus()
|
||||
addAriaPressed = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this._element.setAttribute('aria-pressed',
|
||||
!$(this._element).hasClass(ClassName.ACTIVE))
|
||||
if (addAriaPressed) {
|
||||
this._element.setAttribute('aria-pressed',
|
||||
!$(this._element).hasClass(ClassName.ACTIVE))
|
||||
}
|
||||
|
||||
if (triggerChangeEvent) {
|
||||
$(this._element).toggleClass(ClassName.ACTIVE)
|
||||
|
Reference in New Issue
Block a user