Hacker News new | past | comments | ask | show | jobs | submit login

This is another project that teaches you to write non-standard, invalid code, with the hopes that a tool will come along and transform it into valid, standard code later.

And there's no need, because there are multiple ways in HTML they could already express this without violating HTML. Here are 2 ways that work, and then the way they've done it which is in violation:

Possible method 1: Data attributes. Any time you as an author want to add additional data to an element, you are free to invent any custom attribute names you want, so long as they begin with "data-".

Possible method 2: Custom elements. Any time you as an author want to add a custom element to HTML, you are free to invent any tag name so long as it follows a simple naming criteria (essentially [a-z]+-[a-z]+) and if you invent any custom element, you are allowed to define whatever attributes on it you like.

Invalid method chosen: To pollute standard elements with invalid attribute names in violation of the HTML standard.




> Possible method 1: Data attributes. Any time you as an author want to add additional data to an element, you are free to invent any custom attribute names you want, so long as they begin with "data-".

From the linked docs:

> It's worth mentioning that, if you prefer, you can use the data- prefix when using htmx:

    <a data-hx-post="/click">Click Me!</a>


Why promote and illustrate a non-standard way, or even allow it at all?


For those people that like to have less verbosity at the expense of composing invalid HTML?

TypeScript is an invalid form of JS but people still like it.


Given the documentation actually list the data-* syntax as an alternative (and pretty much near the top), I’m assuming they are aware of the problem, but still prefer the non-standard-compliant attributes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: