UNPKG

nostr-web-components

Version:

collection of web components that provide quick access to basic nostr things

31 lines (22 loc) 585 B
import { renderText } from './text' export default 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 as any as HTMLElement, content) } } window.customElements.define('nostr-text', NostrText)