{ "id": "90982", "key": "TIMOB-9085", "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": [ { "id": "13574", "description": "Sprint 2012-15 Core", "name": "Sprint 2012-15 Core", "archived": true, "released": true, "releaseDate": "2012-07-30" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-09-12T04:07:28.000+0000", "created": "2012-04-27T13:27:46.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "core", "module_view", "qe-review", "qe-testadded" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [ { "id": "18947", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "91948", "key": "TIMOB-9636", "fields": { "summary": "iOS: \"this\" variable does not occur in variables view in the Studio debugger", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-11-07T05:52:33.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h2. Problem\r\n\"this\" value in event listener is set to child component when child component is clicked.\r\n\r\nh2. Steps to reproduce\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#000',\r\n navBarHidden: true\r\n});\r\n \r\nvar view = Ti.UI.createView({ width: '100%', height: '100%', backgroundColor: '#f00' });\r\n \r\nview.addEventListener('click', function(e){\r\n Ti.API.info('View click');\r\n Ti.API.info(this);\r\n});\r\nvar button = Ti.UI.createButton({width:150, height:150, title: 'Click me!' });\r\n\r\nview.add(button);\r\nwin.add(view);\r\n\r\nwin.open();\r\n{code}\r\n\r\nResult: Click on the button and see the output. \"this\" value produces \"[object TiUIButton]\".\r\n\r\nExpected result: \"this\" inside event listener should point to UI object to which that listener is attached (the output should produce \"[object TiUIView]\").\r\n\r\nThis works as expected on Android.", "attachment": [], "flagged": false, "summary": "iOS: \"this\" value in event listener is set to child component when child component is clicked", "creator": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* Titanium SDK version: 2.1.0 (04/27/12 11:03 c695942)\r\n* iOS iPhone simulator 5.0\r\n* OSX Lion", "comment": { "comments": [ { "id": "208114", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Technically both of these behaviors are incorrect according to the JavaScript standard. The {{this}} object in a callback should always refer to the callback function itself.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-17T11:37:46.000+0000", "updated": "2012-07-17T11:37:46.000+0000" }, { "id": "208243", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Hi Stephen.\r\n\r\n\r\nI don't think that is true. \"this\" inside function depends on a context from which function is called (if it is not called as a constructor). I don't think it can ever be a function itself. Detailed explanation of \"this\" value inside function code can be found here: http://dmitrysoshnikov.com/ecmascript/chapter-3-this/#this-value-in-the-function-code\r\n\r\n\r\nThings can get tricky when host objects are involved because nothing is specified. But, if we check how things are implemented in DOM environment, we can see that behavior is exact as this ticket describes:\r\n\r\n{code}\r\n\r\n\r\n\t
\r\n\t\t