react icon indicating copy to clipboard operation
react copied to clipboard

in jsx, html entities without surrounding text produce bad JS

Open digitalicarus opened this issue 12 years ago • 3 comments

HTML entities work if interspersed in plain text. Ex: return <div className="padlock-locked-bg graphic-cell">test &nbsp; test</div>; becomes return React.DOM.div( {className:"padlock-locked-bg graphic-cell"}, "test   test"); ... where the space in the middle is a genuine nbsp

Often a non-breaking space is used to style the background of an element without it collapsing. This does not work in react currently.

return <div className="padlock-locked-bg graphic-cell">&nbsp;</div>; becomes return React.DOM.div( {className:"padlock-locked-bg graphic-cell"}&nbsp;); ... and does not parse

digitalicarus avatar Feb 25 '14 05:02 digitalicarus

I believe this works correctly in 0.9 -- can you confirm? You can also try at http://facebook.github.io/react/jsx-compiler.html.

sophiebits avatar Feb 25 '14 06:02 sophiebits

Indeed, you are right. I was using 0.9.0 in the browser but my copy of gulp-react was stale. Sorry about that Ben.

digitalicarus avatar Feb 25 '14 06:02 digitalicarus

No problem, glad you figured it out!

sophiebits avatar Feb 25 '14 06:02 sophiebits