Make sure objects are created with the 'new' keyword.
// WRONG!
// Won't fail but no instance is returned.
// input1 remains 'undefined'.
var input1 = Fit.Controls.Input();
// Correct
var input2 = new Fit.Controls.Input();
Use the following line of code in every object to make sure it is initialized properly:
if (this instanceof Fit.Controls.Input) {
throw "Fit.Controls.Input must be initialized with the 'new' keyword";
}
Do not perform this check on e.g. Fit.Controls.ControlBase using Fit.Core.InstanceOf(this, Fit.Controls.ControlBase) since it checks the inheritance tree information created with Fit.Core.Extend(..). But unfortunately Fit.Core.Extend(..) is not capable of determining whether a given object was properly initialized (with 'new'), so it will apply the type information no matter what, which in turn causes Fit.Core.InstanceOf(..) to return True.
Make sure objects are created with the 'new' keyword.
Use the following line of code in every object to make sure it is initialized properly:
Do not perform this check on e.g. Fit.Controls.ControlBase using Fit.Core.InstanceOf(this, Fit.Controls.ControlBase) since it checks the inheritance tree information created with Fit.Core.Extend(..). But unfortunately Fit.Core.Extend(..) is not capable of determining whether a given object was properly initialized (with 'new'), so it will apply the type information no matter what, which in turn causes Fit.Core.InstanceOf(..) to return True.