Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1064] ListView parser should remove Templates node after processing the templates

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-08-05T05:31:15.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.5.0
ComponentsTooling
Labelsqe-manualtest
ReporterTim Poulsen
AssigneeFeon Sua Xin Miao
Created2014-06-30T19:28:17.000+0000
Updated2014-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));

Comments

  1. Feon Sua Xin Miao 2014-08-04

    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:
       128     $.__views.__alloyId0 = Alloy.createWidget("foo", "widget", {
       129         id: "__alloyId0",
       130         children: [ $.__views.__alloyId1 ],
       131         __parentSymbol: $.__views.index
       132     });
       
  2. Federico Casali 2014-09-13

    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.

JSON Source