Replies: 1 comment 1 reply
-
I think having explicit structs for the valid attributes on each html element type would be way overkill though. Simply allowing passthrough of attributes that aren't explicitly defined as a prop for the component without the need for checking them would be sufficient, much like how if you put an attribute on an input element in the html macro it isn't checked for a valid value, that becomes the browser's problem. For example, vuejs which I am a bit more familiar with will do this automatically. Any attribute on a component that is not explicitly defined as a prop will be passed down to the root element of the component in vue, or you can move them to a different element than the component root if you wish. Something like this would make reusable functionality so much easier. It could be just a HashMap of attribute names to values, or even a vec of (name, value) tuples, which could just be strings as they are in html. My personal use case was to create a generic Technically I suppose I could pass an input child with the relevant attributes and hook my functionality into that, but that seems needlessly verbose and confusing for someone other than the author of the component. Not to mention, the user could pass an onchange callback to that input which would complicate things. It's quite a glaring oversight in my opinion. |
Beta Was this translation helpful? Give feedback.
-
Idea
I think it could be quite useful to have a prop struct for standard HTML element, it would make it easier to make Components reusable.
Example
I have a
PixelCanvas
that is a wrapper around a canvas with added logic. I'd like to be easily pass canvas attributes easily through my components, so I can use it with different even and style it independently.Having a struct that contain the HTML element's attributes would transform
into
Beta Was this translation helpful? Give feedback.
All reactions