mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-14 19:44:03 +00:00
fix: initialize DOM elements only when executing methods/in pages that
contain those elements
SUMMARY
Trying to grab elements globally in a script results in it trying to
initialize in all pages. When the element is absent, the script
fails and JavaScript crashes.
This commit is contained in:
@@ -25,10 +25,10 @@ import { validate, FORM } from "../../add/novice/ts/form";
|
||||
const SUBMIT_BTN = <HTMLButtonElement>(
|
||||
document.querySelector(".sitekey-form__submit")
|
||||
);
|
||||
const key = SUBMIT_BTN.dataset.sitekey;
|
||||
const submit = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
|
||||
const key = SUBMIT_BTN.dataset.sitekey;
|
||||
const formUrl = getFormUrl(FORM);
|
||||
const payload = {
|
||||
pattern: validate(e),
|
||||
|
||||
Reference in New Issue
Block a user