Skip to content

feat(images): overhaul HTML and CSS image hiding (v2.31.0) - #204

Merged
prabothcharith merged 2 commits into
developmentfrom
feat/hide-images-all-and-css
Nov 20, 2026
Merged

prabothcharith merged 2 commits into
developmentfrom
feat/hide-images-all-and-css

Conversation

@prabothcharith

Copy link
Copy Markdown
Owner

Summary

  • Default HideImagesController (mode="all") + dedicated HideDecorativeImagesController (mode="decorative"):
    • HideImagesController now hides all non-protected host <img> (including non-empty alt and missing alt), <picture>, <object type="image/*">, <embed type="image/*">, and explicitly decorative <svg> elements, while HideDecorativeImagesController and <HideImagesController mode="decorative" /> retain strict decorative-only behavior.
    • Exported HIDE_IMAGES_MODES, HideImagesMode, and HideImagesValue from src/index.ts, and updated builtins.hideImages validation in src/core/featureSchema.ts.
  • Complete CSS & pseudo-element image hiding (src/core/effects.ts):
    • Added support for background-image, background shorthand, CSS variables (var(...)), image-set() / -webkit-image-set() / cross-fade(), list-style-image, element content: url(...), html/body host roots, and ::before/::after pseudo-elements (via CSP-nonce-aware #arap-hide-images-style, open ShadowRoot styles, and document.styleSheets rule scanning), while preserving pure CSS gradients.
    • Replaced substring protection selectors with camelCase-aware word-boundary token matching so aria-label sections, landmark roles, and ordinary class names like .paragraph, .typography, .photography, .roadmap, .sitemap, .charter, .aftermath, and .faqRow are no longer skipped, while widget UI, [data-arap-ignore]/[data-arap-exempt], interactive buttons/controls, icon-only links, CAPTCHAs, charts, maps, QR/barcodes, and math stay protected.
    • Added incremental applyMediaIncremental() + observer.takeRecords() + style/class/src/alt dynamic mutation handling and memoized { effectScope, nonce } options in AccessibilityPlugin.
  • Docs, Examples & Release 2.31.0:
    • Updated docs/DECORATIVE_IMAGES.md, docs/FEATURES.md, docs/API.md, docs/SCOPED_EFFECTS.md, docs/MIGRATION.md, docs/PROJECT_STATUS.md, examples/basic-usage/main.tsx, CHANGELOG.md, package.json, and package-lock.json.

Verification

  • npm run format:check: passed
  • npm run validate (typecheck, eslint --max-warnings 0, vitest run 51 files / 526 tests, tsup + CSS build): passed
  • npm run pack:check & npm run test:consumers (React 18 Vite, React 19 Tailwind Vite, Next.js 16, ESM+SSR, CJS, strict NodeNext declarations): passed
  • npm run test:browser: 260 passed, 10 intentional Next-only skips, 0 failures across react18-chromium, react19-tailwind, next-app, firefox, webkit, and mobile
  • git diff --check: passed

Copilot AI balanced review requested due to automatic review settings November 20, 2026 05:49

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T05:54:41.748228Z 3bf3d0e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 3bf3d0e736

ℹ️ 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 thread src/core/effects.ts
}

function resolveHideImagesMode(value: unknown): HideImagesMode | null {
if (value === true || value === "all") return "all";

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 Keep profile image preferences decorative-only

When AccessibilityPreferences.hideDecorativeImages is true, mapProfileSettingsToFeatures() in src/core/profiles.ts passes boolean true; this branch now interprets it as all, so applying or restoring that profile hides informative images too, unlike the preference’s decorative-only contract. Map the profile boolean to "decorative" so profiles retain their existing behavior.

Useful? React with 👍 / 👎.

Comment thread src/core/effects.ts
/(?:url|-webkit-image-set|image-set|cross-fade)\s*\(/i;
const HIDE_IMAGES_STYLE_ID = "arap-hide-images-style";
const HIDE_IMAGES_PSEUDO_CSS = [
"[data-arap-hide-before-bg]::before { background-image: none !important; }",

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 Override high-specificity host pseudo-image rules

If a host rule such as #hero::before { background-image: url(... ) !important; } applies, its ID selector has higher specificity than this injected attribute selector; since both declarations are !important, the host image remains visible even after the scanner marks the element. Use an override that wins against high-specificity host rules.

Useful? React with 👍 / 👎.

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.

2 participants