chore(form-core): make testing form registration easier

This commit is contained in:
Thijs Louisse 2022-04-06 18:12:47 +02:00
parent 355aabc02c
commit d9d88b7f55
3 changed files with 11 additions and 0 deletions

View file

@ -20,6 +20,7 @@
"src", "src",
"test", "test",
"test-helpers", "test-helpers",
"test-suites",
"translations", "translations",
"types" "types"
], ],

View file

@ -42,6 +42,14 @@ const FormRegisteringMixinImplementation = superclass =>
disconnectedCallback() { disconnectedCallback() {
super.disconnectedCallback(); super.disconnectedCallback();
this.__unregisterFormElement();
}
/**
* Putting this in a separate method makes testing easier
* @private
*/
__unregisterFormElement() {
if (this._parentFormGroup) { if (this._parentFormGroup) {
this._parentFormGroup.removeFormElement(/** @type {* & FormRegisteringHost} */ (this)); this._parentFormGroup.removeFormElement(/** @type {* & FormRegisteringHost} */ (this));
} }

View file

@ -14,6 +14,8 @@ export declare class FormRegisteringHost {
* ChoiceGroup * ChoiceGroup
*/ */
protected _parentFormGroup: FormRegistrarHost | undefined; protected _parentFormGroup: FormRegistrarHost | undefined;
private __unregisterFormElement: void;
} }
export declare function FormRegisteringImplementation<T extends Constructor<LitElement>>( export declare function FormRegisteringImplementation<T extends Constructor<LitElement>>(