Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1541] XML: Require LeftNavButtons/RightNavButtons not working

GitHub Issuen/a
TypeBug
PriorityCritical
StatusResolved
ResolutionFixed
Resolution Date2017-02-16T09:10:06.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.2.0, alloy 1.9.9
ComponentsXML
Labelsalloy
ReporterHazem Khaled
AssigneeFeon Sua Xin Miao
Created2017-02-02T10:17:56.000+0000
Updated2018-03-05T17:44:34.000+0000

Description

Require LeftNavButton/RightNavButton working while LeftNavButtons/RightNavButtons not working example
<Alloy>
	<NavigationWindow>
		<Window class="container">
			<Require src="navbar" />
			<Label id="label">Hello, World</Label>
		</Window>
	</NavigationWindow>
</Alloy>
<Alloy>
	<LeftNavButtons>
		<Button>Btn1</Button>
		<Button>Btn2</Button>
	</LeftNavButtons>
</Alloy>
compiled code problem
    var leftNavButtons = [];
    $.__views.__alloyId2 = Ti.UI.createButton({
        title: "aaa",
        id: "__alloyId2"
    });
    leftNavButtons.push($.__views.__alloyId2);
    $.__views.__alloyId3 = Ti.UI.createButton({
        title: "bbb",
        id: "__alloyId3"
    });
    leftNavButtons.push($.__views.__alloyId3);
    // >>>>> THIS IS THE ERROR <<<<< //
    void 0.leftNavButtons = leftNavButtons;
    $.__views.navbar && $.addTopLevelView($.__views.navbar);
while LeftNavButton compile to
    $.__views.__alloyId2 = Ti.UI.createButton({
        title: "Btn1",
        id: "__alloyId2"
    });
    __parentSymbol.leftNavButton = $.__views.__alloyId2;
    $.__views.navbar && $.addTopLevelView($.__views.navbar);

Comments

  1. Hans Knöchel 2017-02-02

    Hey [~hazemkhaled], thanks for the ticket! Looks like you already digged into it, are you able to provide a fix as well? :-)
  2. Hazem Khaled 2017-02-02

    Yes I'm but no luck, first time to dig into Alloy compile, if you guide where to hack I'll do it. Thanks
  3. Hans Knöchel 2017-02-02

    [~fmiao] can you assist this man?
  4. Feon Sua Xin Miao 2017-02-07

    [~hazemkhaled], looks like the parent symbol is not probably set when LeftNavButtons/RightNavButtons is in another view. The exact location you can look into is, https://github.com/appcelerator/alloy/blob/master/Alloy/commands/compile/parsers/Alloy.Abstract._ItemArray.js#L110 Try setting the parent symbol to the default CONST.PARENT_SYMBOL_VAR if it's not in the parsing state. That should fix it.
  5. Feon Sua Xin Miao 2017-02-14

    PR: https://github.com/appcelerator/alloy/pull/816 Functional Test: 1. Run the test app included in the PR. 2. There should be no compile error.

JSON Source