Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23504] iOS: Titanium proxies don't extend Object.prototype properly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusIn Progress
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2016-06-13T17:46:42.000+0000
Updated2021-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.

Comments

  1. Rene Pot 2017-10-18

    This sounds like a ticket that would be useful to have resolved
  2. Christopher Williams 2018-10-17

    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.

JSON Source