Skip to content

Commit

Permalink
fix: allow using widget as primary control in XML View (#949)
Browse files Browse the repository at this point in the history
Fixes ALOY-1256
  • Loading branch information
brentonhouse authored Apr 27, 2020
1 parent 63c13aa commit 9e10163
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Alloy/commands/compile/parsers/Alloy.Require.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,24 @@ function parse(node, state, args) {
type === 'widget' ? 'Alloy.Widget' : 'Alloy.Require',
args.createArgs,
state
) + ');\n';
if (args.parent.symbol && !state.templateObject && !state.androidMenu) {
code += args.symbol + '.setParent(' + args.parent.symbol + ');\n';
) + ')';
let parent = { symbol: args.symbol };
if (args.parent.symbol && !state.templateObject && !state.androidMenu && !state.insideContainer) {
code += ';\n' + args.symbol + '.setParent(' + args.parent.symbol + ');\n';
parent = {
symbol: args.symbol + '.getViewEx({recurse:true})'
};
} else if ( state.insideContainer ) {
code += ';\n';
parent = {
symbol: args.symbol + '.getViewEx({recurse:true})'
};
} else {
code += '.getViewEx({recurse:true});\n';
}

return {
parent: {
symbol: args.symbol + '.getViewEx({recurse:true})'
},
parent: parent,
controller: args.symbol,
styles: state.styles,
code: code
Expand Down
1 change: 1 addition & 0 deletions Alloy/commands/compile/parsers/Ti.UI.Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function parse(node, state, args) {
if (theNode) {
code += CU.generateNodeExtended(child, state, {
parent: {},
insideContainer: true,
post: function(node, state, args) {
windowSymbol = state.parent.symbol;
}
Expand Down

0 comments on commit 9e10163

Please sign in to comment.