Skip to content

Commit fd9cb1b

Browse files
fix aria-checked (#141)
* Add test assertions for "aria-checked" * Fix aria-checked * cleaner to just pass checked in as an arg Co-authored-by: Jason Barry <[email protected]>
1 parent 92a2077 commit fd9cb1b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<input ...attributes type="radio" aria-checked={{this.checkedStr}} value={{@value}} {{on "change" this.change}} />
1+
<input ...attributes type="radio" checked={{@checked}} aria-checked={{this.checkedStr}} value={{@value}} {{on "change" this.change}} />

addon/components/radio-button.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
required={{@required}}
1010
tabindex={{@tabindex}}
1111
@groupValue={{@groupValue}}
12-
checked={{this.checked}}
12+
@checked={{this.checked}}
1313
@value={{@value}}
1414
aria-labelledby={{@ariaLabelledby}}
1515
aria-describedby={{@ariaDescribedby}}
@@ -27,7 +27,7 @@
2727
required={{@required}}
2828
tabindex={{@tabindex}}
2929
@groupValue={{@groupValue}}
30-
checked={{this.checked}}
30+
@checked={{this.checked}}
3131
@value={{@value}}
3232
aria-labelledby={{@ariaLabelledby}}
3333
aria-describedby={{@ariaDescribedby}}

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module('Integration | Components | Radio Button', function (hooks) {
88
setupRenderingTest(hooks);
99

1010
test('begins checked when groupValue matches value', async function (assert) {
11-
assert.expect(1);
11+
assert.expect(2);
1212

1313
await render(hbs`
1414
<RadioButton
@@ -18,18 +18,20 @@ module('Integration | Components | Radio Button', function (hooks) {
1818
`);
1919

2020
assert.dom('input').isChecked();
21+
assert.dom('input').hasAttribute('aria-checked', 'true');
2122
});
2223

2324
test('it updates when clicked, and triggers the `changed` action', async function (assert) {
24-
assert.expect(5);
25+
assert.expect(7);
2526

2627
let changedActionCallCount = 0;
2728

2829
this.set('groupValue', 'initial-group-value');
2930

30-
this.set('changed', function (newValue) {
31+
this.set('changed', (newValue) => {
3132
changedActionCallCount++;
3233
assert.strictEqual(newValue, 'component-value', 'updates groupValue');
34+
this.set('groupValue', newValue);
3335
});
3436

3537
await render(hbs`
@@ -42,10 +44,20 @@ module('Integration | Components | Radio Button', function (hooks) {
4244

4345
assert.strictEqual(changedActionCallCount, 0);
4446
assert.dom('input').isNotChecked();
47+
assert
48+
.dom('input')
49+
.hasAttribute(
50+
'aria-checked',
51+
'false',
52+
'aria-checked property starts false'
53+
);
4554

4655
await triggerEvent('input', 'click');
4756

4857
assert.dom('input').isChecked('updates element property');
58+
assert
59+
.dom('input')
60+
.hasAttribute('aria-checked', 'true', 'updates aria-checked property');
4961

5062
assert.strictEqual(changedActionCallCount, 1);
5163
});

0 commit comments

Comments
 (0)