Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26179] iOS: Property check on proxy always returns true

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-08-24T17:24:12.000+0000
Affected Version/sRelease 7.2.0
Fix Version/sRelease 7.5.0
ComponentsiOS
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2018-07-03T12:23:29.000+0000
Updated2019-04-26T19:03:53.000+0000

Description

Checking for property existence on Titanium proxy objects always returns true, ignoring if a property really exists or not. Various aspects of Vue/Angular and module bundling with Rollup/Webpack rely on proper existence checks for properties on our proxies. *Steps to reproduce the behavior* Run the following example code in a Titanium app which compares the behavior to a plain JavaScript object.
const win = Ti.UI.createWindow();
const plainObject = {
	prop: 'bar',
	func: () => {}
};

Ti.API.debug('### hasProperty check ###');
Ti.API.debug('non-existing property');
Ti.API.debug(proxy: ${'foo' in win});
Ti.API.debug(plain: ${'foo' in plainObject});
Ti.API.debug('existing property');
Ti.API.debug(proxy: ${'children' in win});
Ti.API.debug(plain: ${'prop' in plainObject});
*Actual behavior* The property check returns true for non-existing properties on the Ti.UI.Window object. *Expected behavior* The property check should return true only for existing properties and false otherwise.

Comments

  1. Jan Vennemann 2018-07-03

    PR: https://github.com/appcelerator/titanium_mobile/pull/10150
  2. Samir Mohammed 2018-07-18

    *Closing ticket*, Verified fix in SDK Version: 7.4.0.v20180717131401 *FR Passed (Test Steps):*

    Created a titanium Application

    Added the following code in the description in to the app.js

    Ran the program

    Following was seen in the console (Proxy for non-existing property no longer always set to true):

       [DEBUG] :  ### hasProperty check ###
       [DEBUG] :  non-existing property
       [DEBUG] :  proxy: false
       [DEBUG] :  plain: false
       [DEBUG] :  existing property
       [DEBUG] :  proxy: true
       [DEBUG] :  plain: true
       
    *Test Environment*
       APPC Studio: 5.0.0.201712081732
       APPC CLI: 7.0.4
       iPhone 6 simulator (11.2)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13
       Node.js Version: 8.9.1
       Xcode 9.2
       

JSON Source