[ALOY-1541] XML: Require LeftNavButtons/RightNavButtons not working
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2017-02-16T09:10:06.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.2.0, alloy 1.9.9 |
Components | XML |
Labels | alloy |
Reporter | Hazem Khaled |
Assignee | Feon Sua Xin Miao |
Created | 2017-02-02T10:17:56.000+0000 |
Updated | 2018-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);
Hey [~hazemkhaled], thanks for the ticket! Looks like you already digged into it, are you able to provide a fix as well? :-)
Yes I'm but no luck, first time to dig into Alloy compile, if you guide where to hack I'll do it. Thanks
[~fmiao] can you assist this man?
[~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 defaultCONST.PARENT_SYMBOL_VAR
if it's not in the parsing state. That should fix it.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.