Skip to content

Commit 2d7f28c

Browse files
committed
Change order to remove attr
1 parent 7209d70 commit 2d7f28c

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

.changeset/spotty-camels-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/wasm": patch
3+
---
4+
5+
Change order to remove attr

libs/extractor/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,25 @@ mod tests {
410410
}
411411
)
412412
.unwrap());
413+
414+
reset_class_map();
415+
assert_debug_snapshot!(extract(
416+
"test.tsx",
417+
r#"import {Image} from '@devup-ui/core'
418+
<Image
419+
className={styles.logo}
420+
src="/next.svg"
421+
alt="Next.js logo"
422+
width={180}
423+
height={38}
424+
/>
425+
"#,
426+
ExtractOption {
427+
package: "@devup-ui/core".to_string(),
428+
css_file: None
429+
}
430+
)
431+
.unwrap());
413432
}
414433

415434
#[test]

libs/extractor/src/prop_modify_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn modify_props<'a>(
124124
let mut class_name_prop = None;
125125
let mut style_prop = None;
126126

127-
for idx in 0..props.len() {
127+
for idx in (0..props.len()).rev() {
128128
if let Attribute(attr) = &props[idx] {
129129
if let Identifier(ident) = &attr.name {
130130
if ident.name == "className" {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "extract(\"test.tsx\",\nr#\"import {Image} from '@devup-ui/core'\n <Image\n className={styles.logo}\n src=\"/next.svg\"\n alt=\"Next.js logo\"\n width={180}\n height={38}\n />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
4+
---
5+
ExtractOutput {
6+
styles: [
7+
Static(
8+
ExtractStaticStyle {
9+
property: "width",
10+
value: "720px",
11+
level: 0,
12+
selector: None,
13+
},
14+
),
15+
Static(
16+
ExtractStaticStyle {
17+
property: "height",
18+
value: "152px",
19+
level: 0,
20+
selector: None,
21+
},
22+
),
23+
],
24+
code: "import \"@devup-ui/core/devup-ui.css\";\n<img src=\"/next.svg\" alt=\"Next.js logo\" className={`d0 d1 ${styles.logo}`} />;\n",
25+
}

0 commit comments

Comments
 (0)