Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dist": "./scripts/dist.sh && npm run types-generate && npm run web-types-generate",
"lint": "eslint src/htmx.js test/attributes/ test/core/ test/util/ scripts/*.mjs",
"format": "eslint --fix src/htmx.js test/attributes/ test/core/ test/util/ scripts/*.mjs",
"types-check": "tsc src/htmx.js --noEmit --checkJs --target es6 --lib dom,dom.iterable --moduleResolution node",
"types-check": "tsc src/htmx.js --noEmit --checkJs --target es6 --lib dom,dom.iterable --moduleResolution node --skipLibCheck",
"types-generate": "tsc dist/htmx.esm.js --declaration --emitDeclarationOnly --allowJs --outDir dist",
"test": "npm run lint && npm run types-check && npm run test:chrome",
"test:debug": "web-test-runner --manual --open",
Expand Down
9 changes: 7 additions & 2 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,8 @@ var htmx = (function() {
function shouldInclude(element) {
// Cast to trick tsc, undefined values will work fine here
const elt = /** @type {HTMLInputElement} */ (element)
if (elt.name === '' || elt.name == null || elt.disabled || closest(elt, 'fieldset[disabled]')) {
const name = getRawAttribute(elt, 'name') || elt.name
if (name === '' || name == null || elt.disabled || closest(elt, 'fieldset[disabled]')) {
return false
}
// ignore "submitter" types (see jQuery src/serialize.js)
Expand Down Expand Up @@ -3508,7 +3509,11 @@ var htmx = (function() {
return toArray(elt.files)
}
// @ts-ignore value will be undefined for non-input elements, which is fine
return elt.value
const value = elt.value
if (Array.isArray(value)) {
return toArray(value)
}
return value
}

/**
Expand Down
11 changes: 11 additions & 0 deletions test/core/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ describe('Core htmx Parameter Handling', function() {
vals.do.should.deep.equal(['', 'rey', ''])
})

it('element with array value appends array items to FormData', function() {
var div = make('<div id="c1" name="fruit"></div>')
Object.defineProperty(div, 'value', {
value: ['banana', 'apple'],
configurable: true
})
var res = htmx._('getInputValues')(div)
res.values.fruit.should.deep.equal(['banana', 'apple'])
res.formData.getAll('fruit').should.deep.equal(['banana', 'apple'])
})

it('hx-include works with form', function() {
var form = make('<form id="f1"><input id="i1" name="foo" value="bar"/><input id="i2" name="do" value="rey"/><input id="i2" name="do" value="rey"/></form>')
var div = make('<div hx-include="#f1"></div>')
Expand Down