webcomponents / custom-elements-everywhere

Custom Element + Framework Interoperability Tests.
https://custom-elements-everywhere.com
Other
1.16k stars 102 forks source link

New test: libraries should offer control over setting attributes vs JS properties #2352

Open trusktr opened 2 months ago

trusktr commented 2 months ago

Now that React 19 is coming out, it will finally have better support for Custom Elements, but it is still not as good as it could be.

What custom-elements-everywhere is missing is a test to verify that each library gives users control over setting DOM attributes vs JS properties.

Lit's html template tag has syntax for this. For example,

Similarly, Solid.js JSX has the following syntax:

Solid's html has similar syntax (but with ${} interpolations)

Pota's html supports both Solid and Lit syntax.

Etc.


This is not just a nice to have, this is a necessity. We cannot guarantee custom elements are written a certain way.

It is impossible for any templating system could heuristically guess if something should be set as attribute or as property (I.e. to guess the CE author's or CE user's intent). Template systems could have defaults (like the above do), but ultimately the user needs control, and authors also need control on telling users how to use their custom elements regardless of how frameworks work.