parent
2f7045720a
commit
386cc5dbb6
|
@ -103,7 +103,8 @@ export function main() {
|
|||
selectors: [new CompileTokenMetadata({value: 'selector'})],
|
||||
descendants: true,
|
||||
first: false,
|
||||
propertyName: 'prop'
|
||||
propertyName: 'prop',
|
||||
read: new CompileTokenMetadata({value: 'readToken'})
|
||||
})
|
||||
],
|
||||
viewQueries: [
|
||||
|
@ -111,7 +112,8 @@ export function main() {
|
|||
selectors: [new CompileTokenMetadata({value: 'selector'})],
|
||||
descendants: true,
|
||||
first: false,
|
||||
propertyName: 'prop'
|
||||
propertyName: 'prop',
|
||||
read: new CompileTokenMetadata({value: 'readToken'})
|
||||
})
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1010,16 +1010,24 @@ List<CompileDiDependencyMetadata> _readDeps(ListLiteral deps) {
|
|||
_createQueryMetadata(Annotation a, bool defaultDescendantsValue, bool first, String propertyName) {
|
||||
final selector = _readToken(a.arguments.arguments.first);
|
||||
var descendants = defaultDescendantsValue;
|
||||
var read = null;
|
||||
a.arguments.arguments.skip(0).forEach((arg) {
|
||||
if (arg is NamedExpression && arg.name.toString() == "descendants:")
|
||||
descendants = naiveEval(arg.expression);
|
||||
if (arg is NamedExpression) {
|
||||
var name = arg.name.toString();
|
||||
if (name == "descendants:") {
|
||||
descendants = naiveEval(arg.expression);
|
||||
} else if (name == "read:") {
|
||||
read = _readToken(arg.expression);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final selectors = selector.value is String ?
|
||||
selector.value.split(",").map( (value) => new CompileTokenMetadata(value: value) ).toList() :
|
||||
[selector];
|
||||
return new CompileQueryMetadata(
|
||||
selectors: selectors, descendants: descendants, first: first, propertyName: propertyName);
|
||||
selectors: selectors, descendants: descendants, first: first,
|
||||
read: read, propertyName: propertyName);
|
||||
}
|
||||
|
||||
List<CompileDiDependencyMetadata> _getCompileDiDependencyMetadata(
|
||||
|
|
|
@ -260,6 +260,9 @@ class _NgMetaIdentifierResolver {
|
|||
void _resolveQueries(Map<String, NgMeta> ngMetaMap, List queries, String neededBy) {
|
||||
queries.forEach((q) {
|
||||
q.selectors.forEach((s) => s.identifier = _resolveIdentifier(ngMetaMap, neededBy, s.identifier));
|
||||
if (q.read != null) {
|
||||
q.read.identifier = _resolveIdentifier(ngMetaMap, neededBy, q.read.identifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -134,13 +134,17 @@ void allTests() {
|
|||
new CompileTypeMetadata(name: 'Service', moduleUrl: 'moduleUrl');
|
||||
|
||||
fooComponentMeta.queries = [
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))]),
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(value: 'one')])
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))],
|
||||
read: new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))),
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(value: 'one')],
|
||||
read: new CompileTokenMetadata(value: 'one'))
|
||||
];
|
||||
|
||||
fooComponentMeta.viewQueries = [
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))]),
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(value: 'one')])
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))],
|
||||
read: new CompileTokenMetadata(identifier: new CompileIdentifierMetadata(name: 'Service'))),
|
||||
new CompileQueryMetadata(selectors: [new CompileTokenMetadata(value: 'one')],
|
||||
read: new CompileTokenMetadata(value: 'one'))
|
||||
];
|
||||
|
||||
fooNgMeta.ngDeps.imports.add(new ImportModel()..uri = 'bar.dart');
|
||||
|
@ -155,11 +159,17 @@ void allTests() {
|
|||
|
||||
expect(cmp.queries[0].selectors[0].identifier.name, equals("Service"));
|
||||
expect(cmp.queries[0].selectors[0].identifier.moduleUrl, equals("moduleUrl"));
|
||||
expect(cmp.queries[0].read.identifier.name, equals("Service"));
|
||||
expect(cmp.queries[0].read.identifier.moduleUrl, equals("moduleUrl"));
|
||||
expect(cmp.queries[1].selectors[0].value, equals("one"));
|
||||
expect(cmp.queries[1].read.value, equals("one"));
|
||||
|
||||
expect(cmp.viewQueries[0].selectors[0].identifier.name, equals("Service"));
|
||||
expect(cmp.viewQueries[0].selectors[0].identifier.moduleUrl, equals("moduleUrl"));
|
||||
expect(cmp.viewQueries[0].read.identifier.name, equals("Service"));
|
||||
expect(cmp.viewQueries[0].read.identifier.moduleUrl, equals("moduleUrl"));
|
||||
expect(cmp.viewQueries[1].selectors[0].value, equals("one"));
|
||||
expect(cmp.viewQueries[1].read.value, equals("one"));
|
||||
});
|
||||
|
||||
test('should resolve providers from types.', () async {
|
||||
|
|
|
@ -590,10 +590,12 @@ void allTests() {
|
|||
expect(deps[5].isOptional, isTrue);
|
||||
expect(deps[6].query.selectors[0].name, equals("ServiceDep"));
|
||||
expect(deps[6].query.descendants, isTrue);
|
||||
expect(deps[6].query.read.identifier.name, equals("ServiceDep"));
|
||||
expect(deps[7].query.selectors[0].identifier.name, equals("ServiceDep"));
|
||||
expect(deps[7].query.descendants, isTrue);
|
||||
expect(deps[8].viewQuery.selectors[0].value, equals("one"));
|
||||
expect(deps[8].viewQuery.selectors[1].value, equals("two"));
|
||||
expect(deps[8].viewQuery.read.value, equals("three"));
|
||||
expect(deps[9].viewQuery.selectors[0].value, equals("one"));
|
||||
expect(deps[9].viewQuery.selectors[1].value, equals("two"));
|
||||
expect(deps[10].token.identifier.name, equals("ServiceDep"));
|
||||
|
|
|
@ -141,9 +141,9 @@ class ComponentWithDiDeps {
|
|||
@Self() ServiceDep arg4,
|
||||
@SkipSelf() ServiceDep arg5,
|
||||
@Optional() ServiceDep arg6,
|
||||
@Query(ServiceDep, descendants: true) arg7,
|
||||
@Query(ServiceDep, descendants: true, read: ServiceDep) arg7,
|
||||
@ContentChildren(ServiceDep) arg8,
|
||||
@ViewQuery("one,two") arg9,
|
||||
@ViewQuery("one,two", read: "three") arg9,
|
||||
@ViewChildren("one,two") arg10,
|
||||
this.arg11,
|
||||
[@Optional() ServiceDep arg12,
|
||||
|
|
Loading…
Reference in New Issue