Commit df440f8c authored by David Sveningsson's avatar David Sveningsson
Browse files

feat(rules): new rule `aria-hidden-html`

parent f3e2a385
Loading
Loading
Loading
Loading
+31
Changes for docs/rules/__tests__/__snapshots__/aria-hidden-html.md.spec.ts.snap: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`docs/rules/aria-hidden-html.md inline validation: correct 1`] = `[]`;

exports[`docs/rules/aria-hidden-html.md inline validation: incorrect 1`] = `
[
  {
    "errorCount": 1,
    "filePath": "inline",
    "fixableErrorCount": 1,
    "fixableWarningCount": 0,
    "messages": [
      {
        "column": 7,
        "fix": [Function],
        "line": 1,
        "message": "aria-hidden must not be used on <html>",
        "offset": 6,
        "related": [],
        "ruleId": "aria-hidden-html",
        "ruleUrl": "https://html-validate.org/rules/aria-hidden-html.html",
        "selector": "html",
        "severity": 2,
        "size": 11,
      },
    ],
    "source": "<html aria-hidden="true"></html>",
    "warningCount": 0,
  },
]
`;
+22
Changes for docs/rules/__tests__/aria-hidden-html.md.spec.ts: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
import { describe, expect, it } from "@jest/globals";
import { HtmlValidate } from "../../../src/htmlvalidate";

const markup: Record<string, string> = {};
markup["incorrect"] = `<html aria-hidden="true"></html>`;
markup["correct"] = `<html></html>`;

describe("docs/rules/aria-hidden-html.md", () => {
	it("inline validation: incorrect", async () => {
		expect.assertions(1);
		const htmlvalidate = new HtmlValidate({"rules":{"aria-hidden-html":"error"}});
		const report = await htmlvalidate.validateString(markup["incorrect"]);
		expect(report.results).toMatchSnapshot();
	});

	it("inline validation: correct", async () => {
		expect.assertions(1);
		const htmlvalidate = new HtmlValidate({"rules":{"aria-hidden-html":"error"}});
		const report = await htmlvalidate.validateString(markup["correct"]);
		expect(report.results).toMatchSnapshot();
	});
});
+1 −1
Changes for docs/rules/aria-hidden-body.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -33,4 +33,4 @@ This rule takes no options.

## Version history

-- 6.3.0 - Rule added.
- 6.3.0 - Rule added.
+36
Changes for docs/rules/aria-hidden-html.md: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
---
docType: rule
name: aria-hidden-html
category: a11y
summary: disallow `aria-hidden` from being set on `<html>`
standards:
  - wcag-2.2-a
  - wcag-2.1-a
  - wcag-2.0-a
---

# Disallow `aria-hidden` from being set on `<html>`

Requires `aria-hidden` is not used on the `<html>` element.

## Rule details

Examples of **incorrect** code for this rule:

```html validate name="incorrect" rules="aria-hidden-html"
<html aria-hidden="true"></html>
```

Examples of **correct** code for this rule:

```html validate name="correct" rules="aria-hidden-html"
<html></html>
```

## Options

This rule takes no options.

## Version history

- %version% - Rule added.
+1
Changes for etc/docs-manifest.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ pattern.html
rules/allowed-links.html
rules/area-alt.html
rules/aria-hidden-body.html
rules/aria-hidden-html.html
rules/aria-label-misuse.html
rules/attr-case.html
rules/attr-delimiter.html
Loading