MZ Aliasing an Inherited Method?

I need to Override an inherited method for a class, but I am worried my plugin will unnecessarily conflict with any other plugin that also Overrides that method. Ideally, I would like to allow my plugin to add its functionality on top of any other plugin that has overridden this method (via an alias or similar), and to also work perfectly if no other plugin overrides this method.

Specifically, I am trying to override the isEnabled method of Window_BattleItem. Window_BattleItem has no isEnabled method, but it inherits from Window_ItemList, which does have an isEnabled method. I need to introduce additional checks before confirming that an Item indeed is enabled on the Battle Items window, but I don't want any additional checks on the other windows that inherit Window_ItemList.

Is there any safe, relatively expedient way to do this?
Code:
    aliasEnabled = Window_BattleItem.prototype.isEnabled
    Window_BattleItem.prototype.isEnabled = function(){
        r = aliasEnabled.call(this) && (<add your custom condition here>);
        return r;
    }
What is stopping you from doing this?
@TheoAllen Perhaps nothing is stopping me! I assumed that if I try setting an alias name equal to a method that has not explicitly been defined (as in your line aliasEnabled = Window_BattleItem.prototype.isEnabled ), then it would be set to undefined and cause a crash when I tried to call the aliased method. Would it be (correctly) set to the inherited method, instead?
shouldn't be an issue so long as window_battleitem.prototype exists, but if you're really worried about that use typeof(foo)=='undefined' to check for nonexistence without a crash
In that case, you can try to see if it is defined or not by printing it out in the console
Try to type Window_BattleItem.prototype, if my memory serves right, it should print all of the available functions.
Because it is inherited, it should return whatever Window_BattleItem.prototype.isEnabled inherits from, likely Window_Command.prototype.isEnabled, since it isn't actually defined on this window, it'll take whatever property it does have from whichever window it was a prototype of.

What Theo suggests is likely the best way to ensure that you're not breaking any other plugins that use that function, though you could also define the function for that window in your plugin, add your check to it, and then call the original prototype function as well. Any plugin that changed the prototype would still get their changes in, the only issue here would be if another plugin also defined the same thing.
His suggestion should make it so that your plugin won't interfere with others, but it'll also make it so that your plugin is not broken by any that make the change as I suggested above, as long as their new function actually calls the prototype, anyway.

Original thread: https://forums.rpgmakerweb.com/threads/aliasing-an-inherited-method.136943/