New elements in Polymer are defined through:
<polymer-element name="el-name">
<template></template>
<script>
Polymer("el-name", { });
</script>
</polymer-element>
What problems are stopping Polymer from getting the element name through document.querySelector("polymer-element").name
?
If you're element definition is in an HTML Import, you don't need to include the name. This isn't documented yet, but you can find more info here: https://github.com/Polymer/docs/issues/351
One reason for passing it as the first arg is because folks wanted to separate out their JS from the element definition into a new file (eg use <script src="">
). The name to the constructor points Polymer to the correct definition to register.
http://www.polymer-project.org/docs/polymer/polymer.html#altregistration
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.