Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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