Added value support for files, you can't set the value to a file, but you can set it to null to clear the current file and reflect to get the file value. Fixed html template deconstructing by making it remove the elements it created.
This commit is contained in:
@ -215,6 +215,8 @@ class IgniteTemplate {
|
||||
newValue = this.element.checked;
|
||||
} else if (type == "number") {
|
||||
newValue = Number(this.element.value);
|
||||
} else if (type == "file") {
|
||||
newValue = this.element.files && this.element.files.length > 0 ? this.element.files[0] : null;
|
||||
} else if (this.element.hasAttribute("contenteditable") && this.element.getAttribute("contenteditable").toLowerCase().trim() == "true") {
|
||||
newValue = this.element.textContent;
|
||||
} else {
|
||||
@ -1389,6 +1391,10 @@ class IgniteTemplate {
|
||||
if (this.element.checked != newValue) {
|
||||
this.element.checked = newValue;
|
||||
}
|
||||
} else if (this.element.hasAttribute("type") && this.element.getAttribute("type").toLowerCase().trim() == "file") {
|
||||
if (newValue == null) {
|
||||
this.element.value = newValue;
|
||||
}
|
||||
} else if (this.element.hasAttribute("contenteditable") && this.element.getAttribute("contenteditable").toLowerCase().trim() == "true") {
|
||||
if (this.element.textContent != newValue.toString()) {
|
||||
this.element.textContent = newValue.toString();
|
||||
@ -2172,6 +2178,17 @@ class html extends IgniteTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
deconstruct() {
|
||||
//If we have elements, remove all of them from the DOM.
|
||||
if (this.elements) {
|
||||
this.elements.forEach(element => element.remove());
|
||||
|
||||
this.elements.length = 0;
|
||||
}
|
||||
|
||||
super.deconstruct();
|
||||
}
|
||||
|
||||
onPropertyChanged(oldValue, newValue) {
|
||||
//Update our code to the new value from the property.
|
||||
this.code = newValue;
|
||||
|
Reference in New Issue
Block a user