Skip to content

Commit

Permalink
fix: replace escaped quotes within class names during SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
sastan committed May 5, 2022
1 parent 7795440 commit b212b52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-humans-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'twind': patch
---

fix: replace escaped quotes within class names during SSR
6 changes: 4 additions & 2 deletions packages/twind/src/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ export function consume(markup: string, tw: (className: string) => string = tw$)
// but this works for now
const token =
quote == `"`
? value.replace(/(\[)'|'(])/g, `$1'$2`)
? // `'` -> ' ' '
value.replace(/(=|\[)(?:'|'|')|(?:'|'|')(])/g, `$1'$2`)
: quote == `'`
? value.replace(/(\[)"|"(])/g, `$1"$2`)
? // `"` -> " " "
value.replace(/(=|\[)(?:"|"|")|(?:"|"|")(])/g, `$1"$2`)
: value

const className = tw(token)
Expand Down

0 comments on commit b212b52

Please sign in to comment.