From d670d5208379be6f2ff2fdc7186f9b097464f893 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 29 Sep 2023 12:33:23 +1000 Subject: [PATCH] catch bad selectors --- resources/js/components/SMForm.vue | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/resources/js/components/SMForm.vue b/resources/js/components/SMForm.vue index f0d8e31..728667b 100644 --- a/resources/js/components/SMForm.vue +++ b/resources/js/components/SMForm.vue @@ -37,15 +37,19 @@ watch( * Handle the user submitting the form. */ const submit = async function () { - inputs = Array.from(document.querySelectorAll(`#${id} input`)); + try { + inputs = Array.from(document.querySelectorAll(`#${id} input`)); - for (let i = inputs.length - 1; i >= 0; i--) { - const input = inputs[i] as HTMLInputElement; - if (!input.disabled) { - input.disabled = true; - } else { - inputs.splice(i, 1); + for (let i = inputs.length - 1; i >= 0; i--) { + const input = inputs[i] as HTMLInputElement; + if (!input.disabled) { + input.disabled = true; + } else { + inputs.splice(i, 1); + } } + } catch { + /* empty */ } if (await props.modelValue.validate()) {