Open qeleb opened 2 months ago
Trying to think if there is a downside. When I started Solid I actually used all properties but we switched to attributes for consistency reasons. We still use properties for webcomponents. So trying to remember why we made this choice. I might have to do some digging to remind myself of why.
Trying to think if there is a downside. When I started Solid I actually used all properties but we switched to attributes for consistency reasons. We still use properties for webcomponents. So trying to remember why we made this choice. I might have to do some digging to remind myself of why.
Ah please do.
I’ve been writing
prop:src=
, prop:alt=
, & prop:href=
for months at work and I was hoping this is something the compiler could take on specifically for the cases where the attribute & property have the exact same behavior.
We definitely cannot do this for all of them though— there are some tricky ones like checked where the attr:checked
=== prop:defaultChecked
(but not prop:checked
)
there is a similarly weird case for the value property.
To the best of my understanding, this optimization is safe for all IDL attribute reflection properties so I made a very careful list of only a few.
@ryansolid Have you gotten a chance to review this? I’ve been taking a look at how Preact handles this and it’s interesting. I may follow their approach
It seems to specially handle value/defaultValue
, checked/defaultChecked
, then set everything as properties except for href because of this quirk (although this can still be handled with some consideration) & a few others
@ryansolid Would you be willing to merge this optimization if it were opt-in only like omitNestedClosingTags
?
@ryansolid Would you be willing to merge this optimization if it were opt-in only like
omitNestedClosingTags
?
That might be a good way to start it. Mostly I don't want to break in preparation for SolidStart release.
Changes
Bundle size win
Example code
OLD output
NEW output
(-0.1KB)
Notes
maxlength (string)
/maxLength (number)
will require slightly more effort to coerce types