From b3516473134d8c6e22ee9dd897ab6065228ddf84 Mon Sep 17 00:00:00 2001 From: Biser Stoilov Date: Sat, 17 Feb 2018 19:14:35 +0200 Subject: [PATCH] Support radio, checkbox and select in form --- lib/proto/attach-form.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/proto/attach-form.js b/lib/proto/attach-form.js index fa4d6af..18b5a32 100644 --- a/lib/proto/attach-form.js +++ b/lib/proto/attach-form.js @@ -50,9 +50,27 @@ var formAction = function(el, event) { // jscs:disable disallowImplicitTypeConversion if (!!element.name && element.attributes !== undefined && element.tagName.toLowerCase() !== "button") { // jscs:enable disallowImplicitTypeConversion - if ((element.attributes.type !== "checkbox" && element.attributes.type !== "radio") || element.checked) { - paramObject.push({name: encodeURIComponent(element.name), value: encodeURIComponent(element.value)}) - } + var elementType; + if (element.tagName.toLowerCase() === "input") { + if (element.type === "text") { + elementType = "input"; + } + if (element.type === "checkbox") { + elementType = "checkbox"; + } + if (element.type === "radio") { + elementType = "radio"; + } + } + if (element.tagName.toLowerCase() === "select") { + elementType = "select"; + } + if ((elementType !== "checkbox" && elementType !== "radio") || element.checked) { + paramObject.push({ + name: encodeURIComponent(element.name), + value: encodeURIComponent(element.value) + }) + } } }