Skip to content

Commit

Permalink
Fix issue aknuds1#52
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpalmer committed Oct 6, 2017
1 parent e510335 commit a0bc13e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ function createStyleJsonFromString(styleString) {
if (singleStyle.length > 2) {
singleStyle[1] = singleStyle.slice(1).join(':');
}

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

if (key.length > 0 && value.length > 0) {
if (key && value && key.length > 0 && value.length > 0) {
jsonStyles[key] = value;
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/html-to-react-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ describe('Html2React', function () {
var reactComponent = parser.parse(htmlInput);
var reactHtml = ReactDOMServer.renderToStaticMarkup(reactComponent);

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>';

var reactComponent = parser.parse(htmlInput);
var reactHtml = ReactDOMServer.renderToStaticMarkup(reactComponent);

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

0 comments on commit a0bc13e

Please sign in to comment.