[fix] whitespace html entities lost in component slot #8464
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.
closes: #8359
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint
The reason is due to the following code
svelte/src/compiler/compile/nodes/InlineComponent.ts
Lines 170 to 172 in d42ca04
svelte/src/compiler/utils/patterns.ts
Line 7 in d42ca04
is non-breaking space characte, /\s/ match it and judging that it should not be retained.
in
<span> </span>
use[ \t\r\n]
so it will not be delete.svelte/src/compiler/compile/render_dom/wrappers/Fragment.ts
Lines 102 to 104 in d42ca04
svelte/src/compiler/utils/trim.ts
Lines 7 to 9 in d42ca04
svelte/src/compiler/utils/patterns.ts
Line 6 in d42ca04
/\s/
is looks equal with/[ \u00A0\u2009\u200C\u200D\u3000\t\n\r\f]/
,\u00A0\u2009\u200C\u200D\u3000
is unicode code of\ \&thinsp \‌ \‍  
.I think we can use
[ \t\n\r\f]
equals with[\u0020\t\n\r\f]
to solve this problem,\u0020
is standard space character we need skip.The test error of html space entities will be hided by
/\s/
in normalizeHtml. The reason is html space entities be replace to''
, so /\s/ need to replaced by[ \t\n\r\f]
and save html space entities in test too.svelte/test/helpers.ts
Lines 143 to 155 in d42ca04