nostr-web-components
Version:
collection of web components that provide quick access to basic nostr things
27 lines (26 loc) • 593 B
JavaScript
import { renderText } from "./text";
class NostrText extends HTMLElement {
static observedAttributes = ["content"];
constructor() {
super();
this.attachShadow({ mode: "open" });
}
connectedCallback() {
this.set();
}
attributeChangedCallback() {
this.set();
}
async set() {
const { shadowRoot } = this;
if (!shadowRoot)
return;
const content = this.getAttribute("content") || "";
shadowRoot.innerHTML = "";
renderText(shadowRoot, content);
}
}
window.customElements.define("nostr-text", NostrText);
export {
NostrText as default
};