Skip 1x1 tracking pixels with empty alt in img_alt_empty_check - #1661
Conversation
Agent-Logs-Url: https://github.com/equalizedigital/accessibility-checker/sessions/5add204d-d436-4544-9c42-3b121f54713e Co-authored-by: pattonwebz <3902039+pattonwebz@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c6587842b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( hasEmptyAlt && isTrackingPixel( node ) ) { | ||
| return true; |
There was a problem hiding this comment.
Limit tracking-pixel skip to img elements
The img_alt_empty selector also runs this check for input[type="image"][alt=""], so this new exception makes a 1×1 image submit button such as <input type="image" alt="" width="1" height="1"> pass. Unlike passive tracking pixels, image inputs are controls and still need a non-empty accessible name; the existing tests already expect empty-alt image inputs to be violations, but this dimension-based bypass now lets those violations through when the control is 1×1.
Useful? React with 👍 / 👎.
Code Review NotesReviewed this PR against issue #1660 — the implementation looks correct. What's working well:
@pattonwebz this is otherwise ready for human review, can you resolve the merge conflict with |
The
img_alt_empty_checkrule incorrectly flags 1×1 tracking pixels withalt=""as WCAG 1.1.1 violations. These are not meaningful visual content and should be treated as decorative no-ops.Changes
src/pageScanner/checks/img-alt-empty-check.jsisTrackingPixel(node)helper that detects 1×1 pixels via:width="1"+height="1"attributes (anysrc, including base64)naturalWidth === 1+naturalHeight === 1for loaded images without explicit size attributesevaluate()now returns early (true) whenhasEmptyAlt && isTrackingPixel(node)tests/jest/rules/imgAltEmpty.test.js— new cases:<img src="track.gif" alt="" width="1" height="1">→ pass<img src="https://example.com/whatever.png" alt="" width="1" height="1">→ pass<img src="tiny.png" alt="" width="2" height="1">→ fail (not 1×1)<img src="maybe-tracker.gif" alt="">→ fail (no dimension attributes to confirm)Fixes PRO-775