angular
angular copied to clipboard
Corner cases in new preserve whitespace
(Tracking Issue For Now)
<div [ngSwitch]="'case-' + switchCase">
<template ngSwitchCase="case-one">first case</template>
<template ngSwitchCase="case-two">second case</template>
<template ngSwitchDefault>default case</template>
</div>
produces first case <whitespace here> instead of the expected <div>first case</div>.
I see various other edge cases around <template> usage.
Currently NgSwitch renders each active template in their own respective view container (at the location of the <template> tag). I thought we could a) optimize NgSwitch, and b) fix this issue by making it render all active templates in a single view container instead.
It turns out this would be breaking, and a feature regression, since the current approach allows any ngSwitchCase template to be nested within additional DOM that is always present.
<div [ngSwitch]="'case-' + switchCase">
<div>
This text will always show, even when the following case doesn't!
<template ngSwitchCase="case-one">first case</template>
</div>
<template ngSwitchCase="case-two">second case</template>
<template ngSwitchDefault>default case</template>
</div>