Skip duplicate user started and execute triggers

This commit is contained in:
Taras Kushnir
2025-11-29 13:49:31 +01:00
parent 3ac40d043d
commit cc94c898cd
2 changed files with 11 additions and 1 deletions

View File

@@ -358,6 +358,11 @@ export class CaptchaWidget {
* @returns {Promise<never>} promise intentionally does not resolve so that the form can be submitted via the callbacks
*/
execute() {
if (this._apiTriggered && (STATE_ERROR !== this._state)) {
this.trace(`skipping duplicate execute event handler`);
return new Promise(() => { });
}
this.trace(`execute event handler. state=${this._state}`);
this._apiTriggered = true;
@@ -373,6 +378,11 @@ export class CaptchaWidget {
event.stopPropagation();
}
if (this._userStarted && (STATE_ERROR !== this._state)) {
this.trace('skipping duplicate onChecked handler')
return;
}
this.trace(`onChecked event handler. state=${this._state}`);
this._userStarted = true;

View File

@@ -4,7 +4,7 @@
"type": "git",
"url": "git+https://github.com/PrivateCaptcha/PrivateCaptcha.git"
},
"version": "0.0.16",
"version": "0.0.17",
"main": "index.js",
"type": "module",
"private": false,