parent
cd89eb8404
commit
36648293a8
|
@ -11,7 +11,7 @@
|
|||
|
||||
import {ChangeDetectorRef as viewEngine_ChangeDetectorRef} from '../change_detection/change_detector_ref';
|
||||
import {InjectionToken} from '../di/injection_token';
|
||||
import {InjectFlags, Injector, inject, setCurrentInjector} from '../di/injector';
|
||||
import {InjectFlags, Injector, NullInjector, inject, setCurrentInjector} from '../di/injector';
|
||||
import * as viewEngine from '../linker';
|
||||
import {Type} from '../type';
|
||||
|
||||
|
@ -636,20 +636,23 @@ class NodeInjector implements Injector {
|
|||
class ViewContainerRef implements viewEngine.ViewContainerRef {
|
||||
private _viewRefs: viewEngine.ViewRef[] = [];
|
||||
|
||||
|
||||
constructor(
|
||||
private _lContainerNode: LContainerNode, private _hostNode: LElementNode|LContainerNode) {}
|
||||
|
||||
get element(): ElementRef { return new ElementRef(this._hostNode.native); }
|
||||
get element(): ElementRef {
|
||||
const injector = getOrCreateNodeInjectorForNode(this._hostNode);
|
||||
return getOrCreateElementRef(injector);
|
||||
}
|
||||
|
||||
get injector(): Injector {
|
||||
return new NodeInjector(getOrCreateNodeInjectorForNode(this._hostNode));
|
||||
const injector = getOrCreateNodeInjectorForNode(this._hostNode);
|
||||
return new NodeInjector(injector);
|
||||
}
|
||||
|
||||
/** @deprecated No replacement */
|
||||
get parentInjector(): Injector {
|
||||
const parentLInjector = getParentLNode(this._hostNode).nodeInjector;
|
||||
return parentLInjector ? new NodeInjector(parentLInjector) : Injector.NULL;
|
||||
return parentLInjector ? new NodeInjector(parentLInjector) : new NullInjector();
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
|
|
|
@ -336,7 +336,7 @@ export function createLViewData<T>(
|
|||
null, // directives
|
||||
null, // cleanupInstances
|
||||
context, // context
|
||||
viewData && viewData[INJECTOR] || null, // injector
|
||||
viewData ? viewData[INJECTOR] : null, // injector
|
||||
renderer, // renderer
|
||||
sanitizer || null, // sanitizer
|
||||
null, // tail
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
{
|
||||
"name": "ChangeDetectionStrategy"
|
||||
},
|
||||
{
|
||||
"name": "ChangeDetectorRef"
|
||||
},
|
||||
{
|
||||
"name": "DECLARATION_VIEW"
|
||||
},
|
||||
|
@ -146,6 +149,9 @@
|
|||
{
|
||||
"name": "TVIEW"
|
||||
},
|
||||
{
|
||||
"name": "TemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "TemplateRef$1"
|
||||
},
|
||||
|
@ -180,7 +186,7 @@
|
|||
"name": "VIEWS"
|
||||
},
|
||||
{
|
||||
"name": "ViewContainerRef$1"
|
||||
"name": "ViewContainerRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewContainerRef$1"
|
||||
|
|
|
@ -1039,10 +1039,8 @@ describe('ViewContainerRef', () => {
|
|||
describe('getters', () => {
|
||||
it('should work on elements', () => {
|
||||
function createTemplate() {
|
||||
elementStart(0, 'header', ['vcref', '']);
|
||||
elementEnd();
|
||||
elementStart(1, 'footer');
|
||||
elementEnd();
|
||||
element(0, 'header', ['vcref', '']);
|
||||
element(1, 'footer');
|
||||
}
|
||||
|
||||
new TemplateFixture(createTemplate, undefined, [DirectiveWithVCRef]);
|
||||
|
@ -1060,10 +1058,8 @@ describe('ViewContainerRef', () => {
|
|||
createComponent('header-cmp', function(rf: RenderFlags, ctx: any) {});
|
||||
|
||||
function createTemplate() {
|
||||
elementStart(0, 'header-cmp', ['vcref', '']);
|
||||
elementEnd();
|
||||
elementStart(1, 'footer');
|
||||
elementEnd();
|
||||
element(0, 'header-cmp', ['vcref', '']);
|
||||
element(1, 'footer');
|
||||
}
|
||||
|
||||
new TemplateFixture(createTemplate, undefined, [HeaderComponent, DirectiveWithVCRef]);
|
||||
|
@ -1079,8 +1075,7 @@ describe('ViewContainerRef', () => {
|
|||
it('should work on containers', () => {
|
||||
function createTemplate() {
|
||||
container(0, embeddedTemplate, undefined, ['vcref', '']);
|
||||
elementStart(1, 'footer');
|
||||
elementEnd();
|
||||
element(1, 'footer');
|
||||
}
|
||||
|
||||
function updateTemplate() {
|
||||
|
|
Loading…
Reference in New Issue