Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ Let one `svgworm.config.json` build several sprites (for example `app` and `mark
- [2026-11-09] Backlog grooming: trigger re-checked and still unmet (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` has no starters and no user request). Every path in Files to Modify exists on main b9e1150, `OWNED_FILE` still at `packages/svgworm/src/core/write.ts:11`. Left pending.
- [2026-11-12] Backlog grooming: trigger re-checked and still unmet (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` has no starters and no user request). Every path in Files to Modify exists on main 73024f2, `OWNED_FILE` still at `packages/svgworm/src/core/write.ts:11`. Left pending.
- [2026-11-18] Backlog grooming: trigger re-checked and still unmet (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` has no starters and no user request). Every path in Files to Modify exists on main b79816f, `OWNED_FILE` still at `packages/svgworm/src/core/write.ts:11`. Note for later: TSK-110 may change the base that config paths resolve against, which a `sprites` map would inherit. Left pending.
- [2026-11-24] Backlog grooming: trigger re-checked and still unmet (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` has no starters and no user request). Every path in Files to Modify exists on main f561905, `OWNED_FILE` still at `packages/svgworm/src/core/write.ts:11`. The 2026-11-18 note is closed: TSK-110 (413df5d) only reworded the path descriptions, config paths still resolve against the working directory, so a `sprites` map inherits no new base. Left pending.
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ Emit an optional CSS file with one class per mono icon (`.svgworm-home { mask: u
- [2026-11-09] Backlog grooming: demand re-checked and still none (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` records no request). Every existing path in Files to Modify verified on main b9e1150 (`scripts/render-check.mjs`, `tests/render/matrix.json`, `src/core/emit/`, `write.ts`). Left pending.
- [2026-11-12] Backlog grooming: demand re-checked and still none (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` records no request). Every existing path in Files to Modify verified on main 73024f2 (`scripts/render-check.mjs`, `tests/render/matrix.json`, `src/core/emit/`, `write.ts`). Left pending.
- [2026-11-18] Backlog grooming: demand re-checked and still none (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` records no request). Every existing path in Files to Modify verified on main b79816f (`scripts/render-check.mjs`, `tests/render/matrix.json`, `src/core/emit/`, `write.ts`). Left pending.
- [2026-11-24] Backlog grooming: demand re-checked and still none (`gh issue list -R jmlweb/svgworm --state all` returns no issues; `docs/metrics/manual.json` records no request). Every existing path in Files to Modify verified on main f561905 (`scripts/render-check.mjs`, `tests/render/matrix.json`, `src/core/emit/`, `write.ts`). Related: TSK-113 changes how the img delivery is sized in the adapters; a CSS output would not use that path. Left pending.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
id: RPT-019
title: img-delivery icons render at 1x1 px by default because width="1em" is not a valid img dimension
type: bug
severity: high
status: triaged
created: 2026-11-24
triaged: 2026-11-24
task-id: TSK-113
---

## What happens

Icons with `delivery: "img"` (multicolor icons that need gradients, masks, clip paths or filters) render at **1 x 1 CSS px** when no `width`/`height` prop is given, so they are effectively invisible.

The React adapter defaults the size to `'1em'` (`packages/react/src/create-icon.tsx:71`, `DEFAULT_SIZE = '1em'`) and passes it as the HTML attributes of the `<img>` (`packages/react/src/create-icon.tsx:164-171`). On `<svg>` the attribute is a CSS length, so `1em` works. On `<img>`, `width`/`height` are HTML dimension attributes: the HTML "rules for parsing dimension values" read the leading digits and stop at `e`, so `width="1em"` means 1 px.

The generated `Icon.astro`, `Icon.vue` and `Icon.svelte` templates render the same markup (`packages/svgworm/src/cli/init/plan.ts:968-969` and `:1054`, `:1254-1255` and `:1315`, and the site copy `apps/site/src/components/Icon.astro:51-52` and `:137`), so every adapter has the bug. The documented markup in `apps/site/src/content/docs/icon.md:57-62` shows the same `height="1em"` / `width="1em"`.

## Reproduction

Observed on 2026-11-24 with the repo's Playwright browsers:

```js
const html = `<div style="font-size:32px"><img id="a" alt="" width="1em" height="1em" src="data:image/svg+xml,…24x24 red rect…"></div>`;
// getBoundingClientRect() of #a
```

Output:

```
chromium 1x1
firefox 1x1
```

(WebKit could not start on this host because of missing system libraries.) The expected size is 32 x 32, as the `<svg>` and `mask` deliveries give at `font-size: 32px`.

The unit test `packages/react/src/create-icon.test.tsx:87` asserts the markup string `<img alt="" height="1em" … width="1em"/>`, and the render matrix (`pnpm render:check`) renders the delivery forms with its own markup, so no check exercises the adapter's default size in a browser.

## Suggested fix

Give the `<img>` its default size through CSS instead of the dimension attributes, for example `style={{ width, height, ...style }}` (or keep numeric `width`/`height` props as attributes and move string lengths into the style), in `createIcon` and in all three templates, which the conformance tests keep in sync. Add a browser check that renders a default-size `img` icon from the adapter output and expects it to be 1em square.
3 changes: 2 additions & 1 deletion .backlog/tasks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Status | Count |
|--------|-------|
| Pending | 5 |
| Pending | 6 |
| Active | 3 |
| Blocked | 2 |
| Complete | 102 |
Expand All @@ -26,6 +26,7 @@
| TSK-107 | Fix: An absolute --config path is reported as not found although the file exists | P4 | | 2026-11-06 |
| TSK-108 | Fix: A config file saved with a UTF-8 BOM is rejected as not valid JSON | P4 | | 2026-11-06 |
| TSK-112 | Fix: check reports a directory or symlink with a sprite-like name as stale, but build never removes it, so check can never pass | P4 | | 2026-11-21 |
| TSK-113 | Fix: img-delivery icons render at 1x1 px by default because width="1em" is not a valid img dimension | P2 | | 2026-11-24 |

## Recently Completed

Expand Down
33 changes: 33 additions & 0 deletions .backlog/tasks/pending/TSK-113-fix-img-delivery-icons-render-at.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: TSK-113
title: Fix: img-delivery icons render at 1x1 px by default because width="1em" is not a valid img dimension
status: pending
priority: P2
tags: []
created: 2026-11-24
source: report/RPT-019
depends-on: []
---

# Fix: img-delivery icons render at 1x1 px by default because width="1em" is not a valid img dimension

## Description

From RPT-019. The adapters default `width`/`height` to `'1em'` and pass them as HTML attributes of the `<img>` used for `delivery: "img"` icons (`packages/react/src/create-icon.tsx:71` and `:164`; the templates in `packages/svgworm/src/cli/init/plan.ts` and `apps/site/src/components/Icon.astro:137`). HTML dimension attributes parse `1em` as 1 px, so multicolor img icons are 1 x 1 px by default (observed in Chromium and Firefox). Move the default size into CSS. Note the trade-off: inline style beats a class rule, which `icon.md` says resizes img icons. Change touches the adapters and the generated templates: run the core/adapter gate set from `.claude/rules/agent-workflow.md`.

## Acceptance Criteria

- [ ] A failing test first shows that the default-size img delivery of createIcon renders an img that is not 1em square in a browser (or asserts the size moves out of the HTML width/height attributes)
- [ ] createIcon in packages/react/src/create-icon.tsx, the Icon.astro, Icon.vue and Icon.svelte templates in packages/svgworm/src/cli/init/plan.ts and apps/site/src/components/Icon.astro render a default-size img icon at 1em x 1em, and the conformance tests stay green
- [ ] Explicit numeric and string width/height props still size img icons as documented
- [ ] A CSS class rule still resizes img icons, or the sizing section of apps/site/src/content/docs/icon.md is updated to say otherwise; the img markup example in icon.md matches the new output
- [ ] Changesets record the fix for svgworm and @svgworm/react
- [ ] pnpm verify, pnpm determinism:fingerprint, pnpm example:check, pnpm example:vite:check, pnpm site:check and pnpm render:check pass

## Notes

## Learnings

## Progress Log

- [2026-11-24] Created
Loading