Permalink
Browse files
fix(ivy): properly insert views before ng-container with injected Vie…
- Loading branch information
|
@@ -682,7 +682,6 @@ function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode|null { |
|
|
TNodeType.IcuContainer, TNodeType.Projection); |
|
|
|
|
|
const tNodeType = tNode.type; |
|
|
|
|
|
if (tNodeType === TNodeType.Element) { |
|
|
return getNativeByTNode(tNode, lView); |
|
|
} else if (tNodeType === TNodeType.Container) { |
|
@@ -692,7 +691,12 @@ function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode|null { |
|
|
if (elIcuContainerChild !== null) { |
|
|
return getFirstNativeNode(lView, elIcuContainerChild); |
|
|
} else { |
|
|
return getNativeByTNode(tNode, lView); |
|
|
const rNodeOrLContainer = lView[tNode.index]; |
|
|
if (isLContainer(rNodeOrLContainer)) { |
|
|
return getBeforeNodeForView(-1, rNodeOrLContainer); |
|
|
} else { |
|
|
return unwrapRNode(rNodeOrLContainer); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
const componentView = lView[DECLARATION_COMPONENT_VIEW]; |
|
|
|
@@ -578,5 +578,37 @@ describe('view insertion', () => { |
|
|
expect(fixture.nativeElement.textContent).toBe('container start|test|container end|click'); |
|
|
}); |
|
|
|
|
|
it('should properly insert before views in a ViewContainerRef injected on ng-container', () => { |
|
|
@Component({ |
|
|
selector: 'app-root', |
|
|
template: ` |
|
|
<ng-template #parameterListItem let-parameter="parameter"> |
|
|
{{parameter}} |
|
|
</ng-template> |
|
|
<ng-container *ngFor="let parameter of items;" |
|
|
[ngTemplateOutlet]="parameterListItem" |
|
|
[ngTemplateOutletContext]="{parameter:parameter}"> |
|
|
</ng-container> |
|
|
` |
|
|
}) |
|
|
class AppComponent { |
|
|
items = [1]; |
|
|
} |
|
|
|
|
|
TestBed.configureTestingModule({ |
|
|
declarations: [AppComponent], |
|
|
imports: [CommonModule], |
|
|
}); |
|
|
|
|
|
const fixture = TestBed.createComponent(AppComponent); |
|
|
fixture.detectChanges(); |
|
|
expect(fixture.nativeElement.textContent.trim()).toContain('1'); |
|
|
|
|
|
fixture.componentInstance.items = [2, 1]; |
|
|
fixture.detectChanges(); |
|
|
|
|
|
expect(fixture.nativeElement.textContent.trim()).toContain('2 1'); |
|
|
}); |
|
|
|
|
|
}); |
|
|
}); |
0 comments on commit
c7a3694