Skip to content

Commit 69b7381

Browse files
HDS-4688 Add role=listitem if Card tag is an li
1 parent 7c8758e commit 69b7381

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Diff for: packages/components/src/components/hds/card/container.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<div class={{this.classNames}} ...attributes>{{yield}}</div>
1111
{{else}}
1212
{{#let (element this.componentTag) as |Tag|}}
13-
<Tag class={{this.classNames}} ...attributes>{{yield}}</Tag>
13+
<Tag class={{this.classNames}} role={{if (eq this.componentTag "li") "listitem"}} ...attributes>{{yield}}</Tag>
1414
{{/let}}
1515
{{/if}}

Diff for: showcase/tests/integration/components/hds/card/container-test.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,22 @@ module('Integration | Component | hds/card/container', function (hooks) {
8181

8282
// TAG
8383

84-
test(`it should render a div if no @tag prop is declared`, async function (assert) {
84+
test(`it should render a div if no @tag prop is declared and it should not have a role`, async function (assert) {
8585
await render(hbs`<Hds::Card::Container id="test-card-container" />`);
86-
assert.dom('#test-card-container').hasTagName('div');
86+
assert
87+
.dom('#test-card-container')
88+
.hasTagName('div')
89+
.doesNotHaveAttribute('role');
8790
});
8891

89-
test(`it should render an li vs. a div if specified in the @tag prop`, async function (assert) {
92+
test(`it should render an li if specified in the @tag prop and it should have the correct role`, async function (assert) {
9093
await render(
9194
hbs`<Hds::Card::Container id="test-card-container" @tag="li" />`
9295
);
93-
assert.dom('#test-card-container').hasTagName('li');
96+
assert
97+
.dom('#test-card-container')
98+
.hasTagName('li')
99+
.hasAttribute('role', 'listitem');
94100
});
95101

96102
// ASSERTIONS

0 commit comments

Comments
 (0)