Kotlin / kotlinx.html

Kotlin DSL for HTML
Apache License 2.0
1.63k stars 133 forks source link

Fix 'htmlFor' wrappers generation - [kotlin-wrappers/issues/365] #170

Closed aerialist7 closed 3 years ago

fluidsonic commented 3 years ago

Unfortunately the implementation is likely incorrect and breaks <label for=…>. Also, there are way more attributes problematic in React than just for. This problem is not limited to a specific property but a more general issue.

The actual problem is that kotlinx.html is used in two different ways:

  1. For building plain HTML. In that case HTML attribute names are used, so for is correct.
  2. For use with React. In that case DOM attribute names are used, so htmlFor is correct.

Depending on if you use the library for (1) or (2), the required names and even the types of attributes are often different. If you change for to htmlFor it will work in React but break for normal HTML. In its current state this library can only support one or the other. And it doesn't support React for now. The alternative is to rework this library in a way that allows different attribute name mapping depending on the intended use of the HTML tree.

For that reason I've not used kotlinx.html when creating my own Kotlin React wrapper fluid-react.