react-magic
react-magic copied to clipboard
HTML fragments are being ignored
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>
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.
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?
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?
@karlfloersch - What issues have you encountered? Concrete examples would be great, ideally one separate issue per issue to allow for better tracking :smile: JSX should allow most HTML tags except for deprecated tags, and hence the converter should also support them.