Skip to content

fix: omit browser/dynamic-variant attrs when at defaults#31

Merged
jonas-haeusler merged 3 commits into
doubleSlashde:mainfrom
benomahony:main
May 21, 2026
Merged

fix: omit browser/dynamic-variant attrs when at defaults#31
jonas-haeusler merged 3 commits into
doubleSlashde:mainfrom
benomahony:main

Conversation

@benomahony
Copy link
Copy Markdown
Contributor

The web component validates browser with ZodMiniBoolean. HTML attributes are always strings, so getAttribute("browser") returns "true" (string), which ZodMini rejects. safeParse fails and the component falls back to {viewId: "index"}, causing every diagram on the page to render the same view.

Omitting the attribute when it equals the default means getAttribute returns null, which the component converts to undefined via ?? void 0, allowing Zod's own default to apply correctly.

The web component validates `browser` with ZodMiniBoolean. HTML attributes are
always strings, so `getAttribute("browser")` returns "true" (string), which
ZodMini rejects. `safeParse` fails and the component falls back to
`{viewId: "index"}`, causing every diagram on the page to render the same view.

Omitting the attribute when it equals the default means `getAttribute` returns
null, which the component converts to undefined via `?? void 0`, allowing Zod's
own default to apply correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jonas-haeusler
Copy link
Copy Markdown
Member

thanks, seems reasonable as a workaround until likec4 releases a version with the fix.

see also #27

@jonas-haeusler jonas-haeusler merged commit 3489ce0 into doubleSlashde:main May 21, 2026
4 checks passed
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