diff --git a/package.json b/package.json index 2a09aa51c..c38045571 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/htmx.js b/src/htmx.js index e574f31f4..9328bd883 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -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) @@ -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 } /** diff --git a/test/core/parameters.js b/test/core/parameters.js index 575fe53a0..09e9fb630 100644 --- a/test/core/parameters.js +++ b/test/core/parameters.js @@ -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('
') + 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('
') var div = make('
')