chinedufn / percy

Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
https://chinedufn.github.io/percy/
Apache License 2.0
2.26k stars 84 forks source link

How are attributes with dash (-) treated? #105

Closed ivanceras closed 3 months ago

ivanceras commented 5 years ago

In this example, how is stroke-width=5 treated? The parser complains about this.

<svg>
 <circle cx="25" cy="75" r="20" stroke="red" fill="transparent" stroke-width="5"/>
</svg>
ivanceras commented 5 years ago

I think this could be easier if done using the same way javascript allow type to be accessed using a camel-case on the identifier that has a dash.

example: z-index could be accessed in javascript using zIndex. so stroke-width=5 will become strokeWidth=5.

chinedufn commented 5 years ago

This is similar to https://github.com/chinedufn/percy/issues/106#issuecomment-474647127 where the parser currently assumes that all attributes are composed of a single identifier.

Note the single input.parse() here.

https://github.com/chinedufn/percy/blob/344e757206de0c2c134b79ed596676489290ca93/crates/html-macro/src/tag.rs#L143


The solution is peeking for a - and if there is one parsing two more identifiers, concatenating their to_string's and then creating a new identifier using that new String.


As with https://github.com/chinedufn/percy/issues/106#issuecomment-474647127 we'd want a test for this.

I can take a look next time I'm working on the parser. If you'd like to take a look in the meantime I'd be happy to provide more detailed instructions.


Cheers and thanks for opening the issue!!

apps4uco commented 1 year ago

Hi, any chance of raising the priority of this issue as its a showstopper for Accessibility aria- and bootstrap data- attributes. Thanks

EHPS-Oliver commented 7 months ago

as well for http-equiv in meta tags

chinedufn commented 3 months ago

Implemented https://github.com/chinedufn/percy/pull/199

Available in html-macro = 0.2.3