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
13 changes: 12 additions & 1 deletion Alloy/commands/compile/compilerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ exports.getParserArgs = function(node, state, opts) {
});
} else {
var theValue = node.getAttribute(attrName);

// find platform specific attributes
var attributeParts = attrName.split(':');
if ( attributeParts.length === 2 && _.includes(CONST.PLATFORMS, attributeParts[0])) {
// if this attribute is for this platform, create it without namespace.
if ( attributeParts[0] === compilerConfig.alloyConfig.platform ) {
attrName = attributeParts[1];
} else {
return;
}
}

if (/(^|\+)\s*(?:(?:Ti|Titanium|Alloy.Globals|Alloy.CFG)\.|L\(.+\)\s*$)/.test(theValue)) {
var match = theValue.match(/^\s*L\([^'"]+\)\s*$/);
if (match !== null) {
Expand All @@ -220,7 +232,6 @@ exports.getParserArgs = function(node, state, opts) {
theValue = styler.STYLE_EXPR_PREFIX + theValue;
}


if (attrName === 'class') {
if (autoStyle) {
createArgs[CONST.CLASS_PROPERTY] = theValue.split(/\s+/) || [];
Expand Down