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

Safari bug when rendering a table using nested loops #700

Closed
kmurph73 opened this issue Aug 12, 2014 · 8 comments
Closed

Safari bug when rendering a table using nested loops #700

kmurph73 opened this issue Aug 12, 2014 · 8 comments
Assignees

Comments

@kmurph73
Copy link

JS Bin example

If I try to render a table using nested loops, like so:

<table>
  <template repeat="{{ row in rows }}">
    <tr>
      <template repeat="{{ cell in row }}">
        <td>{{cell}}</td>
      </template>
    </tr>
  </template>
</table>

it renders just fine in Chrome/FF, but not Safari (haven't tested IE). It seems to be specific to the tr/td tags -- if I turn them into divs, it renders in Safari. Thanks!

@sorvell
Copy link
Contributor

sorvell commented Aug 12, 2014

This type of syntax is unsupported where the <template> element is polyfilled (this is only Safari and IE!). You'll need to use

<tr template repeat="{{ row in rows }}">

There's more info here: http://www.polymer-project.org/docs/polymer/databinding-compat.html#elements-that-cant-contain-a-template

@sorvell sorvell closed this as completed Aug 12, 2014
@kmurph73
Copy link
Author

Odd, when I change the JS Bin code to adhere to the compatibility recommendations, it breaks in FF and Safari. See here.

Interestingly it doesn't do this when I run an app locally using the same syntax. However, it does when I vulcanize said app!

I created a repo that reproduces the issue: https://github.com/shmay/polymer-td-repeat-issue

@sorvell
Copy link
Contributor

sorvell commented Aug 14, 2014

@jmesserly John, would you mind taking a look at this one?

@sorvell sorvell assigned jmesserly and unassigned sorvell Aug 14, 2014
@sorvell
Copy link
Contributor

sorvell commented Aug 14, 2014

The behavior now seems broken in Chrome as well: http://jsbin.com/litosoyepina/4/edit

@sorvell
Copy link
Contributor

sorvell commented Aug 14, 2014

The above breakage is only on master and I think it's due to TemplateBinding now being loaded after DOMContentLoaded. Let me sort that part out.

@sorvell sorvell assigned sorvell and unassigned jmesserly Aug 14, 2014
@sorvell
Copy link
Contributor

sorvell commented Aug 14, 2014

OK, identified the problem. It's currently possible for Polymer to attempt to stamp a template before the TemplateBinding library has decorated the template. We'll get this fixed in the next release, but until then I can give you a workaround. You'll need to implement the instanceTemplate method on your element like so:

instanceTemplate: function(template) {
  HTMLTemplateElement.decorate(template);
  return this.super(arguments);
}

Here's a jsbin that works:

http://jsbin.com/litosoyepina/6/edit

@sorvell
Copy link
Contributor

sorvell commented Aug 14, 2014

We now ensure the template is properly decorated before stamping shadowRoot. Fixed via googlearchive/polymer-dev@73801fc.

@sorvell sorvell closed this as completed Aug 14, 2014
@kmurph73
Copy link
Author

Excellent, thank you!

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