Merge pull request #426 from danychi/fix/serialize-group-bug
Fix bug in serializeGroup and serializeElements
This commit is contained in:
commit
dfe3d6834e
2 changed files with 19 additions and 2 deletions
|
|
@ -210,7 +210,7 @@ export class LionFieldset extends FormRegistrarMixin(
|
|||
serializedValues[name] = this.__serializeElements(element);
|
||||
} else {
|
||||
const serializedValue = this.__serializeElement(element);
|
||||
if (serializedValue) {
|
||||
if (serializedValue || serializedValue === 0) {
|
||||
serializedValues[name] = serializedValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ export class LionFieldset extends FormRegistrarMixin(
|
|||
const serializedValues = [];
|
||||
elements.forEach(element => {
|
||||
const serializedValue = this.__serializeElement(element);
|
||||
if (serializedValue) {
|
||||
if (serializedValue || serializedValue === 0) {
|
||||
serializedValues.push(serializedValue);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -596,6 +596,23 @@ describe('<lion-fieldset>', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('0 is a valid value to be serialized', async () => {
|
||||
const fieldset = await fixture(html`
|
||||
<${tag}>
|
||||
<${childTag} name="price"></${childTag}>
|
||||
</${tag}>`);
|
||||
await nextFrame();
|
||||
fieldset.formElements.price.modelValue = 0;
|
||||
expect(fieldset.serializeGroup()).to.deep.equal({ price: 0 });
|
||||
});
|
||||
|
||||
it('__serializeElements serializes 0 as a valid value', async () => {
|
||||
const fieldset = await fixture(html`<${tag}></${tag}>`);
|
||||
await nextFrame();
|
||||
const elements = [{ serializedValue: 0 }];
|
||||
expect(fieldset.__serializeElements(elements)).to.deep.equal([0]);
|
||||
});
|
||||
|
||||
it('form elements which are not disabled', async () => {
|
||||
const fieldset = await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
||||
await nextFrame();
|
||||
|
|
|
|||
Loading…
Reference in a new issue