Skip to content

Commit

Permalink
Merge pull request #24 in FFE/ffe-checkbox-react from support-aria-in…
Browse files Browse the repository at this point in the history
…valid to master

* commit '37f53818c2f222d313d517ae66043bf3fa380b0d':
  Support prop-name aria-invalid from the WAI-ARIA spec as well
  • Loading branch information
ivarni committed Jun 19, 2017
2 parents 04717d3 + ddf1b1b commit cfd799d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 4.4.0
* Support `aria-invalid` as a prop in addition to `invalid`.

## 4.3.0
* Increased version range for ffe-form to 6.x

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-checkbox-react",
"version": "4.3.0",
"version": "4.4.0",
"main": "lib/checkbox.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/. && npm run example",
Expand Down
2 changes: 1 addition & 1 deletion src/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function CheckBox(props) {
className="ffe-hidden-checkbox"
id={id}
type="checkbox"
{...rest}
aria-invalid={String(!!invalid)}
{...rest}
/>
<label
className={classNames({
Expand Down
22 changes: 22 additions & 0 deletions src/checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ describe('<Checkbox />', () => {
assert.equal(shallow(CreateCheckbox({ invalid: true })).find('input').prop('aria-invalid'), 'true');
});

it('setting "aria-invalid" should override "invalid"', () => {
assert.equal(
shallow(CreateCheckbox({ invalid: true, 'aria-invalid': 'false' })).find('input').prop('aria-invalid'),
'false'
);

assert.equal(
shallow(CreateCheckbox({ invalid: false, 'aria-invalid': 'true' })).find('input').prop('aria-invalid'),
'true'
);

assert.equal(
shallow(CreateCheckbox({ invalid: false, 'aria-invalid': 'spelling' })).find('input').prop('aria-invalid'),
'spelling'
);

assert.equal(
shallow(CreateCheckbox({ invalid: false, 'aria-invalid': 'grammar' })).find('input').prop('aria-invalid'),
'grammar'
);
});

it('should set arbitrary props (rest) on input', () => {
const wrapper = shallow(CreateCheckbox({
name: 'checkbox',
Expand Down

0 comments on commit cfd799d

Please sign in to comment.