implement spreading props in the rsx macro
This commit is contained in:
1 parent
9e167dfdb7
commit
5b65c4cfb4
7 files changed
+208
-102
No files matched your search
@@ -49,7 +49,6 @@ impl Writer<'_> {
|
||||
attributes,
|
||||
children,
|
||||
brace,
|
||||
extra_attributes,
|
||||
..
|
||||
} = el;
|
||||
|
||||
@@ -167,7 +166,7 @@ impl Writer<'_> {
|
||||
|
||||
fn write_attributes(
|
||||
&mut self,
|
||||
attributes: &[ElementAttrNamed],
|
||||
attributes: &[AttributeType],
|
||||
key: &Option<IfmtInput>,
|
||||
sameline: bool,
|
||||
) -> Result {
|
||||
@@ -189,7 +188,7 @@ impl Writer<'_> {
|
||||
while let Some(attr) = attr_iter.next() {
|
||||
self.out.indent += 1;
|
||||
if !sameline {
|
||||
self.write_comments(attr.attr.start())?;
|
||||
self.write_comments(attr.start())?;
|
||||
}
|
||||
self.out.indent -= 1;
|
||||
|
||||
@@ -290,7 +289,14 @@ impl Writer<'_> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_attribute(&mut self, attr: &ElementAttrNamed) -> Result {
|
||||
fn write_attribute(&mut self, attr: &AttributeType) -> Result {
|
||||
match attr {
|
||||
AttributeType::Named(attr) => self.write_named_attribute(attr),
|
||||
AttributeType::Spread(attr) => self.write_spread_attribute(attr),
|
||||
}
|
||||
}
|
||||
|
||||
fn write_named_attribute(&mut self, attr: &ElementAttrNamed) -> Result {
|
||||
self.write_attribute_name(&attr.attr.name)?;
|
||||
write!(self.out, ": ")?;
|
||||
self.write_attribute_value(&attr.attr.value)?;
|
||||
@@ -298,6 +304,13 @@ impl Writer<'_> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_spread_attribute(&mut self, attr: &Expr) -> Result {
|
||||
write!(self.out, "..")?;
|
||||
write!(self.out, "{}", prettyplease::unparse_expr(attr))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// make sure the comments are actually relevant to this element.
|
||||
// test by making sure this element is the primary element on this line
|
||||
pub fn current_span_is_primary(&self, location: Span) -> bool {
|
||||
|
||||
Reference in new issue
Block a user