@expressen/tallahassee
Advanced tools
Comparing version 13.0.0 to 13.1.0
@@ -6,5 +6,11 @@ Changelog | ||
## 13.1.0 | ||
- implement form novalidate | ||
- add submit submitter with name to payload | ||
- button has default type submit | ||
## 13.0.0 | ||
- `input.validate` is of type ValidationState | ||
- `input.validity` is of type `ValidityState` | ||
- `<input name="foo" required oninput="setCustomValidity('')" oninvalid="setCustomValidity('Required')">` now executes attribute event handlers | ||
@@ -11,0 +17,0 @@ |
@@ -173,5 +173,5 @@ "use strict"; | ||
const form = event.target; | ||
const {target: form, submitter} = event; | ||
const method = form.getAttribute("method") || "GET"; | ||
const formaction = (event.submitter?.getAttribute("formaction")) || form.getAttribute("action"); | ||
const formaction = (submitter?.getAttribute("formaction")) || form.getAttribute("action"); | ||
const action = formaction || this.window.location.pathname + (this.window.location.search ? this.window.location.search : ""); | ||
@@ -186,4 +186,8 @@ | ||
} | ||
if (submitter?.name) uri.searchParams.append(submitter.name, submitter.value || ""); | ||
return callback(webPage.submit(`${uri.pathname}${uri.search}`)); | ||
} else if (method.toUpperCase() === "POST") { | ||
const payload = new URLSearchParams(new FormData(form)); | ||
if (submitter?.name) payload.append(submitter.name, submitter.value || ""); | ||
const navigation = webPage.submit(action, { | ||
@@ -194,3 +198,3 @@ method: "POST", | ||
}, | ||
body: new URLSearchParams(new FormData(form)).toString(), | ||
body: payload.toString(), | ||
}); | ||
@@ -197,0 +201,0 @@ return callback(navigation); |
@@ -23,2 +23,13 @@ "use strict"; | ||
} | ||
get type() { | ||
const type = this.getAttribute("type"); | ||
switch (type) { | ||
case "submit": | ||
case "reset": | ||
case "button": | ||
return type; | ||
default: | ||
return "submit"; | ||
} | ||
} | ||
click() { | ||
@@ -25,0 +36,0 @@ if (this.disabled) return; |
@@ -56,2 +56,12 @@ "use strict"; | ||
} | ||
get noValidate() { | ||
return this.hasAttribute("novalidate"); | ||
} | ||
set noValidate(val) { | ||
if (val) { | ||
return this.setAttribute("novalidate", "novalidate"); | ||
} else { | ||
return this.removeAttribute("novalidate"); | ||
} | ||
} | ||
get action() { | ||
@@ -69,4 +79,4 @@ return this.getAttribute("action") || this[originSymbol]; | ||
if (target.type === "submit" || (target.tagName === "BUTTON" && !target.type)) { | ||
if (!this.reportValidity()) return; | ||
if (target.type === "submit") { | ||
if (!this.noValidate && !this.reportValidity()) return; | ||
const submitEvent = new SubmitEvent("submit"); | ||
@@ -73,0 +83,0 @@ submitEvent[symbols.submitter] = event.target; |
{ | ||
"name": "@expressen/tallahassee", | ||
"version": "13.0.0", | ||
"version": "13.1.0", | ||
"description": "Lightweight client testing framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123679
3506