I'm having an abstract class Input extending abstract class EmptyElement which extends abstract class Element. They all reside in the same package.
public abstract class Input(val type: String?, var value: String? = null, id: String? = null) :
EmptyElement(name = "input", id = id) {
val htmlInputElement: HTMLInputElement = super.htmlElement as HTMLInputElement;
init {
this.htmlElement.setAttribute(“type”, type);
if ( value != null ) {
this.htmlInputElement.value = value!!
}
}
}
However the call above fails:
![/uploads/kotlinlang/original/1X/359cb8c6be2e40c1895742dbb66da4b9d02563cc.png](https://global.discourse-cdn.com/business5/uploads/kotlinlang/original/1X/359cb8c6be2e40c1895742dbb66da4b9d02563cc.png)
Unless I’ve declared property htmlElement of class Element “open”:
public abstract class Element (name: String?, cssClass: String? = null, id: String? = null, htmlElement: HTMLElement? = null) {
open val htmlElement: HTMLElement = htmlElement ?: document.createElement(name) as HTMLElement;
<pre><span >...</code></pre>
}
Empty/uploads/kotlinlang/original/1X/836dd12ace62c834a0de7313dd1bb821a7f6820b.zip (299 Bytes)
Element.kt.zip (504 Bytes)