Skip to content

Commit f9213d3

Browse files
authored
fix(styled-jsx): Fix content escaping regression (#471)
1 parent 18281f4 commit f9213d3

8 files changed

Lines changed: 18 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/styled-jsx/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @swc/plugin-styled-jsx
22

3+
## 8.0.2
4+
5+
### Patch Changes
6+
7+
- b28b674: Fix content escaping regression
8+
39
## 8.0.1
410

511
### Patch Changes

packages/styled-jsx/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# @swc/plugin-styled-jsx
44

5+
## 8.0.2
6+
7+
### Patch Changes
8+
9+
- b28b674: Fix content escaping regression
10+
511
## 8.0.1
612

713
### Patch Changes

packages/styled-jsx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-styled-jsx",
3-
"version": "8.0.1",
3+
"version": "8.0.2",
44
"description": "SWC plugin for styled-jsx",
55
"main": "swc_plugin_styled_jsx.wasm",
66
"scripts": {

packages/styled-jsx/transform/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = { workspace = true }
1010
name = "styled_jsx"
1111
repository = { workspace = true }
1212
rust-version = { workspace = true }
13-
version = "0.91.1"
13+
version = "0.91.2"
1414

1515

1616
[features]

packages/styled-jsx/transform/src/transform_css_lightningcss.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn transform_css(
204204
.map(|quasi| {
205205
TplElement {
206206
cooked: None, // ? Do we need cooked as well
207-
raw: quasi.replace('`', "\\`").replace("\"", "\\\"").into(),
207+
raw: quasi.replace('`', "\\`").replace("\\\"", "\\\\\"").into(),
208208
span: DUMMY_SP,
209209
tail: false,
210210
}

packages/styled-jsx/transform/tests/fixture/svg-strip/output.lightningcss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ const MaskedDivBad = ()=>{
2525
<_JSXStyle id={"59987c08c9f7d258"} dynamic={[
2626
0.5 + HEAD_MARGIN_PERCENTAGE,
2727
0.5 + CUTOUT_AVATAR_PERCENTAGE_VISIBLE + HEAD_MARGIN_PERCENTAGE
28-
]}>{`.head.__jsx-style-dynamic-selector{position:relative}.avatar-wrapper.__jsx-style-dynamic-selector{-webkit-mask-composite:source-out;background:#ff6b6b;border-radius:50%;width:40px;height:40px;-webkit-mask-image:url(\"data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"0.5\\" cx=\\"0.5\\" cy=\\"0.5\\"/></svg>\"),url(\"data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"${0.5 + HEAD_MARGIN_PERCENTAGE}\\" cx=\\"${0.5 + CUTOUT_AVATAR_PERCENTAGE_VISIBLE + HEAD_MARGIN_PERCENTAGE}\\" cy=\\"0.5\\"/></svg>\");mask-image:url(\"data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"0.5\\" cx=\\"0.5\\" cy=\\"0.5\\"/></svg>\"),url(\"data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"${0.5 + HEAD_MARGIN_PERCENTAGE}\\" cx=\\"${0.5 + CUTOUT_AVATAR_PERCENTAGE_VISIBLE + HEAD_MARGIN_PERCENTAGE}\\" cy=\\"0.5\\"/></svg>\");-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-composite:source-out;mask-composite:subtract}`}</_JSXStyle>
28+
]}>{`.head.__jsx-style-dynamic-selector{position:relative}.avatar-wrapper.__jsx-style-dynamic-selector{-webkit-mask-composite:source-out;background:#ff6b6b;border-radius:50%;width:40px;height:40px;-webkit-mask-image:url("data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"0.5\\" cx=\\"0.5\\" cy=\\"0.5\\"/></svg>"),url("data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"${0.5 + HEAD_MARGIN_PERCENTAGE}\\" cx=\\"${0.5 + CUTOUT_AVATAR_PERCENTAGE_VISIBLE + HEAD_MARGIN_PERCENTAGE}\\" cy=\\"0.5\\"/></svg>");mask-image:url("data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"0.5\\" cx=\\"0.5\\" cy=\\"0.5\\"/></svg>"),url("data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 1 1\\"><circle r=\\"${0.5 + HEAD_MARGIN_PERCENTAGE}\\" cx=\\"${0.5 + CUTOUT_AVATAR_PERCENTAGE_VISIBLE + HEAD_MARGIN_PERCENTAGE}\\" cy=\\"0.5\\"/></svg>");-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-composite:source-out;mask-composite:subtract}`}</_JSXStyle>
2929
</>;
3030
};

packages/styled-jsx/transform/tests/fixture/tpl-escape-2/output.lightningcss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default function Home({ fontFamily }) {
1010
])}>
1111
<_JSXStyle id={"b45f7ae33801eec9"} dynamic={[
1212
fontFamily
13-
]}>{`body{font-family:${fontFamily}}code:before,code:after{content:\"\`\"}`}</_JSXStyle>
13+
]}>{`body{font-family:${fontFamily}}code:before,code:after{content:"\`"}`}</_JSXStyle>
1414
</div>;
1515
}

0 commit comments

Comments
 (0)