sycamore-rs / sycamore

A library for creating reactive web apps in Rust and WebAssembly
https://sycamore-rs.netlify.app
MIT License
2.79k stars 148 forks source link

fix view! parser to handle dashed attributes with Rust keywords (#620) #624

Closed mekanoe closed 1 year ago

mekanoe commented 1 year ago

Switches view! AttributeName parser to Ident::parse_any to handle keywords in extended attribute names.

fixes #620

Example

view! { cx, p(class="my-class", data-ref-me="my-value") }

Prior to change, this would throw with

┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
error: expected identifier, found keyword `ref`
  --> tests/view/element-pass.rs:26:63
   |
26 |         let _: View<G> = view! { cx, p(class="my-class", data-ref-me="my-value") };
   |                                                               ^^^
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈