Skip to content

Commit

Permalink
fix(injector): support getRootInjectors on dehydrated injectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkirov committed Aug 24, 2015
1 parent 50eee42 commit 92da543
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/angular2/src/core/compiler/element_injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [];
Expand Down
6 changes: 6 additions & 0 deletions modules/angular2/test/core/compiler/element_injector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 92da543

Please sign in to comment.