Skip to content

Commit

Permalink
refactor(form): change how querySelector gets built
Browse files Browse the repository at this point in the history
  • Loading branch information
DukeFerdinand committed Jan 18, 2025
1 parent d741883 commit 15f336b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions components/form/src/auro-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(', '));
}

/**
Expand Down

0 comments on commit 15f336b

Please sign in to comment.