Whitespaces are not trimmed in Text Node with `preserveWhitespaces: false`
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/compiler
Is this a regression?
Yes, the previous version in which this bug was not present was: ....No idea
Description
A clear and concise description of the problem...<!-- input -->
<span>
{{ 'text' }}
</span>
<!-- output -->
<span> {{ 'text' }} </span>
<!-- expected -->
<span>{{ 'text' }}</span>
There is no way to trim
the text.
π¬ Minimal Reproduction
https://stackblitz.com/edit/angular-ivy-pkkssbπ Your Environment
Angular Version:
Angular CLI: 9.1.1
Node: 12.18.0
OS: darwin x64
Angular: 9.1.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.1
@angular-devkit/build-angular 0.901.1
@angular-devkit/build-optimizer 0.901.1
@angular-devkit/build-webpack 0.901.1
@angular-devkit/core 9.1.1
@angular-devkit/schematics 9.1.1
@angular/cdk 9.2.1
@angular/cli 9.1.1
@angular/flex-layout 9.0.0-beta.29
@ngtools/webpack 9.1.1
@schematics/angular 9.1.1
@schematics/update 0.901.1
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
XDocument.Parse preserving whitespace when not asked to
"Not preserving whitespace" means that any text nodes that contain only whitespace will be ignored while loading the XDocument .
Read more >White Space and Significant White Space Handling when ...
To create white space nodes, set the PreserveWhitespace property to true. If the property is set to false, which is the default, white...
Read more >How whitespace is handled by HTML, CSS, and in the DOM
There will be some text nodes that contain only whitespace, and; Some text ... Most whitespace characters are ignored, not all of them...
Read more >State.ng2component - UI-Router
preserveWhitespaces } is set to false potentially superfluous whitespace ... removed (trimmed);; text nodes consisting of whitespaces only are removed (ex.
Read more >DOMDocument - Manual - PHP
Last child element or null . preserveWhiteSpace. Do not remove redundant white space. Default to true . Setting this to false has the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is on purpose, actually. Whitespace is significant in HTML but collapsed to a single whitespace Because of this, the following is equivalent when rendered:
However, the following would not be:
as it would join the two words together.
Two things to note with that tool:
As @pkozlowski-opensource mentioned, there is room for discussion here but I donβt think this would be a high priority for us.