-
Notifications
You must be signed in to change notification settings - Fork 25k
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
control flow is adding unnecessary whitespace #56323
Comments
Your The equivalent of You're probably looking for something like:
|
@JeanMeche, stackblitz includes the ![]() |
What you're seeing is related to the
|
Since, we ran migrator on our entire codebase, it is difficult to add comment block trick or span wrappers. Will check out the preserveWhitespace option |
So HTML doesn't care about whitespace between HTML elements, but it does in between text nodes. It'll collapse multiple spaces between text nodes into a single whitespace when rendered. So this is happening because the for loop is rendering over multiple text nodes. The migration auto formatting isn't perfect and can't account for every use case. This seems to be a very rare one. So my suggestion is to just disable the auto formatting for targeted files with this sort of syntax. You'll likely still have some whitespace issues, but it may resolve this one. Detecting this kind of use case would be complicated and the amount of effort to address this rare use case would be high. So I'm going to close this for now since there's workarounds. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
common
Is this a regression?
Yes
Description
After migrating to the new control flow syntax, we have noticed that it adds whitespace in the DOM, which can cause issues. In the Stackblitz example below, the
ngFor
syntax does not add any extra space after the alphabet, whereas the new control flow syntax adds an extra space when displaying the alphabets.Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-ecubsf?file=src%2Fnew-syntax.component.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: