From 64451ea66a8005ef4d63ed4e5135869731efa109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Gl=C3=BCck?= Date: Fri, 21 Nov 2025 16:33:49 +0100 Subject: [PATCH 1/3] Improve input element selection logic allows something like this: FormDataJson.toJson($(':input:not(.no_filter,button,[name="pool[]"])','#filter'),{includeDisabled: true, uncheckedValue: 0}) --- src/form-data-json.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/form-data-json.ts b/src/form-data-json.ts index 851e060..39a135b 100644 --- a/src/form-data-json.ts +++ b/src/form-data-json.ts @@ -748,12 +748,17 @@ export default class FormDataJson { isValidInput: ((input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLElement) => boolean | undefined) | null = null, options: FormDataJsonOptionsToJson | FormDataJsonOptionsFromJson | FormDataJsonOptionsReset | FormDataJsonOptionsClear ): any { - const el = FormDataJson.getElement(checkEl) - if (!el) { - return [] + let inputs = null, el = null;; + if ((checkEl instanceof NodeList || checkEl instanceof Object) && checkEl.length==1) { // one element should be a form + const el = FormDataJson.getElement(checkEl); + if (!el) { + return []; + } + inputs = Array.from(el.querySelectorAll('select, textarea, input, button')); + } + else { // it is a list of elements + inputs = checkEl; } - - let inputs = Array.from(el.querySelectorAll('select, textarea, input, button')) // if we have a form with a name, we need to find all attributes that have a "form" attribute with that name as value as well if (options.includeLinkedFormElements && el instanceof HTMLFormElement && el.getAttribute('id')) { const formId = el.getAttribute('id') @@ -902,4 +907,4 @@ export default class FormDataJson { } return c } -} \ No newline at end of file +} From 1e28d552af33634d2350a3408cca8cb25c979ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Gl=C3=BCck?= Date: Tue, 25 Nov 2025 08:34:35 +0100 Subject: [PATCH 2/3] Refactor input selection logic for checkEl Refactor input handling to support jQuery objects and improve clarity. --- src/form-data-json.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/form-data-json.ts b/src/form-data-json.ts index 39a135b..23cee06 100644 --- a/src/form-data-json.ts +++ b/src/form-data-json.ts @@ -748,17 +748,18 @@ export default class FormDataJson { isValidInput: ((input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLElement) => boolean | undefined) | null = null, options: FormDataJsonOptionsToJson | FormDataJsonOptionsFromJson | FormDataJsonOptionsReset | FormDataJsonOptionsClear ): any { - let inputs = null, el = null;; - if ((checkEl instanceof NodeList || checkEl instanceof Object) && checkEl.length==1) { // one element should be a form + let inputs = null; + if (checkEl.jquery && checkEl.length>1) { + const el = null; + inputs = checkEl.toArray(); + } + else { const el = FormDataJson.getElement(checkEl); if (!el) { return []; } inputs = Array.from(el.querySelectorAll('select, textarea, input, button')); } - else { // it is a list of elements - inputs = checkEl; - } // if we have a form with a name, we need to find all attributes that have a "form" attribute with that name as value as well if (options.includeLinkedFormElements && el instanceof HTMLFormElement && el.getAttribute('id')) { const formId = el.getAttribute('id') From 2a4b5d074ef557aa20236689cefd04cd597ad92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Gl=C3=BCck?= Date: Tue, 25 Nov 2025 08:49:35 +0100 Subject: [PATCH 3/3] Update input initialization logic in form-data-json Refactor input handling to support array of elements. --- src/form-data-json.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/form-data-json.ts b/src/form-data-json.ts index 23cee06..6332c6c 100644 --- a/src/form-data-json.ts +++ b/src/form-data-json.ts @@ -748,8 +748,11 @@ export default class FormDataJson { isValidInput: ((input: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLElement) => boolean | undefined) | null = null, options: FormDataJsonOptionsToJson | FormDataJsonOptionsFromJson | FormDataJsonOptionsReset | FormDataJsonOptionsClear ): any { - let inputs = null; - if (checkEl.jquery && checkEl.length>1) { + let inputs = []; + if (Array.isArray(checkEl)) { + inputs = checkEl; + } + else if (checkEl.jquery && checkEl.length>1) { const el = null; inputs = checkEl.toArray(); }