Skip to content

Commit 76c671f

Browse files
authored
Merge pull request #96 from bagby/aria-checked-string
set aria-checked attribute value to string
2 parents 3245285 + 715f68e commit 76c671f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

addon/components/radio-button-input.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ export default Component.extend({
3333
'value',
3434
'ariaLabelledby:aria-labelledby',
3535
'ariaDescribedby:aria-describedby',
36-
'checked:aria-checked'
36+
'checkedStr:aria-checked'
3737
],
3838

3939
checked: computed('groupValue', 'value', function() {
4040
return isEqual(this.get('groupValue'), this.get('value'));
4141
}).readOnly(),
4242

43+
checkedStr: computed('checked', function() {
44+
let checked = this.get('checked');
45+
46+
if (typeof checked === 'boolean') {
47+
return checked.toString();
48+
}
49+
50+
return null;
51+
}),
52+
4353
invokeChangedAction() {
4454
let value = this.get('value');
4555
let changedAction = this.get('changed');

tests/unit/components/radio-button-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ test('it binds `aria-describedby` when specified', function(assert) {
384384
});
385385

386386
test('it updates when clicked, and supports legacy-style string `changed` actions', function(assert) {
387-
assert.expect(5);
387+
assert.expect(7);
388388

389389
let changedActionCallCount = 0;
390390
this.on('changed', function() {
@@ -403,12 +403,14 @@ test('it updates when clicked, and supports legacy-style string `changed` action
403403

404404
assert.equal(changedActionCallCount, 0);
405405
assert.equal(this.$('input').prop('checked'), false);
406+
assert.equal(this.$('input').attr('aria-checked'), 'false');
406407

407408
run(() => {
408409
this.$('input').trigger('click');
409410
});
410411

411412
assert.equal(this.$('input').prop('checked'), true, 'updates element property');
413+
assert.equal(this.$('input').attr('aria-checked'), 'true', 'updates element property');
412414
assert.equal(this.get('groupValue'), 'component-value', 'updates groupValue');
413415

414416
assert.equal(changedActionCallCount, 1);

0 commit comments

Comments
 (0)