Socket
Socket
Sign inDemoInstall

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
12
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee - npm Package Compare versions

Comparing version 11.20.0 to 11.21.0

9

CHANGELOG.md
Changelog
=========
## Unreleased
## 11.21.0
- Utilize FormData as payload source when submitting form
- Fix empty input value submits empty string
- Fix FormData behaviour
- Start test-app if addressed as main, for testing behaviours - `node app/app.js`
## 11.20.0

@@ -5,0 +14,0 @@

49

lib/BrowserTab.js

@@ -5,7 +5,6 @@ "use strict";

const Fetch = require("./Fetch");
const FormData = require("./FormData");
const Location = require("./Location");
const querystring = require("querystring");
const vm = require("vm");
const Window = require("./Window");
const url = require("url");

@@ -178,9 +177,10 @@ const webPageSymbol = Symbol.for("webPage");

const formData = this.getFormData(form, event._submitElement);
const webPage = this[webPageSymbol];
if (method.toUpperCase() === "GET") {
const p = url.parse(action, true);
Object.assign(p.query, formData);
return callback(webPage.submit(url.format(p)));
const uri = new URL(action, this.window.location.origin);
for (const [name, value] of new FormData(form).entries()) {
uri.searchParams.append(name, value);
}
return callback(webPage.submit(`${uri.pathname}${uri.search}`));
} else if (method.toUpperCase() === "POST") {

@@ -192,3 +192,3 @@ const navigation = webPage.submit(action, {

},
body: querystring.stringify(formData),
body: new URLSearchParams(new FormData(form)).toString(),
});

@@ -198,37 +198,2 @@ return callback(navigation);

}
getFormData(form, submitElement) {
const inputs = form.elements;
const payload = Array.from(inputs).reduce((acc, input) => {
if (input.disabled) return acc;
if (input.name && input.value) {
if (input.type === "radio" || input.type === "checkbox") {
if (input.checked) {
acc[input.name] = acc[input.name] || [];
acc[input.name].push(input.value);
}
} else if (input.tagName === "SELECT") {
const selected = input.selectedOptions;
if (selected.length === 1) {
acc[input.name] = selected[0].value;
} else if (selected.length > 1) {
acc[input.name] = Array.from(selected).map((option) => option.value);
}
} else if (input.name in acc) {
acc[input.name] = [].concat(acc[input.name], input.value);
} else {
acc[input.name] = input.value;
}
}
return acc;
}, {});
if (submitElement && submitElement.name) {
payload[submitElement.name] = submitElement.value;
}
return payload;
}
onWindowScroll() {

@@ -235,0 +200,0 @@ const elementsToScroll = this[elementsToScrollSymbol];

@@ -7,2 +7,3 @@ "use strict";

constructor(form) {
if (form && form.tagName !== "FORM") throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'");
this[kForm] = form;

@@ -12,4 +13,24 @@ }

const result = [];
for (const elm of this[kForm].elements) {
result.push([ elm.name, elm.value ]);
const form = this[kForm];
if (form) {
for (const elm of this[kForm].elements) {
if (!elm.name || elm.disabled) continue;
switch (elm.type) {
case "checkbox":
case "radio":
if (!elm.checked) continue;
break;
case "submit":
continue;
case "select-multiple": {
for (const option of elm.selectedOptions) {
result.push([ elm.name, option.value ]);
}
continue;
}
}
result.push([ elm.name, elm.value ]);
}
}

@@ -16,0 +37,0 @@ return result[Symbol.iterator]();

@@ -49,2 +49,5 @@ "use strict";

}
get type() {
return this.multiple ? "select-multiple" : "select-one";
}
get value() {

@@ -51,0 +54,0 @@ const selectedIndex = this.selectedIndex;

{
"name": "@expressen/tallahassee",
"version": "11.20.0",
"version": "11.21.0",
"description": "Lightweight client testing framework",

@@ -39,3 +39,3 @@ "main": "index.js",

"chai": "^4.3.6",
"eslint": "^8.23.0",
"eslint": "^8.24.0",
"express": "^4.18.1",

@@ -42,0 +42,0 @@ "markdown-toc": "^1.2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc