-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext-input.js
More file actions
31 lines (25 loc) · 812 Bytes
/
text-input.js
File metadata and controls
31 lines (25 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class TextInput extends HTMLElement {
constructor() {
super();
this._shadow = this.attachShadow({mode: "open"});
this.label = document.createElement("label");
this.label.setAttribute("class", "d-flex flex-justify-between flex-items-center py-1");
this._shadow.appendChild(this.label);
this._name = document.createTextNode("");
this.label.appendChild(this._name);
this._input = document.createElement("input");
this._input.setAttribute("type", "text");
this.label.appendChild(this._input);
}
static get observedAttributes() {
return ["name"];
}
attributeChangedCallback(name, oldValue, newValue) {
switch (name) {
case "name":
this._name.nodeValue = newValue;
break;
}
}
}
customElements.define("text-input", TextInput);