Skip to content

Pages can see window.__RENDERDIFF__ and mark elements data-renderdiff-mask - #70

Merged
tmashara merged 2 commits into
mainfrom
claude/issue-49-page-mask
Oct 29, 2026
Merged

tmashara merged 2 commits into
mainfrom
claude/issue-49-page-mask

Conversation

@tmashara

Copy link
Copy Markdown
Owner

What / why

Sites that know what drifts (a rotating quote, a chat widget) had no way to say so from the page; every mask had to live in the renderdiff config. Now:

  • window.__RENDERDIFF__ = true is set before the page's first script on every load (first line of the existing seeded-Math.random init script in prepare(), so it covers first pages, the recheck's fresh context and replacement pages). No request header, so no CORS preflights.
  • [data-renderdiff-mask] is appended in masksFor(), the one function every mask path goes through: the PNG paint (one-shot and tiled), the text read, the recheck's and the final locate, and --computed. It is not added to cfg.masks, so the config hash, meta.masks and --rerun-failed's setup comparison are untouched.

How the reason appears in the report

capture() reads each marked element's attribute value: data-renderdiff-mask="rotating quote" becomes rotating quote (data-renderdiff-mask) (mirrors <sel> (--mask)); an empty value is listed as data-renderdiff-mask. The distinct reasons of both sides go on the result as masked (absent when none), and "What was neutralized" in report.html and evidence.html lists them after the configured masks. "None configured." still shows only when there are neither.

How tested

New guard-rail fixture cooperate: three boxes whose text differs between the sides — one marked data-renderdiff-mask, one hidden by the page under window.__RENDERDIFF__, one control. The new test in tests/visual/guardrails.test.ts (describe("masks")) asserts every diff region names only the control, the text diff is only the control's line, and the reason shows up in both masked and the report.

  • Without the src/ change: fails (actual: 'div.box.marked > p'). With only the flag line removed: fails (actual: 'div.box.flagged > p'). With the change: passes.
  • Existing maskReasons deepEquals stay green, pinning that the always-present locator adds nothing when no element carries the attribute.
  • npm run typecheck, lint, format:check, npm test (305 pass), npm run test:visual (333 pass).

Docs: "Cooperating pages" in docs/scoping.md, masked in docs/output.md, the skill reference's mask row, bullet and results.json fields.

Fixes #49

🤖 Generated with Claude Code

tmashara and others added 2 commits October 29, 2026 18:16
…-mask

Every page gets window.__RENDERDIFF__ = true before its first script, and every
mask path (capture, text read, recheck, locate, --computed) also masks
[data-renderdiff-mask]. The attribute's value, or the attribute name when empty,
is listed under "What was neutralized" and in the result's `masked`, kept out of
meta.masks so --rerun-failed and the config hash are unaffected.

Fixes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit 455dc0c into main Oct 29, 2026
3 checks passed
@tmashara
tmashara deleted the claude/issue-49-page-mask branch October 29, 2026 17:36
@tmashara tmashara mentioned this pull request Oct 29, 2026
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.

window.__RENDERDIFF__ flag and data-renderdiff-mask attribute

1 participant