Include the 'checked' property in snapshots and state resets.
This commit is contained in:
parent
8f0d9524ba
commit
7ca87b7bdd
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-form",
|
"name": "@tp/tp-form",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-form.js",
|
"main": "tp-form.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -250,6 +250,7 @@ class TpForm extends LitElement {
|
|||||||
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);
|
||||||
if (typeof item.control.reset === 'function') {
|
if (typeof item.control.reset === 'function') {
|
||||||
item.control.reset();
|
item.control.reset();
|
||||||
}
|
}
|
||||||
@ -279,6 +280,7 @@ class TpForm extends LitElement {
|
|||||||
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.value = item.control.value;
|
item.value = item.control.value;
|
||||||
|
item.checked = item.control.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._snapshot = JSON.stringify(this.serialize());
|
this._snapshot = JSON.stringify(this.serialize());
|
||||||
@ -295,7 +297,7 @@ class TpForm extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store copy of original value in case we want to reset the form.
|
// Store copy of original value in case we want to reset the form.
|
||||||
this._origValues.push({ control: target, value: this._copyValue(target.value, target) });
|
this._origValues.push({ control: target, value: this._copyValue(target.value, target), checked: this._copyValue(target.checked, target) });
|
||||||
|
|
||||||
// Stop propagation of the registration event.
|
// Stop propagation of the registration event.
|
||||||
// This allows for nested forms.
|
// This allows for nested forms.
|
||||||
@ -433,4 +435,4 @@ class TpForm extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.customElements.define('tp-form', TpForm);
|
window.customElements.define('tp-form', TpForm);
|
||||||
|
Loading…
Reference in New Issue
Block a user