diff options
-rw-r--r-- | src/htmx.js | 2 | ||||
-rw-r--r-- | test/core/ajax.js | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/htmx.js b/src/htmx.js index e6cd3892..35f99a42 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -2440,7 +2440,7 @@ return (function () { if (shouldInclude(elt)) { var name = getRawAttribute(elt,"name"); var value = elt.value; - if (elt.multiple) { + if (elt.multiple && elt.tagName === "SELECT") { value = toArray(elt.querySelectorAll("option:checked")).map(function (e) { return e.value }); } // include file inputs diff --git a/test/core/ajax.js b/test/core/ajax.js index 4dec14ec..0ca9e075 100644 --- a/test/core/ajax.js +++ b/test/core/ajax.js @@ -481,6 +481,33 @@ describe("Core htmx AJAX Tests", function(){ values.should.deep.equal({multiSelect:["m1", "m3", "m7", "m8"]}); }); + it('properly handles multiple email input', function() + { + var values; + this.server.respondWith("Post", "/test", function (xhr) { + values = getParameters(xhr); + xhr.respond(204, {}, ""); + }); + + var form = make('<form hx-post="/test" hx-trigger="click">' + + '<input id="multiEmail" name="multiEmail" multiple>'+ + '</form>'); + + form.click(); + this.server.respond(); + values.should.deep.equal({multiEmail: ''}); + + byId("multiEmail").value = 'foo@example.com'; + form.click(); + this.server.respond(); + values.should.deep.equal({multiEmail:"foo@example.com"}); + + byId("multiEmail").value = 'foo@example.com,bar@example.com'; + form.click(); + this.server.respond(); + values.should.deep.equal({multiEmail:"foo@example.com,bar@example.com"}); + }); + it('properly handles checkbox inputs', function() { var values; |