-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[fix]: strip leading newline after <pre>
and <textarea>
#7280
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
69b70e6
[fix]: strip leading newline after `<pre>`
ota-meshi ece59b4
Fix for `<textarea>`
ota-meshi 1464caf
fix test for CRLF
ota-meshi 7d4990c
Strip newline logic to src/compiler/compile/nodes/Eleement.ts
ota-meshi a3c027c
add to_html_for_attr_value and use it
ota-meshi 130975e
Merge commit 'c36f1c066ef2dbfd1a414d358151a09d0fe7ae4c' into pre2
ota-meshi 563303c
fix testcase
ota-meshi 03dff46
revert Fragment
ota-meshi 21a00bd
remove empty line
ota-meshi 2789ace
check leading newline immediately after `<textarea>` in SSR.
ota-meshi 04c2ce4
comments
e925e38
Merge branch 'master' into pre2
3fc9fb6
changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export const whitespace = /[ \t\r\n]/; | ||
export const start_whitespace = /^[ \t\r\n]*/; | ||
export const end_whitespace = /[ \t\r\n]*$/; | ||
export const start_newline = /^\r?\n/; | ||
|
||
export const dimensions = /^(?:offset|client)(?:Width|Height)$/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[main.svelte] | ||
trim_trailing_whitespace = unset | ||
tanhauhau marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[main.svelte] | ||
trim_trailing_whitespace = unset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export default { | ||
test({ assert, target }) { | ||
// Test for <textarea> tag | ||
const elementTextarea = target.querySelector('#textarea'); | ||
// Test for <textarea> tag in non <textarea> tag | ||
const elementDivWithTextarea = target.querySelector('#div-with-textarea'); | ||
// Test for <textarea> tag with leading newline | ||
const elementTextareaWithLeadingNewline = target.querySelector('#textarea-with-leading-newline'); | ||
const elementTextareaWithoutLeadingNewline = target.querySelector('#textarea-without-leading-newline'); | ||
const elementTextareaWithMultipleLeadingNewline = target.querySelector('#textarea-with-multiple-leading-newlines'); | ||
const elementDivWithTextareaWithMultipleLeadingNewline = target.querySelector('#div-with-textarea-with-multiple-leading-newlines'); | ||
|
||
assert.equal( | ||
elementTextarea.value, | ||
` A | ||
B | ||
` | ||
); | ||
assert.equal( | ||
elementDivWithTextarea.children[0].value, | ||
` A | ||
B | ||
` | ||
); | ||
assert.equal(elementTextareaWithLeadingNewline.children[0].value, 'leading newline'); | ||
assert.equal(elementTextareaWithLeadingNewline.children[1].value, ' leading newline and spaces'); | ||
assert.equal(elementTextareaWithLeadingNewline.children[2].value, '\nleading newlines'); | ||
assert.equal(elementTextareaWithoutLeadingNewline.children[0].value, 'without spaces'); | ||
assert.equal(elementTextareaWithoutLeadingNewline.children[1].value, ' with spaces '); | ||
assert.equal(elementTextareaWithoutLeadingNewline.children[2].value, ' \nnewline after leading space'); | ||
assert.equal(elementTextareaWithMultipleLeadingNewline.value, '\n\nmultiple leading newlines'); | ||
assert.equal(elementDivWithTextareaWithMultipleLeadingNewline.children[0].value, '\n\nmultiple leading newlines'); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<textarea id="textarea"> | ||
A | ||
B | ||
</textarea> | ||
|
||
<div id="div-with-textarea"> | ||
<textarea> | ||
A | ||
B | ||
</textarea> | ||
</div> | ||
|
||
<div id="textarea-with-leading-newline"> | ||
<textarea> | ||
leading newline</textarea> | ||
<textarea> | ||
leading newline and spaces</textarea> | ||
<textarea> | ||
|
||
leading newlines</textarea> | ||
</div> | ||
|
||
<div id="textarea-without-leading-newline"> | ||
<textarea>without spaces</textarea> | ||
<textarea> with spaces </textarea> | ||
<textarea> | ||
newline after leading space</textarea> | ||
</div> | ||
|
||
<textarea id="textarea-with-multiple-leading-newlines"> | ||
|
||
|
||
multiple leading newlines</textarea> | ||
|
||
<div id="div-with-textarea-with-multiple-leading-newlines"> | ||
<textarea> | ||
|
||
|
||
multiple leading newlines</textarea> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[{main.svelte,_expected.html}] | ||
trim_trailing_whitespace = unset | ||
tanhauhau marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.