fix(ivy): TestBed should use annotation for the last match rather than the first (#28195)

When we look for matching annotations in TestBed, we should always take the last
matching annotation. Otherwise, we will return superclass data for subclasses,
which would have unintended consequences like directives matching the wrong selectors.

PR Close #28195
This commit is contained in:
Kara Erickson
2019-01-16 16:28:04 -08:00
committed by Alex Rickabaugh
parent 8a08ff1571
commit 1f7d3b9a57
3 changed files with 25 additions and 3 deletions

View File

@ -37,7 +37,9 @@ abstract class OverrideResolver<T> implements Resolver<T> {
}
getAnnotation(type: Type<any>): T|null {
return reflection.annotations(type).find(a => a instanceof this.type) || null;
// We should always return the last match from filter(), or we may return superclass data by
// mistake.
return reflection.annotations(type).filter(a => a instanceof this.type).pop() || null;
}
resolve(type: Type<any>): T|null {