Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class HelloElement extends HTMLElement {
connectedCallback() {
this.innerHTML = this.render('Nettleser: Hei');
render(text) {
return `<h1> ${text} </h1>`;
customElements.define('hello-element', HelloElement);
global.HTMLElement = class EmptyHTMLElement {};
const helloElement = new HelloElement();
const serverHtml = `
${helloElement.render('Server: Hei')}
function renderElement(elementConstructor, tagName, props) {
const element = new elementConstructor();
const html = element.render(props);
return `<${tagName}> ${html} </${tagName}>`;
const html = renderElement(HelloElement, 'hello-element', 'Server: Hei');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment