[TIMOB-6202] MobileWeb: Creating new classes without a definition throws error when instantiating
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-01-16T12:06:43.000+0000 |
Affected Version/s | Release 1.8.0.1 |
Fix Version/s | n/a |
Components | MobileWeb |
Labels | stage |
Reporter | Chris Barber |
Assignee | Chris Barber |
Created | 2011-11-16T09:54:09.000+0000 |
Updated | 2014-01-28T23:57:35.000+0000 |
Description
In Ti._5.createClass(), if the class definition (value) is not a function, it defaults the definition to "new Object()". This works fine, however if you try to create a new instance of this class, it throws a JavaScript error.
Turns out there is inconsistent use of createClass(). Sometimes it's used to create an instantiable object with the "new" operator such as when:
There are other times when createClass() is used to create a non-instantiable object that fails if you do a "new" operator:
Probably best to solve this by creating a new method called createObject() to explicitly differentiate between objects and classes:
Bryan and I discussed and we agree this should be separated. Start by renaming createClass() to declare(). As for createObject(), perhaps something like getObject() or object() or obj()?
I don't have a strong preference, but I think I am leaning towards object(). Aesthetically it seems to compliment declare() the best.
This entire issue has been eliminated since rolling out the new class hierarchy in TIMOB-6772.