{ "id": "92759", "key": "TIMOB-9356", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-06-04T12:33:35.000+0000", "created": "2012-06-04T09:00:46.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [], "assignee": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "updated": "2014-01-28T23:57:36.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": "11500", "name": "MobileWeb", "description": "Mobile Web (HTML) Platform" } ], "description": "h1. Problem\r\nStoring a label in a variable and then calling window.add(with that variable) causes an app exception. Directly adding the label to the window does not, nor does cascading an assignment with the window.add call.\r\n\r\nh2. Error\r\n{quote}\r\nUncaught TypeError: Object [object Object] has no method '_setParent' :8083/:4421\r\ndeclare._add :8083/:4421\r\ndeclare.add :8083/:13596\r\n(anonymous function)\r\n{quote}\r\nLine 8083 is:\r\n{code:title=app.js}\r\n_add: function(view) {\r\n view._setParent(this);\r\n this.children.push(view);\r\n this.containerNode.appendChild(view.domNode);\r\n view._hasBeenLaidOut = false;\r\n this._triggerLayout(this._isAttachedToActiveWin());\r\n},\r\n{code}\r\n\r\nh2. Reproduction\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\nvar breakTheApp = true;\r\nif (breakTheApp) {\r\n var status = Ti.UI.createLabel({\r\n text: 'This breaks.'\r\n });\r\n win.add(status);\r\n}\r\nelse {\r\n var status2;\r\n win.add(status2 = Ti.UI.createLabel({\r\n text: 'This works.'\r\n }));\r\n}\r\nwin.open();\r\n{code}\r\n\r\nh2. Workaround\r\nSee the reproduction's \"else\" case.", "attachment": [], "flagged": false, "summary": "MobileWeb: Storing a label to a variable named \"status\" causes the label to be caste to a string.", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": "Google Chrome 19.0.1084.53\r\n\r\nversion=2.0.3, timestamp=06/01/12 14:15, githash=a43004b\r\nversion=2.1.0, timestamp=06/02/12 01:02, githash=7b8aeb3", "comment": { "comments": [ { "id": "197104", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The problem has to do with the variable name itself. Changing the var name to, say, \"label\" fixes the problem. It seems to be a webkit thing only. All webkit based browsers I tested exhibited this behavior (Safari, Chrome, Android browser), but none of the non-webkit based browsers do (Firefox, Opera, IE). I'm keeping this ticket open in case it's something funky we do, but lowering the priority since it's easily worked around.", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-04T12:16:54.000+0000", "updated": "2012-06-04T12:16:54.000+0000" }, { "id": "197106", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "The problem is because Webkit apparently has a variable called \"status\" in the window object. Others have the same issue: http://stackoverflow.com/questions/1234453/variable-assignments-using-jquery-failing-in-safari.\r\n\r\nI'd be curious if you can just wrap the example above in a (function(){ /* code goes here */ }()) and see if that also would fix it.\r\n\r\nIn short, this is something outside of the hands of Mobile Web. Perhaps the AST parser could detect and warn about it?", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2012-06-04T12:23:15.000+0000", "updated": "2012-06-04T12:23:15.000+0000" }, { "id": "197109", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Good idea Chris. In fact we should warn for any browser objects being used inadvertently (document, window, etc) and we could just treat \"status\" as one of them. I created ticket TIMOB-9367 to address the general issue, which also addresses this one in specific, so I'm resolving this ticket.", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-04T12:33:21.000+0000", "updated": "2012-06-04T12:33:21.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }