Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close #21090 - Fix aria-pressed attribute for buttons in container with data-attribute="buttons" #21093

Merged
merged 1 commit into from
Jan 5, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions js/src/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 11 additions & 0 deletions js/tests/unit/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdo is this just a problem of configuration? running the test locally worked just fine with no errors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardiharborow should we add qunit in .eslintrc.json to avoid this ?
see : http://eslint.org/docs/user-guide/configuring#specifying-environments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickhlauke @Johann-S this is due to Hound not supporting the cascading ESLint configs we use. Hound was recently set to ignore our test files, until a workaround can be found. Travis lints everything correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, in that case i'll go ahead and merge. thanks for clarifying, @bardiharborow

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>')
Expand Down