From 33fd1bef09654ab6346774d7bb5b57db2849c67d Mon Sep 17 00:00:00 2001 From: palash2601 Date: Tue, 10 May 2022 14:50:15 +0200 Subject: [PATCH] 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 --- .changeset/hungry-mirrors-stare.md | 5 +++++ .../src/registration/FormRegistrarMixin.js | 4 ---- .../form-group/FormGroupMixin.suite.js | 21 ------------------- 3 files changed, 5 insertions(+), 25 deletions(-) create mode 100644 .changeset/hungry-mirrors-stare.md diff --git a/.changeset/hungry-mirrors-stare.md b/.changeset/hungry-mirrors-stare.md new file mode 100644 index 000000000..2b3f5df37 --- /dev/null +++ b/.changeset/hungry-mirrors-stare.md @@ -0,0 +1,5 @@ +--- +'@lion/form-core': minor +--- + +remove name property check on lion field for forward compatibility with Form participation api diff --git a/packages/form-core/src/registration/FormRegistrarMixin.js b/packages/form-core/src/registration/FormRegistrarMixin.js index 60abcd31d..e97de5c07 100644 --- a/packages/form-core/src/registration/FormRegistrarMixin.js +++ b/packages/form-core/src/registration/FormRegistrarMixin.js @@ -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`); diff --git a/packages/form-core/test-suites/form-group/FormGroupMixin.suite.js b/packages/form-core/test-suites/form-group/FormGroupMixin.suite.js index f1e107109..70061675f 100644 --- a/packages/form-core/test-suites/form-group/FormGroupMixin.suite.js +++ b/packages/form-core/test-suites/form-group/FormGroupMixin.suite.js @@ -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}>`)); - 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 = () => {};