Make sure falsy values are preserved
This commit is contained in:
@@ -324,8 +324,8 @@ class TpForm extends LitElement {
|
|||||||
reset() {
|
reset() {
|
||||||
for (let i = 0, li = this._origValues.length; i < li; ++i) {
|
for (let i = 0, li = this._origValues.length; i < li; ++i) {
|
||||||
const item = this._origValues[i];
|
const item = this._origValues[i];
|
||||||
item.control.value = this._copyValue(item.value || null, item.control);
|
item.control.value = this._copyValue(item.value ?? null, item.control);
|
||||||
item.control.checked = this._copyValue(item.checked || null, item.control);
|
item.control.checked = this._copyValue(item.checked ?? null, item.control);
|
||||||
if (typeof item.control.reset === 'function') {
|
if (typeof item.control.reset === 'function') {
|
||||||
item.control.reset();
|
item.control.reset();
|
||||||
}
|
}
|
||||||
@@ -445,7 +445,7 @@ class TpForm extends LitElement {
|
|||||||
|
|
||||||
_copyValue(value, control) {
|
_copyValue(value, control) {
|
||||||
if (control.defaultValue !== undefined || control.hasAttribute('default-value')) {
|
if (control.defaultValue !== undefined || control.hasAttribute('default-value')) {
|
||||||
value = control.defaultValue || control.getAttribute('default-value');
|
value = control.defaultValue ?? control.getAttribute('default-value');
|
||||||
}
|
}
|
||||||
|
|
||||||
return clone(value);
|
return clone(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user