fix(transformer): record HostBinding annotations applied to getters

Closes #6283
This commit is contained in:
vsavkin 2016-01-05 18:56:59 -08:00 committed by Victor Savkin
parent 761c6d0df7
commit a593ffa6f3
3 changed files with 16 additions and 1 deletions

View File

@ -294,6 +294,15 @@ class _DirectiveMetadataVisitor extends Object
final params = _getHostListenerParams(meta); final params = _getHostListenerParams(meta);
_host['(${eventName})'] = '${node.name}($params)'; _host['(${eventName})'] = '${node.name}($params)';
} }
if (_isAnnotation(meta, 'HostBinding') && node.isGetter) {
final renamed = _getRenamedValue(meta);
if (renamed != null) {
_host['[${renamed}]'] = '${node.name}';
} else {
_host['[${node.name}]'] = '${node.name}';
}
}
} }
return null; return null;
} }

View File

@ -552,7 +552,7 @@ void allTests() {
it('should merge host bindings from the annotation and fields.', () async { it('should merge host bindings from the annotation and fields.', () async {
var model = await _testCreateModel('directives_files/components.dart'); var model = await _testCreateModel('directives_files/components.dart');
expect(model.types['ComponentWithHostBindings'].hostProperties) expect(model.types['ComponentWithHostBindings'].hostProperties)
.toEqual({'a': 'a', 'b': 'b', 'renamed': 'c'}); .toEqual({'a': 'a', 'b': 'b', 'renamed': 'c', 'd': 'd', 'get-renamed': 'e'});
}); });
it('should merge host listeners from the annotation and fields.', () async { it('should merge host listeners from the annotation and fields.', () async {

View File

@ -67,6 +67,12 @@ class ComponentWithInputs {
class ComponentWithHostBindings { class ComponentWithHostBindings {
@HostBinding() Object b; @HostBinding() Object b;
@HostBinding('renamed') Object c; @HostBinding('renamed') Object c;
Object _d;
@HostBinding() Object get d => _d;
Object _e;
@HostBinding('get-renamed') Object get e => _e;
} }
@Component( @Component(