fix(injector): support getRootInjectors on dehydrated injectors.
Closes #3760
This commit is contained in:
parent
50eee42668
commit
92da5430e7
|
@ -854,6 +854,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||||
getBoundElementIndex(): number { return this._proto.index; }
|
getBoundElementIndex(): number { return this._proto.index; }
|
||||||
|
|
||||||
getRootViewInjectors(): ElementInjector[] {
|
getRootViewInjectors(): ElementInjector[] {
|
||||||
|
if (!this.hydrated) return [];
|
||||||
var view = this._preBuiltObjects.view;
|
var view = this._preBuiltObjects.view;
|
||||||
var nestedView = view.getNestedView(view.elementOffset + this.getBoundElementIndex());
|
var nestedView = view.getNestedView(view.elementOffset + this.getBoundElementIndex());
|
||||||
return isPresent(nestedView) ? nestedView.rootElementInjectors : [];
|
return isPresent(nestedView) ? nestedView.rootElementInjectors : [];
|
||||||
|
|
|
@ -864,6 +864,12 @@ export function main() {
|
||||||
var inj = injector(extraBindings);
|
var inj = injector(extraBindings);
|
||||||
expect(inj.getRootViewInjectors()).toEqual([]);
|
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", () => {
|
describe("dehydrate", () => {
|
||||||
|
|
Loading…
Reference in New Issue