Reputation: 419
When defining custom elements, the API developer guide always passes the name of the custom element as the first argument to the Polymer()
function.
Polymer('my-element', {/*stuff*/});
In the Tutorial, however, the Polymer()
function is consistently called without the name and simply passed the prototype object.
Polymer({/*stuff*/});
As the Polymer()
function doesn't seem to be explicitly defined anywhere in the documentation I was just wondering what the recommendation is. Are there any pitfalls to leaving the name out or should you always pass it just to be safe?
Upvotes: 1
Views: 57
Reputation: 11027
You can omit the name argument to Polymer()
iff:
<script>
node containing the Polymer()
call is inside the matching <polymer-element>
nodeUpvotes: 3
Reputation: 978
In my opinion you should always declare the name of your polymer-element to make your code more readable, at least for others.
Nevertheless, it looks like you can skip the name and let Polymer do the detection. If I get it right Polymer looks for the name attribute of its first parent node.
https://github.com/Polymer/polymer-dev/blob/master/src/declaration/polymer.js#L20-29
I tried it on https://ele.io
and it worked for me.
Upvotes: 2