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 JSX converter doesn't correctly parse className parameter in tag #1529

Closed
merges opened this issue May 14, 2014 · 7 comments
Closed

Comments

@merges
Copy link

merges commented May 14, 2014

  1. Visit http://facebook.github.io/react/html-jsx.html
  2. Paste <div className="blah"></div> into Live JSX Editor
  3. Observe conversion

EXPECTED RESULT
className is still className in the conversion

ACTUAL RESULT
className is converted to classname; this is invalid JSX

@syranide
Copy link
Contributor

Oops! Yeah that's weird.

@merges
Copy link
Author

merges commented May 14, 2014

Ah, I thought that as supported attributes the converter would parse them correctly?
http://facebook.github.io/react/docs/tags-and-attributes.html#supported-attributes

@syranide
Copy link
Contributor

@merges Hmm, I think it's labeled a little weirdly, you're supposed to paste HTML to the left (i.e <div class="blah"></div>) and see what it becomes in JSX to the right... I think? This doesn't really make sense to me.

@merges
Copy link
Author

merges commented May 14, 2014

The issue I had was that I had partially supported JSX, and needed to use the converter to check something in a large block of markup. It correctly fixed that problem, but spit out the aforementioned classname attribute which isn't supported.

@zpao
Copy link
Member

zpao commented May 14, 2014

Yea, that's labeled weirdly, you should be pasting HTML into the left.

But we should probably leave case intact for unrecognized attributes (cc @Daniel15)

@Daniel15
Copy link
Member

The input field wasn't labelled as "Live JSX Editor" when I initially built the page, I guess that's a more recent change.

I think the issue with the className attribute is that the HTML to JSX converter uses the browser's HTML parsing, which normalises the case of attributes. I could special-case classname so it always gets changed to className, or alternatively use a full proper HTML parser (which I didn't do initially due to time constraints).

@Daniel15 Daniel15 self-assigned this Sep 8, 2014
@Daniel15
Copy link
Member

Moving this issue to https://github.com/reactjs/react-magic since the HTMLToJSX converter now lives entirely in that project.

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

No branches or pull requests

4 participants