fix(dart/transform): Handle hostAttributes
in DirectiveMetadata
Handle `hostAttributes` in the transformer.
`hostAttributes` was introduced in 51839ca677
Closes #1742
This commit is contained in:
@ -47,6 +47,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||
properties: {},
|
||||
hostListeners: {},
|
||||
hostProperties: {},
|
||||
hostAttributes: {},
|
||||
readAttributes: []);
|
||||
super.visitInstanceCreationExpression(node);
|
||||
}
|
||||
@ -80,6 +81,9 @@ class _DirectiveMetadataVisitor extends Object
|
||||
case 'hostProperties':
|
||||
_populateHostProperties(node.expression);
|
||||
break;
|
||||
case 'hostAttributes':
|
||||
_populateHostAttributes(node.expression);
|
||||
break;
|
||||
case 'hostListeners':
|
||||
_populateHostListeners(node.expression);
|
||||
}
|
||||
@ -155,4 +159,20 @@ class _DirectiveMetadataVisitor extends Object
|
||||
meta.hostProperties[sKey] = sVal;
|
||||
}
|
||||
}
|
||||
|
||||
void _populateHostAttributes(Expression hostAttributeValue) {
|
||||
if (hostAttributeValue is! MapLiteral) {
|
||||
logger.error('Angular 2 currently only supports map literal values for '
|
||||
'Directive#hostAttributes.'
|
||||
' Source: ${hostAttributeValue}');
|
||||
return;
|
||||
}
|
||||
for (MapLiteralEntry entry in (hostAttributeValue as MapLiteral).entries) {
|
||||
var sKey =
|
||||
_expressionToString(entry.key, 'Directive#hostAttributes keys');
|
||||
var sVal =
|
||||
_expressionToString(entry.value, 'Directive#hostAttributes values');
|
||||
meta.hostAttributes[sKey] = sVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user