Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALOY-1646] Add support for platform specific namespaces for xml attributes #922

Merged
merged 8 commits into from
Mar 29, 2019
11 changes: 11 additions & 0 deletions Alloy/commands/compile/parsers/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ function parse(node, state, args) {
args.symbol = CU.generateUniqueId();
}

// find platform specific attributes
var platformAttributes = _.filter(_.keys(args.createArgs), key => _.includes(key, ':'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than looping through all the keys again in this file, I think it would be better to do this in the initial pass in compilerUtils.getParserArgs. Filtering out any args that aren't for the platform and removing the platform prefix from the attribute.

_.forEach(platformAttributes, attribute => {
var attributeParts = attribute.split(':');
// if this attribute is for this platform, create it without namespace.
if ( attributeParts[0] === platform ) {
args.createArgs[attributeParts[1]] = args.createArgs[attribute];
}
delete args.createArgs[attribute];
});

// Generate runtime code
if (state.isViewTemplate) {
var bindId = node.getAttribute('bindId');
Expand Down