Skip to content

Skip 1x1 tracking pixels with empty alt in img_alt_empty_check - #1661

Merged
SteveJonesDev merged 4 commits into
developfrom
copilot/skip-1x1-images-empty-alt
Jul 14, 2026
Merged

Skip 1x1 tracking pixels with empty alt in img_alt_empty_check#1661
SteveJonesDev merged 4 commits into
developfrom
copilot/skip-1x1-images-empty-alt

Conversation

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

The img_alt_empty_check rule incorrectly flags 1×1 tracking pixels with alt="" 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.js

    • Added isTrackingPixel(node) helper that detects 1×1 pixels via:
      • HTML width="1" + height="1" attributes (any src, including base64)
      • Computed naturalWidth === 1 + naturalHeight === 1 for loaded images without explicit size attributes
    • evaluate() now returns early (true) when hasEmptyAlt && 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)
function isTrackingPixel( node ) {
    const widthAttr = node.getAttribute( 'width' );
    const heightAttr = node.getAttribute( 'height' );
    if ( widthAttr === '1' && heightAttr === '1' ) {
        return true;
    }
    if (
        typeof node.naturalWidth === 'number' &&
        typeof node.naturalHeight === 'number' &&
        node.naturalWidth === 1 &&
        node.naturalHeight === 1
    ) {
        return true;
    }
    return false;
}

Fixes PRO-775

Copilot AI changed the title [WIP] Skip 1x1 images with empty alt in img_alt_empty_check Skip 1x1 tracking pixels with empty alt in img_alt_empty_check Apr 23, 2026
Copilot AI requested a review from pattonwebz April 23, 2026 11:57
@SteveJonesDev
SteveJonesDev marked this pull request as ready for review May 29, 2026 03:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +39 to +40
if ( hasEmptyAlt && isTrackingPixel( node ) ) {
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@SteveJonesDev

SteveJonesDev commented May 29, 2026

Copy link
Copy Markdown
Member

Code Review Notes

Reviewed this PR against issue #1660 — the implementation looks correct.

What's working well:

  • isTrackingPixel() helper correctly checks both HTML width/height attributes and naturalWidth/naturalHeight for loaded images without explicit attributes
  • The early return is slotted in cleanly before the existing return !hasEmptyAlt line, leaving all other existing skip conditions untouched
  • All 4 test cases specified in the issue are present and correctly asserted

@pattonwebz this is otherwise ready for human review, can you resolve the merge conflict with develop?

@SteveJonesDev
SteveJonesDev merged commit 7235c55 into develop Jul 14, 2026
18 checks passed
@pattonwebz pattonwebz mentioned this pull request Jul 14, 2026
9 tasks
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rules: Skip 1x1 images (tracking pixels) with empty alt in img_alt_empty_check

3 participants