fix(forms): preserve regex quantifiers and use inline constraint errors
This commit is contained in:
1 parent
1dd60ded0d
commit
fe40cc56df
13 files changed
+132
-26
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { parse, generate } from "../src/index.ts";
|
||||
|
||||
test("HTML and component pattern attributes preserve regex quantifiers", () => {
|
||||
for (const tag of ["input", "Input"]) {
|
||||
for (const pattern of ["[0-9]{6}", "[a-z]{2,8}", "[A-Z]{1,}"]) {
|
||||
const code = generate(parse(`page Example { view { <${tag} pattern="${pattern}" /> } }`));
|
||||
expect(code).toContain(pattern);
|
||||
expect(code).not.toContain("__wrnAttr(6)");
|
||||
expect(code).not.toContain("__wrnAttr(2,8)");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("dynamic pattern props still compile as expressions", () => {
|
||||
const code = generate(
|
||||
parse(
|
||||
'component Example { props { pattern: string = "" } view { <input pattern="{pattern}" /> } }',
|
||||
),
|
||||
);
|
||||
expect(code).toContain("__wrnAttr(pattern)");
|
||||
});
|
||||
Reference in new issue
Block a user