How do I replace a buggy method in a class when the method calls super.method()?
I am extending a framework that has a bug in a class method.
// Parent Class
class BaseClass{
method() {
// do something
}
}
// Child class
class SubClass extends BaseClass{
method() {
// do something buggy
super.method();
}
}
I have submitted an issue to get a fix, but want an interim workaround. I looked at either
- monkeypatching the method in the existing class, but the method needs to call
super.method()which is not allowed in a monkeypatch function, because it does not have the [[HomeObject]] slot.
SubClass.prototype.method = function() {
// cannot call super.method()
};
- extending the class and overriding the method, but then I dont want to call the buggy super.method(), but "super.super.method()"
class SubSubClass extends SubClass{
method() {
// do something not buggy
super.super.method();
}
}
Is either approach possible? Is there another way to work around the buggy method?