angular icon indicating copy to clipboard operation
angular copied to clipboard

Corner cases in new preserve whitespace

Open matanlurey opened this issue 6 years ago • 2 comments

(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>.

matanlurey avatar May 08 '18 17:05 matanlurey

I see various other edge cases around <template> usage.

matanlurey avatar May 08 '18 17:05 matanlurey

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>

leonsenft avatar Oct 09 '18 23:10 leonsenft