release: WRNexusJS 0.3.5
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/validation",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
|
||||
@@ -150,6 +150,10 @@ export const VALIDATE_RUNTIME = String.raw`
|
||||
var name = form.getAttribute("data-schema");
|
||||
var schema = (window.__wireSchemas || {})[name];
|
||||
if (!schema) return;
|
||||
// Schema-backed forms use WRNexus messages instead of the browser's
|
||||
// non-themeable native validation bubbles.
|
||||
form.noValidate = true;
|
||||
form.setAttribute("novalidate", "");
|
||||
form.addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
if (validateForm(form, schema) > 0) return; // client-invalid: stay put, errors shown
|
||||
|
||||
@@ -68,8 +68,11 @@ test("browser validation displays the serialized custom required message", () =>
|
||||
(0, eval)(VALIDATE_RUNTIME);
|
||||
const runtime = win.__wireValidate as { init(root: Document): void };
|
||||
runtime.init(win.document as unknown as Document);
|
||||
const form = win.document.querySelector("form")!;
|
||||
win.document.querySelector("input")!.dispatchEvent(new win.Event("blur", { bubbles: true }));
|
||||
|
||||
expect(form.noValidate).toBe(true);
|
||||
expect(form.hasAttribute("novalidate")).toBe(true);
|
||||
expect(win.document.querySelector("[data-error=email]")!.textContent).toBe(
|
||||
"Enter your email or username",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user