-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Per the HTML spec, an attribute name like data-id-25 is valid (albeit maybe unusual)
Attribute names must consist of one or more characters other than the space characters, U+0000 NULL, U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters, the control characters, and any characters that are not defined by Unicode. link
This can't be parsed by syn-rsx at present because each segment of the node name needs to be an Ident, and 25 isn't a valid Rust identifier.
You're probably more familiar with syn than I am but I wonder if changing the Punctuated variant of NodeName to something like
Punctuated(Punctuated<NodeNameFragment, Punct>),where
pub enum NodeNameFragment {
Ident(Ident),
Number(u32)
}would be a possibility. This only expands the possibilities to include numbers, and not other possibly-valid attribute names that aren't valid Rust identifiers, but would be a start.
Here's an issue in my repo with an example of where someone would use it—using a class: syntax to toggle a Tailwind-like CSS class name that included a number after a dash.