I understand that the structure of a web component is something like this:
var template = document.createElement('template');
template.innerHTML = `
<style>
...
</style>
<div class="my-webcomp">
...
</div>
`;
class MyWebComp extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
connectedCallback() {...}
disconnectedCallback() {...}
}
window.customElements.define('my-webcomp', MyWebComp);
And I was wondering if there is a way to write the html code in template.innerHTML = `<HTML CODE>`;
in another file ".html" to have the benefit of the editor code recognition and not writing the code between ticks. I tried to use fetch() but couldn't quite get it to work.