24 lines
422 B
TypeScript
24 lines
422 B
TypeScript
|
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 = "";
|
||
|
}
|
||
|
}
|
||
|
}
|