1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Merge pull request #21093 from Johann-S/fixButtonGrpAria

Close #21090 - Fix aria-pressed attribute for buttons in container with data-attribute="buttons"
This commit is contained in:
Patrick H. Lauke 2017-01-05 09:35:43 +00:00 committed by GitHub
commit 85a1fdcb29
2 changed files with 14 additions and 3 deletions

View file

@ -96,11 +96,11 @@ const Button = (($) => {
input.focus()
}
} else {
this._element.setAttribute('aria-pressed',
!$(this._element).hasClass(ClassName.ACTIVE))
}
this._element.setAttribute('aria-pressed',
!$(this._element).hasClass(ClassName.ACTIVE))
if (triggerChangeEvent) {
$(this._element).toggleClass(ClassName.ACTIVE)
}

View file

@ -60,6 +60,17 @@ $(function () {
assert.strictEqual($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
})
QUnit.test('should toggle aria-pressed on buttons with container', function (assert) {
assert.expect(1)
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
'<button id="btn1" class="btn btn-secondary" type="button">One</button>' +
'<button class="btn btn-secondary" type="button">Two</button>' +
'</div>'
$('#qunit-fixture').append(groupHTML)
$('#btn1').bootstrapButton('toggle')
assert.strictEqual($('#btn1').attr('aria-pressed'), 'true')
})
QUnit.test('should toggle aria-pressed when btn children are clicked', function (assert) {
assert.expect(2)
var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>')