Skip to content

Commit

Permalink
Ensure that key is defined before calling camelize
Browse files Browse the repository at this point in the history
  • Loading branch information
aknuds1 committed Oct 7, 2017
1 parent 5fdcce0 commit 5432f32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.js]
indent_style = space
end_of_line = lf
insert_final_newline = true
max_line_length = 100
indent_size = 2
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ function createStyleJsonFromString(styleString) {
singleStyle[1] = singleStyle.slice(1).join(':');
}

key = camelize(singleStyle[0]);
key = singleStyle[0];
value = singleStyle[1];
if (typeof value === 'string'){
value = value.trim();
}

if (key && value && key.length > 0 && value.length > 0) {
jsonStyles[key] = value;
if (key != null && value != null && key.length > 0 && value.length > 0) {
jsonStyles[camelize(key)] = value;
}
}
return jsonStyles;
Expand Down
2 changes: 1 addition & 1 deletion test/html-to-react-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('Html2React', function () {

assert.equal(reactHtml, htmlExpected);
});

it('should handle invalid style tag', function () {
var htmlInput = '<div style="color:black;href="></div>';
var htmlExpected = '<div style="color:black"></div>';
Expand Down

0 comments on commit 5432f32

Please sign in to comment.