Răsfoiți Sursa

fix: parsing of attributes without trailing commas

Jonathan Kelley 2 ani în urmă
părinte
comite
d160f38bc2
2 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 6 0
      examples/svg_basic.rs
  2. 1 2
      packages/rsx/src/element.rs

+ 6 - 0
examples/svg_basic.rs

@@ -67,6 +67,12 @@ fn app(cx: Scope) -> Element {
             stroke: "blue",
             stroke_width: "5",
         }
+        path {
+            d: "M9.00001 9C9 62 103.5 124 103.5 178",
+            stroke: "#3CC4DC",
+            "stroke-linecap": "square",
+            "stroke-width": "square",
+        }
     }))
 }
 

+ 1 - 2
packages/rsx/src/element.rs

@@ -45,7 +45,7 @@ impl Parse for Element {
 
                 content.parse::<Token![:]>()?;
 
-                if content.peek(LitStr) && content.peek2(Token![,]) {
+                if content.peek(LitStr) {
                     let value = content.parse()?;
                     attributes.push(ElementAttrNamed {
                         el_name: el_name.clone(),
@@ -53,7 +53,6 @@ impl Parse for Element {
                     });
                 } else {
                     let value = content.parse::<Expr>()?;
-
                     attributes.push(ElementAttrNamed {
                         el_name: el_name.clone(),
                         attr: ElementAttr::CustomAttrExpression { name, value },