fix: allow keys
This commit is contained in:
1 parent
1e4af430a8
commit
5bab835843
2 files changed
+26
-4
No files matched your search
@@ -72,7 +72,8 @@ impl Buffer {
|
|||||||
ShortOptimization::Empty => {}
|
ShortOptimization::Empty => {}
|
||||||
ShortOptimization::Oneliner => {
|
ShortOptimization::Oneliner => {
|
||||||
write!(self.buf, " ")?;
|
write!(self.buf, " ")?;
|
||||||
self.write_attributes(attributes, true)?;
|
|
||||||
|
self.write_attributes(attributes, key, true)?;
|
||||||
|
|
||||||
if !children.is_empty() && !attributes.is_empty() {
|
if !children.is_empty() && !attributes.is_empty() {
|
||||||
write!(self.buf, ", ")?;
|
write!(self.buf, ", ")?;
|
||||||
@@ -87,7 +88,7 @@ impl Buffer {
|
|||||||
|
|
||||||
ShortOptimization::PropsOnTop => {
|
ShortOptimization::PropsOnTop => {
|
||||||
write!(self.buf, " ")?;
|
write!(self.buf, " ")?;
|
||||||
self.write_attributes(attributes, true)?;
|
self.write_attributes(attributes, key, true)?;
|
||||||
|
|
||||||
if !children.is_empty() && !attributes.is_empty() {
|
if !children.is_empty() && !attributes.is_empty() {
|
||||||
write!(self.buf, ",")?;
|
write!(self.buf, ",")?;
|
||||||
@@ -98,7 +99,7 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortOptimization::NoOpt => {
|
ShortOptimization::NoOpt => {
|
||||||
self.write_attributes(attributes, false)?;
|
self.write_attributes(attributes, key, false)?;
|
||||||
self.write_body_indented(children)?;
|
self.write_body_indented(children)?;
|
||||||
self.tabbed_line()?;
|
self.tabbed_line()?;
|
||||||
}
|
}
|
||||||
@@ -109,9 +110,24 @@ impl Buffer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_attributes(&mut self, attributes: &[ElementAttrNamed], sameline: bool) -> Result {
|
fn write_attributes(
|
||||||
|
&mut self,
|
||||||
|
attributes: &[ElementAttrNamed],
|
||||||
|
key: &Option<syn::LitStr>,
|
||||||
|
sameline: bool,
|
||||||
|
) -> Result {
|
||||||
let mut attr_iter = attributes.iter().peekable();
|
let mut attr_iter = attributes.iter().peekable();
|
||||||
|
|
||||||
|
if let Some(key) = key {
|
||||||
|
if !sameline {
|
||||||
|
self.indented_tabbed_line()?;
|
||||||
|
}
|
||||||
|
write!(self.buf, "key: \"{}\"", key.value())?;
|
||||||
|
if !attributes.is_empty() {
|
||||||
|
write!(self.buf, ", ")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while let Some(attr) = attr_iter.next() {
|
while let Some(attr) = attr_iter.next() {
|
||||||
if !sameline {
|
if !sameline {
|
||||||
self.indented_tabbed_line()?;
|
self.indented_tabbed_line()?;
|
||||||
|
|||||||
@@ -147,6 +147,12 @@ fn format_comments() {
|
|||||||
div {
|
div {
|
||||||
// empty space
|
// empty space
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
key: "asd", class: "asdsda",
|
||||||
|
div {}
|
||||||
|
h3 {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user