emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.46k stars 4.21k forks source link

[Bug] Whitespace issue in HBS 2 #19603

Open boris-petrov opened 3 years ago

boris-petrov commented 3 years ago

🐞 Describe the Bug

Check the reproduction.

🔬 Minimal Reproduction

Component foo:

{{#each (array 1 2) as |item index|~}}
  {{~#if index}},{{/if}}{{yield item}}
{{~/each}}

Use it:

(<span>
  {{#foo as |item|}}
    {{~item~}}
  {{/foo}}
</span>)

This renders:

( 1,2)

😕 Actual Behavior

Note the missing space before the closing parenthesis. There is a new line before the closing span tag so there should be a space.

Changing the usage to be something like:

(<span>
  {{#foo as |item|}}
    {{item}}
  {{/foo}}
</span>)

Fixes the issue. The space appears correctly.

🤔 Expected Behavior

A space to be there.

🌍 Environment

lifeart commented 2 years ago

may be related to https://github.com/glimmerjs/glimmer-vm/pull/1168

MelSumner commented 2 years ago

@didoo noticed this issue in one of our templates today. Wondering what the plan is to resolve?

didoo commented 2 years ago

I have created a small repro code here: https://ember-twiddle.com/3575bcb7229f8c689339408eb0dcbed2 in which, if you follow the content, I tried to explain what the issue is.

boris-petrov commented 1 year ago

A similar issue:

(
  {{~#foo as |item|}}
    {{! @glint-expect-error }}
    {{~item}}
  {{~/foo~}}
)

Renders (1,2). It should, however, be ( 1, 2) because there is no whitespace-removal before the comment.