diff options
author | Vincent <vichenzo-thebaud@hotmail.com> | 2023-09-21 20:08:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-21 12:08:51 -0600 |
commit | 1f55266c470b23bd6327f535d2a57c3f0a6d74bb (patch) | |
tree | 3210fb3ee4dff24ccb9780c92c1b29763c3c9eaf /test/core | |
parent | 048f98c87b0ed4623b1325c173d2155ab1343ae6 (diff) | |
download | htmx-1f55266c470b23bd6327f535d2a57c3f0a6d74bb.tar.gz htmx-1f55266c470b23bd6327f535d2a57c3f0a6d74bb.zip |
[Test] Add a test to ensure inputs outside form with `form` attribute work properly (#1815)
Add a test to ensure inputs external to form work properly
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/ajax.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/core/ajax.js b/test/core/ajax.js index 220173cc..ae33fd53 100644 --- a/test/core/ajax.js +++ b/test/core/ajax.js @@ -1208,4 +1208,26 @@ describe("Core htmx AJAX Tests", function(){ this.server.respond(); values.should.deep.equal({t1: 'textValue', b1: ['inputValue', 'buttonValue']}); }) + + it('properly handles inputs external to form', function () { + var values; + this.server.respondWith("Post", "/test", function (xhr) { + values = getParameters(xhr); + xhr.respond(204, {}, ""); + }); + + make('<form id="externalForm" hx-post="/test">' + + ' <input type="hidden" name="b1" value="inputValue">' + + '</form>' + + '<input type="text" name="t1" value="textValue" form="externalForm">' + + '<select name="s1" form="externalForm">' + + ' <option value="someValue"></option>' + + ' <option value="selectValue" selected></option>' + + '</select>' + + '<button id="submit" form="externalForm" type="submit" name="b1" value="buttonValue">button</button>'); + + byId("submit").click(); + this.server.respond(); + values.should.deep.equal({t1: 'textValue', b1: ['inputValue', 'buttonValue'], s1: "selectValue"}); + }) }) |