Skip to content

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

Closed
@treshugart

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions