[TIMOB-23504] iOS: Titanium proxies don't extend Object.prototype properly
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | In Progress |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Christopher Williams |
Created | 2016-06-13T17:46:42.000+0000 |
Updated | 2021-02-03T01:51:42.000+0000 |
Description
Our Titanium proxies do not extend Object.prototype properly on iOS, resulting in some unexpected behavior and necessary workarounds. In general, it means our proxies don't fully act like actual JS objects.
Some examples?
- Well should.js should just work fine to do something like
Ti.App.should.exist;
but does not, because should is a function added to Object.prototype and since our proxies don't extend it, it'll fail with "undefined is not a function". You need to do should(Ti.App).exist;
to work around it.
- We can't do something like Ti.App.hasOwnProperty('apiName');
, so we need to hack it to be called like so: Object.prototype.hasOwnProperty.call(Ti.App, 'apiName');
This is showing up in my mocha unit tests since iOS fails any checks that end up looking for own properties on Titanium proxies.
This sounds like a ticket that would be useful to have resolved
This in progress PR begins to address this issue: https://github.com/appcelerator/titanium_mobile/pull/10381 It won't be fixed until *all* of the proxies are migrated/fixed up though.