-
Notifications
You must be signed in to change notification settings - Fork 160
[Request] Custom special attributes #303
Comments
The runtime should actually already be fine with this - it needs xhp library and typechecker extensions though. From an open source perspective, this would probably need to be a new language feature rather than a |
Assuming this change would need to be in the HHVM repo, then? e.g. here? If you have some pointers, I'd be happy to try and contribute to this if I have time. I doubt it's urgent since I'm guessing no one has asked for this before me haha. Main thing that's still unclear to me is how to actually configure which special attribute prefixes to allow. I'm assuming the "would probably need to be a new language feature" means rather than a config option it'd be some new special syntax for how to declare these (e.g. in addition to But yeah. As said above, if you have some idea of how this would get done, I'd be down to give it a shot. |
I am very interested in how this would be implemented. I am worried this will make xhp attributes more unsound. Would it be okay if the renderer could be configured to special case prefixes like <p data-up-expand="JS" /> which would render as Lines 163 to 181 in d6893af
Adding an |
I think we'd be very unlikely to provide a way to retrofit this to existing HTML classes:
|
Background
For some context that inspired this request, currently working on a site using XHP for server-side HTML rendering. Looked into progressive enhancement frameworks for JS and found one I really liked called Unpoly. The way it works is by annotating the HTML with custom special attributes prefixed with
up-
(e.g.up-target
,up-expand
, etc.).Motivation
XHP does support custom attributes already (
data-
andaria-
) but there is no way to extend this list if there's a desire for more.The only existing way I can think of doing this is by basically reimplementing all of the core XHP HTML elements by extending some new like "base up element" that enumerates all the attributes and then just smearing the HTML element attributes and extend via composition.
If there's some other way to do this, that'd be great. But otherwise, would it be possible to add this?
Proposal
In my mind, this would be a new HHVM INI config option that can be used to add additional special attribute prefixes. Something like
hhvm.xhp.special_attribute_prefixes
which is configured with a default ofkeyset['data-', 'aria-']
I'd then just be able to modify my INI file with:
and I don't have to do any additional code. I can just use the attributes right away.
The text was updated successfully, but these errors were encountered: