Syntactic/dynamic tag/attribute extensions #3477
Replies: 1 comment 2 replies
-
What would be the use case for allowing colons in attribute names?
This is a wonderful idea, especially for the edge cases of actually needing some unusual characters in attribute names.
If one of intended use cases of these is an escape hatch from the limitations of the syntax of
As far as I understand, |
Beta Was this translation helpful? Give feedback.
-
Unsupported Attributes
Systems like HTMX require attributes using a colon in their name, for example
hx-on:click
orhx-on::before-request
. Currently Yew does not support the colon/namespace syntax, even though HTML spec allows it (is-
a valid attribute name? what about:
?).Main concern with supporting it directly via a set of
ident
s and colon-punct
s may be the way Rust macros handle spaces (this link is suggested by stylist documentation - oncestart
andend
or such stabilize, it would be possible to figure out the whitespaces from token lengths and positions). If Yew were to support boolean attributes as they are defined in the spec (likeabc- abc=123
should be interpreted asabc-="abc-" abc=123
, but in Rust with ignoring spaces it would becomeabc-abc=123
), some ambiguity may appear, but Yew for the better or the worse, does not.Additionally, Yew uses
~
for HTML/JS (doc is a little unclear on what it exactly it does) properties, which supposedly is valid HTML as per spec mentioned above, which would clash with extending Yew syntax to all characters.Proposed Syntaxes
a:b-c:d
. More characters should be allowed if Yew were to follow the HTML spec, but every single new character (@
,~
, etc) to be added would have to be vetted.{"attribute"}={"value"}
, but also"attribute"="value"
. Having quotes in attribute names is banned per HTML spec, so it should be fine to use in Yew.key
andref
be handled in any way if the attribute is dynamic? What about direct"key"
and"ref"
? (does current Yew support~key
and~ref
to be properties instead of built-in keywords?)@
(e.g.@{"attribute"}={"value"}
)?set_attribute
? (does current Yew sanitize dynamic tag names, for example whitespaces?)@
from the dynamic tag syntax. It seems unnecessary, as<{"dynamic-tag"} ... >
(but also<"dynamic-tag" ... >
) would suffice.</{}>
or having to repeat the dynamic tag (but then it would have to be checked in runtime). yew-alt-html supports</>
for all tags.Beta Was this translation helpful? Give feedback.
All reactions