From 1edc2d071bf6d085536068ccad0c46f20084e402 Mon Sep 17 00:00:00 2001 From: MJJ Date: Sun, 8 May 2016 00:12:26 +0800 Subject: [PATCH] fix matching boolean attribute --- src/utils/HtmlAttributesToReact.js | 3 ++- test/unit/utils/HtmlAttributesToReact.spec.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils/HtmlAttributesToReact.js b/src/utils/HtmlAttributesToReact.js index 5a4987e..e85bb5d 100644 --- a/src/utils/HtmlAttributesToReact.js +++ b/src/utils/HtmlAttributesToReact.js @@ -12,7 +12,8 @@ const getParsedAttributeValue = function(attribute, value) { // if the attribute if a boolean then it's value should be the same as it's name // e.g. disabled="disabled" - if (BooleanAttributes.indexOf(attribute) >= 0) { + let lowerBooleanAttributes = BooleanAttributes.map(attr => attr.toLowerCase()); + if (lowerBooleanAttributes.indexOf(attribute.toLowerCase()) >= 0) { value = attribute; } diff --git a/test/unit/utils/HtmlAttributesToReact.spec.js b/test/unit/utils/HtmlAttributesToReact.spec.js index db074f6..a8d4b77 100644 --- a/test/unit/utils/HtmlAttributesToReact.spec.js +++ b/test/unit/utils/HtmlAttributesToReact.spec.js @@ -22,7 +22,8 @@ describe('Testing `utils/HtmlAttributesToReact`', () => { 'UPPER-CASE-TEST-ATTRIBUTE': 'upperTestAttribute', // boolean attributes disabled: '', - checked: '' + checked: '', + autoplay: '' }; const expectedReactAttributes = { @@ -30,14 +31,15 @@ describe('Testing `utils/HtmlAttributesToReact`', () => { htmlFor: 'testFor', minLength: 1, acceptCharset: 'testAcceptCharset', - formNoValidate: 'testFormNoValidate', + formNoValidate: 'formNoValidate', label: 'testLabel', 'data-test': 'test', 'aria-role': 'role', testattribute: 'testAttribute', 'upper-case-test-attribute': 'upperTestAttribute', disabled: 'disabled', - checked: 'checked' + checked: 'checked', + autoPlay: 'autoPlay' }; expect(HtmlAttributesToReact(htmlAttributes)).toEqual(expectedReactAttributes);