fix(lion-field): remove name property exception to align with platform

fix(lion-field): remove name property check for forward compatibility with Form participation api

Co-authored-by: Thijs Louisse <t_louisse@hotmail.com>
This commit is contained in:
palash2601 2022-05-10 14:50:15 +02:00 committed by GitHub
parent f11f94fafc
commit 33fd1bef09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 25 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/form-core': minor
---
remove name property check on lion field for forward compatibility with Form participation api

View file

@ -156,10 +156,6 @@ const FormRegistrarMixinImplementation = superclass =>
// 2. Add children as object key
if (this._isFormOrFieldset) {
const { name } = child;
if (!name) {
console.info('Error Node:', child); // eslint-disable-line no-console
throw new TypeError('You need to define a name');
}
if (name === this.name) {
console.info('Error Node:', child); // eslint-disable-line no-console
throw new TypeError(`You can not have the same name "${name}" as your parent`);

View file

@ -133,27 +133,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
]);
});
it('throws if an element without a name tries to register', async () => {
const orig = console.info;
console.info = () => {};
let error;
const el = /** @type {FormGroup} */ (await fixture(html`<${tag}></${tag}>`));
try {
// we test the api directly as errors thrown from a web component are in a
// different context and we can not catch them here => register fake elements
el.addFormElement(
/** @type {HTMLElement & import('../../types/FormControlMixinTypes').FormControlHost} */ ({}),
);
} catch (err) {
error = err;
}
expect(error).to.be.instanceOf(TypeError);
expect(/** @type {TypeError} */ (error).message).to.equal('You need to define a name');
console.info = orig; // restore original console
});
it('throws if name is the same as its parent', async () => {
const orig = console.info;
console.info = () => {};