{ "id": "121320", "key": "ALOY-851", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "15758", "description": "Alloy 1.4.0", "name": "Alloy 1.4.0", "archived": false, "released": true, "releaseDate": "2014-07-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-01-21T22:28:02.000+0000", "created": "2013-10-17T14:33:51.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "alloy", "compiler", "conditions", "platform", "qe-testadded" ], "versions": [], "issuelinks": [ { "id": "49318", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "151952", "key": "ALOY-1317", "fields": { "summary": "Alloy: Default top-level ID doesn't take if-attribute into account", "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": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2015-10-12T08:08:02.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": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "The compiler sets the id of the first top-level XML view element to the default (the controller name) *before* the platform conditions are evaluated. Now if you have a view in which you use the {{platform}} attribute to select which top-level element should be used for each platform, this leads to unpredictable behavior. Only the first (conditional) top-level element will get the default id.\r\n\r\nh1. Steps to reproduce\r\n1. Create new project: {{titanium create -p ios,android -n defaultid --id ti.defaultid -d .}}\r\n2. Initialize Alloy: {{cd defaultid && alloy new}}\r\n3. Replace contents of {{index.xml}} with:\r\n {code}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {code}\r\n4. Compile for iOS: {{alloy compile -c platform=ios}}\r\n5. Open {{Resources/alloy/controllers/index.js}} and see that the window has correctly been given {{index}} as id.\r\n4. Compile for Android: {{alloy compile -c platform=android}}\r\n5. Open {{Resources/alloy/controllers/index.js}} and see that the window has *not* been given {{index}} as id.", "attachment": [], "flagged": false, "summary": "Alloy: Setting default ID on first top-level XML view element doesn't take platform attribute into account", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "environment": "Alloy 1.2.2", "comment": { "comments": [ { "id": "289018", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "I can confirm the behavior is present as described.\n\n{code:title=iOS build results}\n$.__views.index = Ti.UI.createWindow({\n id: \"index\"\n});\n{code}\n\n{code:title=Android build results}\n$.__views.index = Ti.UI.createWindow({\n id: \"__alloyId0\"\n});\n{code}", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-01-21T14:18:36.000+0000", "updated": "2014-01-21T14:18:36.000+0000" }, { "id": "289138", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm going to solve 2 for 1 here, since in addition to this, the event handler is rendered twice, once for each platform despite that only one should be generated. \r\n\r\nPR: https://github.com/appcelerator/alloy/pull/304\r\n\r\nFunctional testing should be the same as noted in the description and previous comments. In addition to validating that the default id gets applied in the android case, also assert that in both cases that only one event handler gets assigned. You can assert this by making sure there is on;y one line like this at the bottom of the generated controllers:\r\n\r\n{code:javascript}\r\n__defers[\"$.__views.label!click!doClick\"] && $.__views.label.addEventListener(\"click\", doClick);\r\n{code}\r\n\r\nPrior to this fix, the event handler would have showed up twice, one right after the other.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-21T22:28:02.000+0000", "updated": "2014-01-21T22:28:02.000+0000" }, { "id": "289194", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Wow, never noticed that double event handler. Nice to have that fixed ;)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2014-01-22T08:34:03.000+0000", "updated": "2014-01-22T08:34:03.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }