Skip to content

Commit

Permalink
fix(transformer): record HostBinding annotations applied to getters
Browse files Browse the repository at this point in the history
Closes #6283
  • Loading branch information
vsavkin committed Jan 21, 2016
1 parent 761c6d0 commit a593ffa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ class _DirectiveMetadataVisitor extends Object
final params = _getHostListenerParams(meta);
_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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void allTests() {
it('should merge host bindings from the annotation and fields.', () async {
var model = await _testCreateModel('directives_files/components.dart');
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class ComponentWithInputs {
class ComponentWithHostBindings {
@HostBinding() Object b;
@HostBinding('renamed') Object c;

Object _d;
@HostBinding() Object get d => _d;

Object _e;
@HostBinding('get-renamed') Object get e => _e;
}

@Component(
Expand Down

0 comments on commit a593ffa

Please sign in to comment.