Skip to content

Commit

Permalink
fix #33 - include empty input values in request
Browse files Browse the repository at this point in the history
  • Loading branch information
carson committed May 23, 2020
1 parent f86ee98 commit 468c405
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8,335 deletions.
2 changes: 1 addition & 1 deletion src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ var htmx = htmx || (function () {
if (shouldInclude(elt)) {
var name = getRawAttribute(elt,"name");
var value = elt.value;
if (name && value) {
if (name != null && value != null) {
var current = values[name];
if(current) {
if (Array.isArray(current)) {
Expand Down
14 changes: 14 additions & 0 deletions test/core/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,18 @@ describe("Core htmx Regression Tests", function(){
htmx.find("#message2").innerHTML.should.equal("I came from a message2 oob swap I should be third but I am in the wrong spot")
});

it ('Handles https://github.com/bigskysoftware/htmx/issues/33 "empty values" properly', function() {
this.server.respondWith("POST", "/htmx.php", function (xhr) {
xhr.respond(200, {}, xhr.requestBody);
});

var form = make('<form hx-trigger="click" hx-post="/htmx.php">\n' +
'<input type="text" name="variable" value="">\n' +
'<button type="submit">Submit</button>\n' +
'</form>')
form.click();
this.server.respond();
form.innerHTML.should.equal("variable=")
});

})
1 change: 0 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ <h2>Mocha Test Suite</h2>

<script src="lib/handlebars-v4.7.6.js"></script>
<script src="lib/mustache.js"></script>
<script src="lib/nunjucks.js"></script>
<script src="../src/ext/client-side-templates.js"></script>
<script src="ext/client-side-templates.js"></script>

Expand Down

0 comments on commit 468c405

Please sign in to comment.