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

If Polymer() is not called almost immediately, the element is not initialised. #214

Closed
treshugart opened this issue Jul 19, 2013 · 2 comments

Comments

@treshugart
Copy link

Given the following element:

<polymer-element name="todo-list">
  <template>
    <form>
      <input id="title" type="text" value="{{ title }}" placeholder="New Todo Title">
      <button type="button" on-click="add">Add</button>
    </form>
    <ul>
      <template repeat="{{ todos }}">
        <li>{{ title }}</li>
      </template>
    </ul>
  </template>
  <script>
    setTimeout(function() {
      Polymer('todo-list', {
        title: 'asdf',
        todos: [],
        add: function() {
          this.todos.push({ title: this.title });
          this.$.title.value = '';
        }
      });
    }, 1000);
  </script>
</polymer-element>

The call to Polymer() will not initialise the element. I messed with the value and got it to happen some of the time around 5ms.

Due to this issue, you cannot use an asynchronous module loader if you want to use components within your element.

@sjmiles
Copy link
Contributor

sjmiles commented Jul 19, 2013

In [stable] it's required that the JavaScript execute before the constructs.

[master] branch should not have this issue.

@treshugart
Copy link
Author

Cool, I will try that. Thanks for being so responsive!

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

2 participants