From 348ae41548e5881efb1c0f123e9160b262a732bb Mon Sep 17 00:00:00 2001 From: David Martin Date: Thu, 6 Feb 2020 06:34:35 -0800 Subject: [PATCH] Convert focusable attribute to boolean from string (#42) --- dist/converter.js | 4 ++++ src/components/__tests__/FontAwesomeIcon.test.js | 15 ++++++++++++++- src/converter.js | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dist/converter.js b/dist/converter.js index 128b9ce..756354f 100644 --- a/dist/converter.js +++ b/dist/converter.js @@ -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]; diff --git a/src/components/__tests__/FontAwesomeIcon.test.js b/src/components/__tests__/FontAwesomeIcon.test.js index 7e503ac..8560fa7 100644 --- a/src/components/__tests__/FontAwesomeIcon.test.js +++ b/src/components/__tests__/FontAwesomeIcon.test.js @@ -188,4 +188,17 @@ describe('when extra props are given', () => { }) }) - +describe("convert focusable attribute", () => { + test("from false string to boolean", () => { + const tree = renderer + .create() + .toJSON(); + expect(tree.props.focusable).toEqual(false); + }); + test("from true string to boolean", () => { + const tree = renderer + .create() + .toJSON(); + expect(tree.props.focusable).toEqual(true); + }); +}); diff --git a/src/converter.js b/src/converter.js index 480caad..f928a0b 100644 --- a/src/converter.js +++ b/src/converter.js @@ -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]