Skip to content

Commit d86e6b5

Browse files
committed
Ensure only one <form> is synced per instance
1 parent dd1741c commit d86e6b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class OptionsSync<UserOptions extends Options> {
172172
The form fields' `name` attributes will have to match the option names.
173173
*/
174174
async syncForm(form: string | HTMLFormElement): Promise<void> {
175+
this.stopSyncForm();
175176
this._form = form instanceof HTMLFormElement
176177
? form
177178
: document.querySelector<HTMLFormElement>(form)!;
@@ -192,7 +193,7 @@ class OptionsSync<UserOptions extends Options> {
192193
/**
193194
Removes any listeners added by `syncForm`
194195
*/
195-
async stopSyncForm(): Promise<void> {
196+
stopSyncForm(): void {
196197
if (this._form) {
197198
this._form.removeEventListener('input', this._handleFormInput);
198199
this._form.removeEventListener('submit', this._handleFormSubmit);

0 commit comments

Comments
 (0)