{ "id": "77733", "key": "TIMOB-4818", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2017-07-25T22:42:12.000+0000", "created": "2011-07-13T01:09:18.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-07-25T22:42:12.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Hi.\r\n\r\nI've noticed that there is a bug when creating Titanium components with configuration objects that have properties defined in prototype chain. Here is example that demonstrate bug:\r\n\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n \r\nvar Conf = function() {\r\n this.height = 50;\r\n};\r\n \r\nConf.prototype.width = 100;\r\n \r\nvar cnf = new Conf();\r\n \r\ncnf.backgroundColor = '#f93';\r\n \r\nTi.API.debug(cnf);\r\nTi.API.debug(cnf.width);\r\nTi.API.debug(cnf.height);\r\nTi.API.debug(cnf.backgroundColor);\r\n \r\n//workaround is to copy properties from prototype chain\r\n//cnf.width = cnf.width;\r\n \r\nvar view = Ti.UI.createView(cnf);\r\n \r\nwin.add(view);\r\n \r\nwin.open();\r\n{code} \r\n\r\n\r\nOutput:\r\n{code}\r\nD/TiAPI ( 268): (kroll$1: app://app.js) [82,1429] {\"backgroundColor\":\"#f93\",\"height\":50}\r\nD/TiAPI ( 268): (kroll$1: app://app.js) [2,1431] 100.0\r\nD/TiAPI ( 268): (kroll$1: app://app.js) [1,1432] 50.0\r\nD/TiAPI ( 268): (kroll$1: app://app.js) [1,1433] #f93\r\n{code}\r\n\r\nSo, as you can see, \"width\" property is defined in prototype chain and it exists if we try to access it. But, \"View\" component created with this configuration object hasn't width defined as it is defined in prototype chain, as you can see if you run the code.", "attachment": [], "flagged": false, "summary": "JavaScript prototypes doesn't work with Titanium components", "creator": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "Titanium SDK version: 1.7.1+, Android 2.2", "comment": { "comments": [ { "id": "170030", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Reassigning tickets, as per Tony Guntharp's request", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-10-21T07:32:20.000+0000", "updated": "2011-10-21T07:32:20.000+0000" }, { "id": "176690", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Just to add, a workaround is to copy properties from object's prototype chain like this:\r\n\r\n{code}\r\nfor (var c in cnf) {\r\n cnf[c] = cnf[c];\r\n}\r\n{code}\r\n\r\nand pass that object to Titanium factory methods.\r\n\r\n\r\nI think this should be easy to fix for someone who knows where to fix. I think somewhere here the fix should go: https://github.com/appcelerator/titanium_mobile/tree/master/android/runtime/common/src/js\r\n\r\nin \"invoker.js\", but not sure.\r\n\r\n\r\n\r\nI know that this is trivial issue and that currently there are not much interested people that watches it, but JS prototypes are basic language feature and because of that I hope someone will find some time to fix this. :)\r\n\r\n\r\nThanks.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-12-20T04:32:33.000+0000", "updated": "2011-12-20T04:32:33.000+0000" }, { "id": "424703", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing due to inactivity. If this issue still exists, please raise a new ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-07-25T22:42:12.000+0000", "updated": "2017-07-25T22:42:12.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }