IE8 blows up on undefined values #753

Closed
morphar opened this Issue Feb 25, 2014 · 4 comments

Comments

Projects
None yet
4 participants

morphar commented Feb 25, 2014

I haven't tested in IE9+ or IE7-
Everything works fine in newer Safari/Chrome...

Assuming this data:

var users = [{ id: 1, name: 'user1' }, { id: 2, name: 'user2' }];

And a template containing something like this:

<ul>
  {{#if users}}
    {{#each users}}
      <li title="{{userName}}">{{name}}</li>
      <li>-</li>
    {{/each}}
  {{/if}}
</ul>

What I get is parts of the template in return, it seems extremely random what is removed.
Though any single case will remove the same template code every time.

Collaborator

kpdecker commented Feb 25, 2014

Can you create a fiddle demonstrating the issue?

If i understand right way, here is the fiddle example but i cant test it on IE8 because i dont have one. http://jsfiddle.net/ghtzg/

ef2k commented Feb 25, 2014

That fiddle seems to be working fine in IE8 (Windows 7).
screen shot 2014-02-25 at 3 08 10 pm

morphar commented Mar 2, 2014

So sorry about this one!

It was in fact due to html5 tags rendered and put into the dom, after document load.

Everything worked fine with html5shim, handlebars and jQuery, but wrestling some templates by pulling out html with jQuery, then doing some stuff to the str, compiling and calling the template and finally re-inserting into the dom caused the html5 tags to blow up everything.

In ie8 the html5shim changes e.g.: <article>bla</article> to <:article>bla<:/article> or even &lt;:article&gt;bla&lt;:/article&gt;.
So I figured out, I have to also fix incorrect tags, something like this:

var tmplStr = template(data);
tmplStr = tmplStr.replace(/&lt;(\/|.{0}):(.+?)&gt;/ig, '<$1$2>');
tmplStr = tmplStr.replace(/<(\/|.{0}):([^>]+)>/g, '<$1$2>');

So... It was a jQuery/IE8/html5shim thing.

Thanks for trying to figure it out and sorry for not doing the fiddle first!

@morphar morphar closed this Mar 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment