Hi @Jan
Yes this is expected behaviour, Error expected when super constructors invoke private methods in derived classes?
The sub class fields are not installed until the super constructor has completed. This is something developers need to be aware of when using inheritance and overloads. It applies to other languages too.
One solution is to track which method were called early before the super constructor has returned, so then the subclasss constructor can do the work when it is ready. The pattern would look a little like:
class FancyInputElement extends InputElement {
static #callUpdate = new WeakSet();
constructor(...args) {
super(...args);
if (FancyInputElement.#callUpdate.has(this)) {
this.#update();
}
}
#update () { ... }
set required (v) {
if (! #update in this) {
FancyInputElement.#callUpdate.add(this);
} else {
this.#update();
}
super.required = v;
}
}