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 fragments are being ignored #32

Open
andrewkolesnikov opened this issue Aug 15, 2015 · 4 comments
Open

HTML fragments are being ignored #32

andrewkolesnikov opened this issue Aug 15, 2015 · 4 comments
Labels

Comments

@andrewkolesnikov
Copy link

The following test fails, probably because it's fed to innerHTML.

  it('should handle tr, td tags', function() {
    var converter = new HTMLtoJSX({ createClass: false });
    expect(converter.convert('<tr><td>foo</td></tr>').trim())
      .toBe('<tr><td>foo</td></tr>');
  });

Fails with:
Expected '<div> foo </div>' to be '<tr><td>foo</td></tr>'.

Consequently, tons of HTML fragments won't be converted correctly, e.g. <table><tr><td>foo</td></tr></table> becomes <table><tbody><tr><td>foo</td></tr></tbody></table>

@Daniel15 Daniel15 added the bug label Aug 15, 2015
@Daniel15
Copy link
Member

Good catch! Indeed, table elements need special handling here.

For your second case, is that actually an issue? Tables should ideally always have at least one <tbody> in them.

@andrewkolesnikov
Copy link
Author

Agreed. Injecting <tbody> shouldn't be an issue in most cases.
Perhaps a note in the README to indicate elements aren't guaranteed to match 1:1?

@karlfloersch
Copy link

Daniel15, is this project ever going to be able to match HTML 1:1? Could you ever ensure a ~100% compatibility with HTML5? Does React/JSX have full coverage over everything you can do in normal HTML?

When I used this on a few sites, I would often get HTML syntax errors (akin to #9). Is that due to an incompatibility or just a buggy parser that could be fixed if enough time was put into it?

@Daniel15
Copy link
Member

@karlfloersch - What issues have you encountered? Concrete examples would be great, ideally one separate issue per issue to allow for better tracking 😄 JSX should allow most HTML tags except for deprecated tags, and hence the converter should also support them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants