Skip to content

Commit 5356b24

Browse files
committed
Release 0.2.1
1 parent 348ae41 commit 5356b24

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
---
88

9+
## [0.2.1](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.1) - 2020-02-06
10+
11+
### Fixed
12+
13+
- Convert 'focusable' attribute to boolean from string #42
14+
915
## [0.2.0](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.0) - 2019-12-13
1016

1117
### Added

dist/converter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ function convert(createElement, element) {
5656
delete element.attributes[key];
5757
break;
5858

59-
case "focusable":
60-
acc.attrs[key] = Boolean(val);
59+
case 'focusable':
60+
acc.attrs[key] = val === 'true' ? true : false;
6161
break;
6262

6363
default:

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fortawesome/react-native-fontawesome",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Official React Native component for Font Awesome 5",
55
"main": "index.js",
66
"scripts": {
@@ -18,7 +18,8 @@
1818
"Travis Chase <[email protected]>",
1919
"Rob Madole <[email protected]>",
2020
"Mike Wilkerson <[email protected]>",
21-
21+
22+
"David Martin <github.com/iamdavidmartin>"
2223
],
2324
"license": "MIT",
2425
"peerDependencies": {

src/components/__tests__/FontAwesomeIcon.test.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import renderer from 'react-test-renderer'
55
import { StyleSheet } from 'react-native'
66
import { find } from 'lodash'
77

8+
jest.spyOn(React, 'createElement')
9+
810
const faCoffee = {
911
prefix: 'fas',
1012
iconName: 'coffee',
@@ -189,16 +191,16 @@ describe('when extra props are given', () => {
189191
})
190192

191193
describe("convert focusable attribute", () => {
192-
test("from false string to boolean", () => {
193-
const tree = renderer
194-
.create(<FontAwesomeIcon icon={faCoffee} focusable='false' color="purple" foo="bar" />)
195-
.toJSON();
196-
expect(tree.props.focusable).toEqual(false);
197-
});
198-
test("from true string to boolean", () => {
194+
test("no title leads to focusable false", () => {
199195
const tree = renderer
200-
.create(<FontAwesomeIcon icon={faCoffee} focusable='true' color="purple" foo="bar" />)
201-
.toJSON();
202-
expect(tree.props.focusable).toEqual(true);
203-
});
196+
.create(<FontAwesomeIcon icon={faCoffee} />)
197+
.toJSON()
198+
199+
React.createElement.mock.calls
200+
.map(([_c, attrs, _children]) => attrs)
201+
.filter((attrs) => 'focusable' in attrs)
202+
.forEach(({ focusable }) => {
203+
expect(focusable).toEqual(false)
204+
})
205+
})
204206
});

src/converter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ function convert(createElement, element, extraProps = {}) {
2525
const mixins = Object.keys(element.attributes || {}).reduce(
2626
(acc, key) => {
2727
const val = element.attributes[key]
28-
switch(key){
28+
switch (key) {
2929
case 'class':
3030
case 'role':
3131
case 'style':
3232
case 'xmlns':
3333
delete element.attributes[key]
3434
break
35-
case "focusable":
36-
acc.attrs[key] = Boolean(val);
35+
case 'focusable':
36+
acc.attrs[key] = (val === 'true') ? true : false
3737
break
3838
default:
3939
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || ( 'fill' === key && 'currentColor' === val )) {

0 commit comments

Comments
 (0)