From 9d6ee0110a679922f7456057db8fd416da01c77b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:01:44 -0500 Subject: [PATCH] Extract rule: template-no-heading-inside-button --- README.md | 1 + .../template-no-heading-inside-button.md | 32 ++++++++ .../template-no-heading-inside-button.js | 47 +++++++++++ .../template-no-heading-inside-button.js | 77 +++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 docs/rules/template-no-heading-inside-button.md create mode 100644 lib/rules/template-no-heading-inside-button.js create mode 100644 tests/lib/rules/template-no-heading-inside-button.js diff --git a/README.md b/README.md index ae2c7b3b6c..80506d23d9 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,7 @@ rules in templates can be disabled with eslint directives with mustache or html | [template-no-aria-hidden-body](docs/rules/template-no-aria-hidden-body.md) | disallow aria-hidden on body element | | 🔧 | | | [template-no-aria-unsupported-elements](docs/rules/template-no-aria-unsupported-elements.md) | disallow ARIA roles, states, and properties on elements that do not support them | | | | | [template-no-autofocus-attribute](docs/rules/template-no-autofocus-attribute.md) | disallow autofocus attribute | | 🔧 | | +| [template-no-heading-inside-button](docs/rules/template-no-heading-inside-button.md) | disallow heading elements inside button elements | | | | ### Best Practices diff --git a/docs/rules/template-no-heading-inside-button.md b/docs/rules/template-no-heading-inside-button.md new file mode 100644 index 0000000000..1c79e9293d --- /dev/null +++ b/docs/rules/template-no-heading-inside-button.md @@ -0,0 +1,32 @@ +# ember/template-no-heading-inside-button + + + +Assistive technology allows users to browse a page by heading elements (`

` - `

`). However, if those heading elements are nested inside of button elements, they will automatically be marked as presentational by browsers. Any HTML element where ["children presentational" is true](https://w3c.github.io/aria/#button) should be coerced by the browser to be presentational, and therefore not included in the accessibility tree. + +As such, nesting a heading element inside of a button element will cause failures for WCAG requirement 1.3.1, Info and Relationships, because the heading has lost semantic meaning. + +This rule checks `