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

Error: Client parser breaks when first element has attributes #23

Closed
remarkablemark opened this issue Sep 27, 2016 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@remarkablemark
Copy link
Owner

remarkablemark commented Sep 27, 2016

When the client parser parses an HTML string where the first element has attribute(s), this causes the regex to match an improper tag name and throw an error on this line.

Example:

// works
HTMLReactParser('<p>foo</p>');

// breaks
HTMLReactParser('<p id="bar">foo</p>');

Error thrown:

TypeError: Cannot read property 'parentNode' of undefined

@remarkablemark remarkablemark added the bug Something isn't working label Sep 27, 2016
@remarkablemark remarkablemark self-assigned this Sep 27, 2016
remarkablemark added a commit that referenced this issue Sep 27, 2016
For the client parser, when the first element of the HTML string
has attributes, the regex will improperly capture everything and
make the tag name invalid.

The fix is to ensure only the tag name is matched and whitespace
is trimmed.

Fixes #23
remarkablemark added a commit that referenced this issue Sep 27, 2016
Confirm that for the client parser, if the first HTML element has
attributes, it should properly match only the tag name and no
longer throw an error.

Issue #23
@remarkablemark remarkablemark changed the title Error: Client-side parser breaks when root element has attributes Error: Client parser breaks when first element has attributes Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant