Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember JS 1.8.1 + Chrome - Additional whitespaces

I have a problem in the app that I'm working on, since I upgraded EmberJS from 1.6.1 to 1.8.1. It happens only under Chrome. The issue is that somehow my templates are being rendered with lots of additional spaces surrounding each html node. So to say... instead of:

<div>
[tab]<span>Hello</span>
</div>

I get something like this rendered:

<div>[ ][ ][ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ]<span>Hello</span>[ ][ ][ ][ ]
</div>[ ][ ][ ][ ]

Or maybe you'll see it here: An example

That obviously breaks styling a lot. The funny thing is that when I remove at least one space from such strange construct, then magically the styling for given section is back (even though other spaces are still there).

Just to mention. I'm using ember-grunt-templates 0.4.21 to compile. I know that there are new versions of it (0.4.23 I think...) and I tried to update it as well, but it doesn't help.

I know that there was a mention here: http://emberjs.com/blog/2014/11/04/ember-1-8-1-released.html about whitespace issue in Chrome, but it says that people get the opposite effect of missing spaces due to some bug in Chrome. ;> Is my Chrome instance consuming and gathering all other people whitespaces or what? :-)

Anyone encountered similar issue (like mine, not like the one mentioned in Ember release notes)? Anyone knows how to get rid of this?

Update 1:

I tried to update to:

  • Ember 1.9
  • Handlebars 2.0
  • Grunt-Ember-Templates 0.5 alpha

That fixes few occurrences of whitespace issue, but some are still present. I.e. that results in a space in front of rendered text:

<span class="someClass">
    {{#if condition}}{{someProperty}}{{else}}{{t 'translationKey'}}{{/if}}
</span>

And that doesn't:

<span class="someClass">{{#if condition}}{{someProperty}}{{else}}{{t 'translationKey'}}{{/if}}</span>

:-|

like image 211
Imp Avatar asked Dec 16 '14 09:12

Imp


1 Answers

It turns out to be a line ending encoding related bug. I reported that issue here: https://github.com/emberjs/ember.js/issues/9945

Solution is to make sure that line ending encoding has to be Unix-like.

like image 126
Imp Avatar answered Oct 23 '22 16:10

Imp