Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE8 blows up on undefined values #753

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

IE8 blows up on undefined values #753

morphar opened this issue Feb 25, 2014 · 4 comments

Comments

@morphar
Copy link

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.

@kpdecker
Copy link
Collaborator

Can you create a fiddle demonstrating the issue?

@ramesaliyev
Copy link

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
Copy link

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants