[ALOY-1064] ListView parser should remove Templates node after processing the templates
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-08-05T05:31:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.5.0 |
Components | Tooling |
Labels | qe-manualtest |
Reporter | Tim Poulsen |
Assignee | Feon Sua Xin Miao |
Created | 2014-06-30T19:28:17.000+0000 |
Updated | 2014-09-13T16:40:54.000+0000 |
Description
Given a project containing a widget and this in index.xml:
<Alloy>
<Window>
<Widget src="foo">
<ListView>
<Templates>
<ItemTemplate name="first">
<!-- ... ... ... -->
</ItemTemplate>
<ItemTemplate name="second">
<!-- ... ... ... -->
</ItemTemplate>
</Templates>
</ListView>
</Widget>
</Window>
</Alloy>
The widget receives an arguments object containing two extra null
values which presumably correspond to the ItemTemplate tags. Those should be removed by the Ti.UI.ListView.js parser.
Generated code without this change:
$.__views.__alloyId0 = Alloy.createWidget("foo", "widget", {
id: "__alloyId0",
children: [ , , $.__views.__alloyId1 ],
__parentSymbol: $.__views.index
});
Using child views of Widget other than ListView (such as using a pair of Views) does not pass those null values via the children array.
Workaround: reference the children array like this:
var kids = _.compact(arguments[0].children);
Ti.API.info(JSON.stringify(kids));
PR: https://github.com/appcelerator/alloy/pull/499 Test app: https://github.com/feons/alloy/tree/ALOY-1064/test/apps/testing/ALOY-1064 Functional Test: 1. Compile test app on iOS 2. There should be no null values for widget's children property. The generated code should look like this:
Verified fixed on iOS 8 (iPAD mini) and Android 4.3 TiSDK 3.4.0.v20140912164913 Appcelerator Studio 3.4.0.201409121853 CLI 3.4.0-rc3 Alloy 1.5.0-rc Xcode6 GM Closing.