Commit 4a43819d authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(rules): `wcag/h32` checks for `type="image"`

parent cb2e8437
Pipeline #213909321 passed with stages
in 9 minutes and 38 seconds
......@@ -10,6 +10,14 @@ summary: "WCAG 2.1 H32: Providing submit buttons"
[WCAG 2.1 technique H32][1] requires each `<form>` element to include at least one submit button in order to allow users to interact with the form in apredictable way.
For instance pressing enter in an input field to submit.
This rule checks for the presence of:
- `<button type="submit">`
- `<input type="submit">`
- `<input type="image">`
Submit buttons can either be nested or associated using the `form` attribute.
[1]: https://www.w3.org/WAI/WCAG21/Techniques/html/H32
## Rule details
......
......@@ -32,6 +32,13 @@ describe("wcag/h32", () => {
expect(report).toBeValid();
});
it("should not report when form has nested submit button (image)", () => {
expect.assertions(1);
const markup = '<form><input type="image"></form>';
const report = htmlvalidate.validateString(markup);
expect(report).toBeValid();
});
it("should not report when form has associated submit button", () => {
expect.assertions(1);
const markup = '<form id="foo"></form><button form="foo" type="submit"></button>';
......
......@@ -40,7 +40,7 @@ export default class H32 extends Rule {
function isSubmit(node: HtmlElement): boolean {
const type = node.getAttribute("type");
return type && type.valueMatches("submit");
return type && type.valueMatches(/submit|image/);
}
function isAssociated(id: string, node: HtmlElement): boolean {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment