diff options
| author | Patrick H. Lauke <[email protected]> | 2017-04-10 14:43:54 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-04-10 14:43:54 +0100 |
| commit | 3f6e1faf45d503d670e01b600a0455e2da0fe660 (patch) | |
| tree | bd4366e7094dcc6a92b704ed88e4f2606884c30e /js/tests/unit/button.js | |
| parent | 278ddd0acd9700917791af0b67d44bc21ed17498 (diff) | |
| download | bootstrap-3f6e1faf45d503d670e01b600a0455e2da0fe660.tar.xz bootstrap-3f6e1faf45d503d670e01b600a0455e2da0fe660.zip | |
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
Diffstat (limited to 'js/tests/unit/button.js')
| -rw-r--r-- | js/tests/unit/button.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index c67cea345..abc04e10a 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -138,4 +138,22 @@ $(function () { assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked') }) + QUnit.test('should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group', function (assert) { + assert.expect(2) + var groupHTML = '<div class="btn-group" data-toggle="buttons">' + + '<label class="btn btn-primary"><input type="checkbox" autocomplete="off"> Checkbox</label>' + + '<label class="btn btn-primary"><input type="radio" name="options" autocomplete="off"> Radio</label>' + + '</div>' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + var $btn1 = $group.children().eq(0) + var $btn2 = $group.children().eq(1) + + $btn1.find('input').trigger('click') + assert.ok($btn1.is(':not([aria-pressed])'), 'label for nested checkbox input has not been given an aria-pressed attribute') + + $btn2.find('input').trigger('click') + assert.ok($btn2.is(':not([aria-pressed])'), 'label for nested radio input has not been given an aria-pressed attribute') + }) + }) |
