Nils Werner
Nils Werner

Reputation: 36765

Traverse DOM tree of Polymer element

Is it possible to traverse the DOM subtree when I am using a Polymer element custom-element like

<polymer-element name="custom-element" attributes="something">
  <template>
  </template>

  <script>
  // access ul and li from the actual DOM here.
  </script>
</polymer-element>

<body>
  <custom-element something="foo">
    <ul>
      <li>Bar</li>
      <li>Hello</li>
    </ul>
  </custom-element>
</body>

I want to be able to parameterize my Polymer element using the markup that's wrapped by it.

Upvotes: 0

Views: 331

Answers (1)

Nils Werner
Nils Werner

Reputation: 36765

Actually, this.children allows access to them.

<polymer-element name="custom-element" attributes="something">
  <template>
  </template>

  <script>
  Polymer({
    created: function() {
      console.log(this.children);
    }
  });
  </script>
</polymer-element>

Upvotes: 1

Related Questions