Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html-to-react crashes on invalid style tag #52

Closed
nickpalmer opened this issue Oct 6, 2017 · 2 comments
Closed

html-to-react crashes on invalid style tag #52

nickpalmer opened this issue Oct 6, 2017 · 2 comments

Comments

@nickpalmer
Copy link

nickpalmer commented Oct 6, 2017

function createStyleJsonFromString(styleString) {
  styleString = styleString || '';
  var styles = styleString.split(/;(?!base64)/);
  var singleStyle, key, value, jsonStyles = {};
  for (var i = 0; i < styles.length; ++i) {
    singleStyle = styles[i].split(':');
    if (singleStyle.length > 2) {
      singleStyle[1] = singleStyle.slice(1).join(':');
    }
    
    key = camelize(singleStyle[0]);
    value = singleStyle[1];
    //
    // If key or value are undefined this blows up
    //
    if (key.length > 0 && value.length > 0) {
      jsonStyles[key] = value;
    }
  }
  return jsonStyles;
}
nickpalmer added a commit to nick-codes/html-to-react that referenced this issue Oct 6, 2017
@nickpalmer
Copy link
Author

Would love to get this merged and up on npm ASAP. :) Thanks for a great project.

aknuds1 pushed a commit that referenced this issue Oct 7, 2017
* Fix issue #52

* Add newline between tests
@aknuds1
Copy link
Owner

aknuds1 commented Oct 7, 2017

Merged your PR and published version 1.3.1, thanks! Next time, please put "Fixes #" in your PR's description as it will close the corresponding issue automatically.

@aknuds1 aknuds1 closed this as completed Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants