-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[fix]: strip leading newline after <pre>
and <textarea>
#7280
Conversation
I don't know how to fix the CI timeout. If you think my change is the cause, please let me know. |
<pre>
<pre>
and <textarea>
@tanhauhau Thank you for checking this PR! I made a fix for |
Currently, the following JS is generated. <div>
<textarea>AAA</textarea>
</div> div.innerHTML = `<textarea value="AAA"></textarea>`; I don't think this should work, but it works fine with REPL. (I didn't understand why it worked.) https://svelte.dev/repl/d5ccce1d50d547039053b78db9ce8477?version=3.46.6 However, it didn't work in the test, so I changed it to render to the content. div.innerHTML = `<textarea>AAA</textarea>`; |
oh the result u see in REPL uses |
Ah I see. Thank you for letting me know. |
i see you already made relevant changes right, it's okay i'll review them later |
# Conflicts: # src/compiler/compile/render_ssr/handlers/Element.ts
Thank you for checking this PR. The CI error seems to be due to a timeout. If you think my change is the cause, please let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you! I enhanced the comments a little to explain in more detail the quirkyness that the leading newline is only ignored if innerHTML is used on a parent of the tag, not on the tag content, and not if set through other means.
Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint
Close #7264
This PR changes to strip the newline immediately after
<pre>
.However, if
innerHTML
is used in the renderer and there are multiple newlines, the newline immediately after<pre>
is restored.However, the SSR remains the same as before. This isn't necessary because HTML parsing strips the newline immediately after<pre>
, and it's simpler than handling multiple newlines.It has been changed to handle the same in SSR.