mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
fix: trailing commas with key
This commit is contained in:
parent
a37458b9fa
commit
5313fc0cc6
3 changed files with 17 additions and 5 deletions
|
@ -84,7 +84,7 @@ impl Buffer {
|
||||||
|
|
||||||
self.write_attributes(attributes, key, true)?;
|
self.write_attributes(attributes, key, true)?;
|
||||||
|
|
||||||
if !children.is_empty() && !attributes.is_empty() {
|
if !children.is_empty() && (!attributes.is_empty() || key.is_some()) {
|
||||||
write!(self.buf, ", ")?;
|
write!(self.buf, ", ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
self.write_attributes(attributes, key, true)?;
|
self.write_attributes(attributes, key, true)?;
|
||||||
|
|
||||||
if !children.is_empty() && !attributes.is_empty() {
|
if !children.is_empty() && (!attributes.is_empty() || key.is_some()) {
|
||||||
write!(self.buf, ",")?;
|
write!(self.buf, ",")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ impl Buffer {
|
||||||
ShortOptimization::NoOpt => {
|
ShortOptimization::NoOpt => {
|
||||||
self.write_attributes(attributes, key, false)?;
|
self.write_attributes(attributes, key, false)?;
|
||||||
|
|
||||||
if !children.is_empty() && !attributes.is_empty() {
|
if !children.is_empty() && (!attributes.is_empty() || key.is_some()) {
|
||||||
write!(self.buf, ",")?;
|
write!(self.buf, ",")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,9 +282,10 @@ impl Buffer {
|
||||||
|
|
||||||
if attr_len > 80 {
|
if attr_len > 80 {
|
||||||
None
|
None
|
||||||
|
} else if comp.children.is_empty() {
|
||||||
|
Some(attr_len)
|
||||||
} else {
|
} else {
|
||||||
self.is_short_children(&comp.children)
|
None
|
||||||
.map(|child_len| child_len + attr_len)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[BodyNode::RawExpr(ref expr)] => {
|
[BodyNode::RawExpr(ref expr)] => {
|
||||||
|
|
|
@ -25,3 +25,5 @@ twoway! ("tiny" => tiny);
|
||||||
twoway! ("tinynoopt" => tinynoopt);
|
twoway! ("tinynoopt" => tinynoopt);
|
||||||
|
|
||||||
twoway! ("long" => long);
|
twoway! ("long" => long);
|
||||||
|
|
||||||
|
twoway! ("key" => key);
|
||||||
|
|
9
packages/autofmt/tests/samples/key.rsx
Normal file
9
packages/autofmt/tests/samples/key.rsx
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
rsx! {
|
||||||
|
li { key: "{link}",
|
||||||
|
Link { class: "py-1 px-2 {hover} {hover_bg}", to: "{link}", "{name}" }
|
||||||
|
}
|
||||||
|
|
||||||
|
li { key: "{link}", asd: "asd",
|
||||||
|
Link { class: "py-1 px-2 {hover} {hover_bg}", to: "{link}", "{name}" }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue