Attempting to craft a custom HTML tag using JavaScript, I aimed to create the custom element with ES6 JavaScript syntax. The code devised for this task reads as follows:
customElements.define('neo-element', NeoElement);
function NeoElement (){
var ref = Reflect.construct(HTMLElement,[], this.constructor) ;
return ref;
};
NeoElement.prototype = Object.create(HTMLElement.prototype);
NeoElement.prototype.constructor = NeoElement;
NeoElement.prototype.connectedCallback = function(){
this.innerHTML = `<h1>Hello world</h1>`;
<neo-element></neo-element>
While it has been confirmed that NeoElement successfully extends HTMLElement, content is not appearing inside the <neo-element>
tags.
If anyone could review the code and advise on any missed elements in ES5 syntax, it would be greatly appreciated.