Skip to content

Commit

Permalink
Exclude form elements within disabled fieldsets (#2012)
Browse files Browse the repository at this point in the history
* Exclude form elements within disabled fieldsets

* add test for disabled fieldsets

* cleanup
  • Loading branch information
flixcor authored Nov 30, 2023
1 parent 40cd1a5 commit 4dc97a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ return (function () {
}

function shouldInclude(elt) {
if(elt.name === "" || elt.name == null || elt.disabled) {
if(elt.name === "" || elt.name == null || elt.disabled || closest(elt, "fieldset[disabled]")) {
return false;
}
// ignore "submitter" types (see jQuery src/serialize.js)
Expand Down
7 changes: 7 additions & 0 deletions test/core/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,12 @@ describe("Core htmx Parameter Handling", function() {
}
});

it('Input within disabled fieldset is excluded', function () {
var input = make('<form><input name="foo" value="bar"/><fieldset disabled><input name="do" value="rey"/></fieldset></form>');
var vals = htmx._('getInputValues')(input, "get").values;
vals['foo'].should.equal('bar');
should.equal(vals["do"], undefined);
})

});

0 comments on commit 4dc97a4

Please sign in to comment.