Skip to content

feat(browser): data-image-type and data-visual-test-wait-bg-img stabilization helpers#334

Merged
gregberge merged 3 commits into
mainfrom
feat/stabilization-image-attrs
Jul 4, 2026
Merged

feat(browser): data-image-type and data-visual-test-wait-bg-img stabilization helpers#334
gregberge merged 3 commits into
mainfrom
feat/stabilization-image-attrs

Conversation

@gregberge

Copy link
Copy Markdown
Member

Adds two ways for authors to opt individual elements into image stabilization when the SDK's automatic detection can't cover them.

data-image-type="gif" (pauseGifs)

The pauseGifs stabilizer only recognized GIFs from their URL (a .gif extension or a data:image/gif URI), so GIFs served from extension-less URLs (e.g. a CDN endpoint like /media/1234) kept animating through the screenshot. Authors can now flag those explicitly:

<img src="https://cdn.example.com/media/1234" data-image-type="gif" />

This is the only reliable way to catch them without fetching and byte-sniffing every image.

data-visual-test-wait-bg-img + waitForBackgroundImages on by default

waitForBackgroundImages was opt-in because a full-document getComputedStyle sweep is expensive. It's now enabled by default, but scoped to elements flagged with data-visual-test-wait-bg-img (and their descendants) — keeping the sweep cheap while covering the common case out of the box:

<section class="hero" data-visual-test-wait-bg-img></section>
  • waitForBackgroundImages: true still widens the scan to the whole document.
  • { selector } still overrides the scan target.
  • false disables it.

Since it was the only consumer, the now-unused optIn plugin mechanism is removed.

Tests

Playwright e2e coverage for both: a GIF served from an extension-less endpoint flagged with the attribute gets frozen to a PNG, and a data-visual-test-wait-bg-img element blocks stabilization by default until its background image loads.

Docs

Documented in argos-ci/docs#221 (should not merge before this ships).

🤖 Generated with Claude Code

gregberge and others added 2 commits July 4, 2026 14:24
The pauseGifs stabilizer only recognized GIFs from their URL (a `.gif`
extension or a `data:image/gif` URI), so GIFs served from extension-less
URLs (e.g. a CDN endpoint) animated through the screenshot.

Let authors opt an image in explicitly with `data-image-type="gif"`,
which is the only reliable way to flag those cases without fetching and
sniffing the bytes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ttribute

The waitForBackgroundImages stabilizer was opt-in because a full-document
`getComputedStyle` sweep is expensive. Instead, enable it by default but
scope the scan to elements flagged with the `data-visual-test-wait-bg-img`
attribute (and their descendants), keeping the sweep cheap while covering
the common case out of the box. `waitForBackgroundImages: true` still
widens the scan to the whole document, and a `selector` still overrides it.

Since it was the only consumer, the now-unused `optIn` plugin mechanism is
removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
argos-js-sdk-reference Ready Ready Preview, Comment Jul 4, 2026 2:46pm

Request Review

The pauseGifs cleanup restores `img.src`, which the browser resolves to an
absolute URL, so the extension-less endpoint comes back as
`file:///…/masked-gif-endpoint` rather than the literal relative string.
Assert on the suffix instead of exact equality.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gregberge gregberge merged commit 75835e9 into main Jul 4, 2026
68 checks passed
@gregberge gregberge deleted the feat/stabilization-image-attrs branch July 4, 2026 14:49
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.

1 participant