Skip to content

Commit

Permalink
Convert focusable attribute to boolean from string (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdavidmartin authored Feb 6, 2020
1 parent 97fa749 commit 348ae41
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dist/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function convert(createElement, element) {
delete element.attributes[key];
break;

case "focusable":
acc.attrs[key] = Boolean(val);
break;

default:
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || 'fill' === key && 'currentColor' === val) {
delete element.attributes[key];
Expand Down
15 changes: 14 additions & 1 deletion src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,17 @@ describe('when extra props are given', () => {
})
})


describe("convert focusable attribute", () => {
test("from false string to boolean", () => {
const tree = renderer
.create(<FontAwesomeIcon icon={faCoffee} focusable='false' color="purple" foo="bar" />)
.toJSON();
expect(tree.props.focusable).toEqual(false);
});
test("from true string to boolean", () => {
const tree = renderer
.create(<FontAwesomeIcon icon={faCoffee} focusable='true' color="purple" foo="bar" />)
.toJSON();
expect(tree.props.focusable).toEqual(true);
});
});
3 changes: 3 additions & 0 deletions src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function convert(createElement, element, extraProps = {}) {
case 'xmlns':
delete element.attributes[key]
break
case "focusable":
acc.attrs[key] = Boolean(val);
break
default:
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || ( 'fill' === key && 'currentColor' === val )) {
delete element.attributes[key]
Expand Down

0 comments on commit 348ae41

Please sign in to comment.