Skip to content

Milestone 4: card DOM - #5

Merged
rodzy merged 4 commits into
mainfrom
milestone-4-card-dom
Nov 27, 2026
Merged

rodzy merged 4 commits into
mainfrom
milestone-4-card-dom

Conversation

@rodzy

@rodzy rodzy commented Nov 27, 2026

Copy link
Copy Markdown
Owner

What does this change?

Milestone 4 of the roadmap: src/card.js adds, updates and removes the artwork image in a media card.

  • showArtwork(card, src) adds one HTML <img class="zen-media-viz-artwork" alt=""> as the first item of the card's .zen-media-info-container, created through the card's own document. It reuses the image when the artwork changes and leaves it alone when the source is unchanged.
  • The image stays hidden until it loads, so a failed load never shows a broken-image icon.
  • Only sources accepted by isUsableSrc (https: or image data:) are set. Anything else, including null, removes the image.
  • removeArtwork(card) removes the image and leaves the card as it was.

The bundle zen-media-viz.uc.js is unchanged because src/index.js does not import the module yet. Wiring happens in Milestone 5, and styling in Milestone 6.

How was it tested?

  • test/card.test.js runs against the recorded Zen 1.24.3b card (test/fixtures/zen-1.24.3b.json) under happy-dom.
  • npm test, npm run lint, npm run format:check and npm run check:bundle pass locally.
  • Not checked by hand in Zen. Real image loading in browser.xhtml is verified once the mod runs in Zen (Milestone 5).

Checklist

  • Tests were written first and cover the change (npm test)
  • npm run lint and npm run format:check pass
  • Bundle rebuilt and committed (npm run build) if anything in src/ changed (not needed here: the bundle is unchanged)
  • Relevant items in docs/manual-testing.md checked in a real Zen + Sine install (Milestone 5)
  • CHANGELOG.md updated under Unreleased

showArtwork adds or reuses one decorative img as the first child of the card's info container and keeps it hidden until it loads, so a failed load never shows a broken icon. Sources that fail isUsableSrc remove the image. removeArtwork takes it out again. Tests run against the recorded Zen 1.24.3b card fixture.
The artwork URL comes from the page being played, so the browser UI
should not leak its own referrer to that host. The failed-load test
now also checks that the image stays in the card, so it catches a
regression that removes the element instead of hiding it.
@rodzy
rodzy merged commit 34cc3de into main Nov 27, 2026
1 check passed
@rodzy
rodzy deleted the milestone-4-card-dom branch November 27, 2026 23:14
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