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:
parent
f11f94fafc
commit
33fd1bef09
3 changed files with 5 additions and 25 deletions
5
.changeset/hungry-mirrors-stare.md
Normal file
5
.changeset/hungry-mirrors-stare.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/form-core': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
remove name property check on lion field for forward compatibility with Form participation api
|
||||||
|
|
@ -156,10 +156,6 @@ const FormRegistrarMixinImplementation = superclass =>
|
||||||
// 2. Add children as object key
|
// 2. Add children as object key
|
||||||
if (this._isFormOrFieldset) {
|
if (this._isFormOrFieldset) {
|
||||||
const { name } = child;
|
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) {
|
if (name === this.name) {
|
||||||
console.info('Error Node:', child); // eslint-disable-line no-console
|
console.info('Error Node:', child); // eslint-disable-line no-console
|
||||||
throw new TypeError(`You can not have the same name "${name}" as your parent`);
|
throw new TypeError(`You can not have the same name "${name}" as your parent`);
|
||||||
|
|
|
||||||
|
|
@ -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 () => {
|
it('throws if name is the same as its parent', async () => {
|
||||||
const orig = console.info;
|
const orig = console.info;
|
||||||
console.info = () => {};
|
console.info = () => {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue