From 5dd077a58692722ef76987e3e0196b1104c8e123 Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 17 Jan 2025 16:57:28 -0800 Subject: [PATCH] refactor(form): change how querySelector gets built --- components/form/src/auro-form.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/components/form/src/auro-form.js b/components/form/src/auro-form.js index c7f2f7ee..ea66939c 100644 --- a/components/form/src/auro-form.js +++ b/components/form/src/auro-form.js @@ -208,11 +208,25 @@ export class AuroForm extends LitElement { * @returns {NodeList} */ queryAuroElements() { - const formElementQuery = AuroForm.formElementTags.map((tag) => `${tag}[name], [${tag}][name]`); - const submitterQuery = AuroForm.buttonElementTags.map((tag) => `${tag}[type=submit], [${tag}][type=submit]`); - const resetButtonQuery = AuroForm.buttonElementTags.map((tag) => `${tag}[type=reset], [${tag}][type=reset]`); + const queries = [ + [ + AuroForm.formElementTags, + '[name]' + ], + [ + AuroForm.buttonElementTags, + '[type=submit]' + ], + [ + AuroForm.buttonElementTags, + '[type=reset]' + ] + ]; - return this.querySelectorAll(formElementQuery.concat(submitterQuery, resetButtonQuery).join(', ')); + return this.querySelectorAll(queries.flatMap(([ + tags, + extraAttributes + ]) => tags.map((tag) => `${tag}${extraAttributes}, [${tag}]${extraAttributes}`)).join(', ')); } /**