Reputation: 1460
Question 1:
The below code works in polymer. I don't quite understand how. I didn't have to do something like var el = new Element()
or I didn't have append it to the document explicitly.
Question 2: How can I eliminate the <my-element></my-element>
tag?
MyElement.html
// After Importing all the necesarry files
var Element= Polymer({
is: 'my-element'
created: function (){
this.textContent = "My Element"
},
});
index.html (After importing all necessary files)
<body>
<my-element></my-element>
</body>
Upvotes: 0
Views: 39
Reputation: 2038
Upvotes: 0
Reputation: 1842
You can if you want,
// create an instance with createElement:
var el1 = document.createElement('my-element');
// ... or with the constructor:
var el2 = new MyElement();
Ref. https://www.polymer-project.org/2.0/docs/devguide/registering-elements#register-element
But, the beauty is the tag itself. More to read on custom elements,
https://www.polymer-project.org/2.0/docs/devguide/custom-elements https://www.webcomponents.org/introduction#specifications
Upvotes: 0