You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have one functions which inter alia disabled HTMLInputElement, HTMLTextAreaElement and others. Currently I use an unsafeCastto HTMLInputElement for other types because I know that it works as internally it only uses disabled which HTMLTextAreaElement, HTMLSelectElement provide as well.
However, it would be nicer if I could rely on a common interface and do not have to use unsafeCast
The text was updated successfully, but these errors were encountered:
All HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement and so on are generated based on the specification IDLs. According to the specification HTMLTextAreaElement is not a HTMLInputElement and they even don't have any useful base type except HTMLElement. See, for example https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element
The workaround could be to write an extension property, something like this (untested)
Ah nice, was not even aware of that such a spec exist. But anyway, not all specs are perfect aren't they ;)
I understand if you do not want to change your generation approach. How about adding interfaces to kotlinx.html and provide extension functions, something like asFormSubElement() and the interface FormSubElement would look something like:
interface FormSubElement {
val disabled
val value
val required
...
}
and the extension function:
fun HTMLInputElement.asFormSubElement() = this.unsafeCast<FormSubElement >()
I think the use case of disabling all input, select, textarea or to fetch all value etc. is common enough that it would be worth that kotlinx.html provides such an interface and that not every user has to reinvent the wheel.
I have one functions which inter alia disabled HTMLInputElement, HTMLTextAreaElement and others. Currently I use an
unsafeCast
to HTMLInputElement for other types because I know that it works as internally it only usesdisabled
which HTMLTextAreaElement, HTMLSelectElement provide as well.However, it would be nicer if I could rely on a common interface and do not have to use
unsafeCast
The text was updated successfully, but these errors were encountered: