ssorallen / turbo-react

A JavaScript library that transitions between static HTML pages on navigation; no app server required.
https://turbo-react.herokuapp.com/
Apache License 2.0
274 stars 16 forks source link

<textarea> and <pre> content is not converted properly #22

Closed sicks closed 8 years ago

sicks commented 8 years ago

The following rules are affecting <textarea> and <pre> when the page renders:

All lines having leading or trailing whitespace are trimmed, all newlines are removed, adjacent text separated by newlines become separated by a single space. Any whitespace tabs are replaced with spaces. Strings inside expressions are unaffected.

Summarized from this pull request. I was originally looking for a way to opt-out a specific element from this, but after reading how react normally works with JSX components I'm not sure how to address this if you're building your UI with something else.

sicks commented 8 years ago

It looks like this is actually due to the HTMLtoJSX converter. I don't think it produces the JSX necessary to maintain textarea and pre tag contents, here's a fiddle demonstrating this.

sicks commented 8 years ago

Moved this to react-magic#33 as that's where the HTMLtoJSX converter lives.

sicks commented 8 years ago

fixed in reactjs/react-magic@8b90aa3

ssorallen commented 8 years ago

Perfect, thanks for the note. I will update turbo-react with the latest react-magic.

sicks commented 8 years ago

Thanks! Don't forget the rails gem!

ssorallen commented 8 years ago

Pushed an updated version of the JS and of the Ruby gem with the update assets.

tom-orrow commented 8 years ago

Hi. A bit of explanation could be nice. How can I render textarea with new lines? Value attribute still replaces line breaks with spaces. Default value attribute seems not working.

sicks commented 8 years ago

@tom-orrow this was fixed in reactjs/react-magic@8b90aa3, but broken again when turbo-react's version of turbolinks was updated to non-stable version, see #24.

sicks commented 8 years ago

Actually I just realized I hadn't switched back to the original turbo_react-rails gem. @ssorallen your release doesn't appear to include the newline fixes, any idea?

ssorallen commented 8 years ago

@sickslives turbo-react does not bundle Turbolinks any more, so turbo-react needs to the react-magic fix in order to work with Edge Turbolinks.

Is there a release of react-magic with the fix? I can update both turbo-react and turbo-react_rails with it.

sicks commented 8 years ago

@ssorallen The current master branch of react-magic includes the textarea/pre fix, I'm not sure why it didn't come through in your bundle. I got it working in my fork but since the file's minified I can't really tell why mine works and yours doesn't.

Covering all the bases, did you remember to copy the dist version over to turbo_react-rails's vendor folder after building turbo-react? :P

ssorallen commented 8 years ago

The commit to fix <textarea> and <pre> is not yet in a release for html-to-jsx. The latest is v0.2.4, but the commit is only in master: https://github.com/reactjs/react-magic/compare/release-0.2.4...master