Skip to content

Commit

Permalink
Fix for issues #33 #19 (#41)
Browse files Browse the repository at this point in the history
* Added check for title if 2F returns empty string

* Implemented requested changes
  • Loading branch information
OisinNolan committed Sep 1, 2020
1 parent d29837a commit 25d1f35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@ var accname = (function (exports) {
.join(' ');
// #SPEC_ASSUMPTION (F.2) : that CSS generated content should be
// concatenated to accumulatedText
return (cssBeforeContent + accumulatedText + cssAfterContent).trim();
const result = (cssBeforeContent + accumulatedText + cssAfterContent).trim();
return result || null;
}

/**
Expand Down
22 changes: 22 additions & 0 deletions src/lib/compute_text_alternative_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,26 @@ describe('The computeTextAlternative function', () => {
rulesApplied: new Set<Rule>(['2B', '2F', '2G']),
});
});

it('check title attribute for name when subtree is empty', () => {
render(
html` <input type="checkbox" title="Hello world" id="foo" /> `,
container
);
const elem = document.getElementById('foo')!;
expect(computeTextAlternative(elem).name).toEqual('Hello world');
});

it('check title attribute for name when subtree is hidden', () => {
render(
html`
<button title="Hello world" id="foo">
<div aria-hidden="true">Invisible text</div>
</button>
`,
container
);
const elem = document.getElementById('foo')!;
expect(computeTextAlternative(elem).name).toEqual('Hello world');
});
});
4 changes: 3 additions & 1 deletion src/lib/rule2F.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,7 @@ export function rule2F(

// #SPEC_ASSUMPTION (F.2) : that CSS generated content should be
// concatenated to accumulatedText
return (cssBeforeContent + accumulatedText + cssAfterContent).trim();
const result = (cssBeforeContent + accumulatedText + cssAfterContent).trim();

return result || null;
}

0 comments on commit 25d1f35

Please sign in to comment.