Published
Edited
Apr 16, 2021
2 stars
Insert cell
Insert cell
Insert cell
tag_name = "wc-example" //your element tag name
Insert cell
mutable iterations = 0 //as we cant redefine the custom element, we increment it on each iteration
Insert cell
nickname = tag_name + "-" + iterations
Insert cell
element_maker = {
mutable iterations = mutable iterations + 1;
const nickname = tag_name + "-" + mutable iterations;
/*
*/
const { LitElement, html } = lit;
class MyElement extends LitElement {
render() {
//make some edits here for tesing!
return html`
<div>Hello from My Element!</div>
`;
}
}
/*
*/

!window.customElements.get(nickname) &&
window.customElements.define(nickname, MyElement);

return MyElement;
}
Insert cell
html`<${nickname}></${nickname}>`
Insert cell
element_maker.toString()
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more