fix(transformer): record HostBinding annotations applied to getters
Closes #6283
This commit is contained in:
parent
761c6d0df7
commit
a593ffa6f3
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue