monorepo/music-player/client/src/components/TextField.ts

24 lines
422 B
TypeScript
Raw Normal View History

export class TextField extends HTMLElement {
static get observedAttributes() {
return ["text"];
}
constructor() {
super();
}
get text(): string | null {
return this.getAttribute("text");
}
set text(text: string | null) {
if (text) {
this.setAttribute("text", text);
this.innerHTML = text;
} else {
this.removeAttribute("text");
this.innerHTML = "";
}
}
}