← All analysers · Multi-model analysers

OrphanedEventHandlerAnalyzer

Detects handlers attached to selectors that don't resolve to any element.

What it detects

An `addEventListener` against `#submit` is silently dead code when no element with that id exists in the source HTML. This analyser cross-references every handler registration in the ActionLanguage tree against the DOMModel and reports unresolved selectors.

WCAG criteria

  • 4.1.1Parsing (deprecated; legacy)

Example

// handlers.js
document
  .querySelector("#submitt") // typo — element is "submit"
  .addEventListener("click", save);

Paradise reports: Handler registered against selector `#submitt`, but no matching element exists in the source HTML.

Source

analyzers/OrphanedEventHandlerAnalyzer.ts

More