Skip to content

Commit

Permalink
fix(vue): svg attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jan 7, 2025
1 parent 2e4ae72 commit 9cce2ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-dragons-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/vue": patch
---

Fix issue where svg `viewBox` attribute handling between client and server
1 change: 1 addition & 0 deletions examples/nuxt-ts/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
compatibilityDate: "2025-01-07",
})
12 changes: 7 additions & 5 deletions packages/frameworks/vue/src/normalize-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ const propMap: Record<string, string> = {
defaultChecked: "checked",
}

const preserveKeys =
"viewBox,className,preserveAspectRatio,fillRule,clipPath,clipRule,strokeWidth,strokeLinecap,strokeLinejoin,strokeDasharray,strokeDashoffset,strokeMiterlimit".split(
",",
)

function toVueProp(prop: string) {
if (prop in propMap) return propMap[prop]

if (prop.startsWith("on")) {
return `on${toCase(prop.substr(2))}`
}

if (prop.startsWith("on")) return `on${toCase(prop.substr(2))}`
if (preserveKeys.includes(prop)) return prop
return prop.toLowerCase()
}

Expand Down

0 comments on commit 9cce2ba

Please sign in to comment.