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

Handling of @html in textarea tags #5603

Open
ethan-tqa opened this issue Oct 28, 2020 · 6 comments
Open

Handling of @html in textarea tags #5603

ethan-tqa opened this issue Oct 28, 2020 · 6 comments

Comments

@ethan-tqa
Copy link

Describe the bug
Svelte compiler fails to handle {@html} inside <textarea> tags

Logs
No output in browser console. Compiler throws error Unexpected character '@' (7:11)

To Reproduce
https://svelte.dev/repl/001f72ee82ac4115920eaf086d785584

Expected behavior
The compiler compiles the code successfully, the output <textarea> contains the child HTML elements in the string.

Stacktraces
N/A

Information about your Svelte project:

  • Your browser and the version: Firefox 82, Chrome 86 (doesn't matter)

  • Your operating system: Windows 10 (doesn't matter)

  • Svelte version: 3.29.4

  • Whether your project uses Webpack or Rollup: None, as I used Snowpack in dev mode.

Severity
Low. I was able to use <div> instead for my use case.

Additional context
I was trying to integrate TinyMCE editor into my Svelte app. On the surface, TinyMCE uses <textarea> and the content to be edited must be children of that <textarea>. But upon reading through their docs (it's a bit unclear) turns out <div> can be used too, so that's my solution for the time being.

@nickolasgregory
Copy link

Sometimes Svelte isn't quite normal html. The docs show how to bind_element_property to a textarea
<textarea bind:value={name}></textarea>

@ethan-tqa
Copy link
Author

Yes, it is true that I can use bind:value with <textarea>, but for my use case, that does not work out. As stated in the original report, TinyMCE wants the content to be raw HTML children nodes of the main editor element, which bind:value does not fulfill.

@Conduitry
Copy link
Member

I don't know what I'd expect {@html foo} to do inside a <textarea> that's different from just {foo}. Perhaps we can improve the parser error here, but I don't see what the desired behavior is. I don't think <textarea>s have child elements.

@MichealPearce
Copy link

To achieve your desired outcome, you could use a div tag with the attribute contenteditable. I'm not sure TinyMCE's requirements however.

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 27, 2021
@stale
Copy link

stale bot commented Dec 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Dec 24, 2021
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

5 participants