percy icon indicating copy to clipboard operation
percy copied to clipboard

How are attributes with dash (-) treated?

Open ivanceras opened this issue 7 years ago • 4 comments

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 avatar Mar 19 '19 05:03 ivanceras

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.

ivanceras avatar Mar 20 '19 10:03 ivanceras

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!!

chinedufn avatar Mar 21 '19 01:03 chinedufn

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

apps4uco avatar Aug 06 '23 00:08 apps4uco

as well for http-equiv in meta tags

EHPS-Oliver avatar Feb 02 '24 19:02 EHPS-Oliver