fix(injector): support getRootInjectors on dehydrated injectors.

Closes #3760
This commit is contained in:
Rado Kirov 2015-08-20 16:25:25 -07:00 committed by Rado Kirov
parent 50eee42668
commit 92da5430e7
2 changed files with 7 additions and 0 deletions

View File

@ -854,6 +854,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
getBoundElementIndex(): number { return this._proto.index; }
getRootViewInjectors(): ElementInjector[] {
if (!this.hydrated) return [];
var view = this._preBuiltObjects.view;
var nestedView = view.getNestedView(view.elementOffset + this.getBoundElementIndex());
return isPresent(nestedView) ? nestedView.rootElementInjectors : [];

View File

@ -864,6 +864,12 @@ export function main() {
var inj = injector(extraBindings);
expect(inj.getRootViewInjectors()).toEqual([]);
});
it("should return an empty array on a dehydrated view", () => {
var inj = injector(extraBindings);
inj.dehydrate();
expect(inj.getRootViewInjectors()).toEqual([]);
});
});
describe("dehydrate", () => {