fix(ivy): properly determine the first native node of a view (#33627)

PR Close #33627
This commit is contained in:
Pawel Kozlowski
2019-11-06 15:29:27 +01:00
committed by Kara Erickson
parent c57759f191
commit f63e5d9319
6 changed files with 91 additions and 28 deletions

View File

@ -10,6 +10,7 @@ import {CommonModule} from '@angular/common';
import {ChangeDetectorRef, Component, ComponentFactoryResolver, Directive, EmbeddedViewRef, Injector, NgModule, TemplateRef, ViewChild, ViewContainerRef, ViewRef} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {onlyInIvy} from '@angular/private/testing';
describe('view insertion', () => {
describe('of a simple template', () => {
@ -347,6 +348,26 @@ describe('view insertion', () => {
});
onlyInIvy('VE incorrectly inserts views before ng-container content')
.it('should insert before a view with a ng-container where ViewContainerRef is injected',
() => {
expect(createAndInsertViews(`
<ng-container [ngTemplateOutlet]="after">|before</ng-container>
<ng-template #after>|after</ng-template>
`).textContent)
.toBe('insert|before|after');
});
it('should insert before a view with an element where ViewContainerRef is injected', () => {
expect(createAndInsertViews(`
<div [ngTemplateOutlet]="after">|before</div>
<ng-template #after>|after</ng-template>
`).textContent)
.toBe('insert|before|after');
});
it('should insert before a view with an empty projection as the first root node', () => {
expect(createAndInsertViews(`<ng-content></ng-content>|before`).textContent)
.toBe('insert|before');

View File

@ -263,6 +263,9 @@
{
"name": "findAttrIndexInNode"
},
{
"name": "findComponentView"
},
{
"name": "findDirectiveMatches"
},
@ -311,6 +314,9 @@
{
"name": "getFactoryDef"
},
{
"name": "getFirstNativeNode"
},
{
"name": "getInitialStylingValue"
},
@ -326,6 +332,9 @@
{
"name": "getLView"
},
{
"name": "getLViewParent"
},
{
"name": "getMapProp"
},
@ -344,9 +353,6 @@
{
"name": "getNativeByTNode"
},
{
"name": "getNativeByTNodeOrNull"
},
{
"name": "getNodeInjectable"
},

View File

@ -218,6 +218,9 @@
{
"name": "extractPipeDef"
},
{
"name": "findComponentView"
},
{
"name": "generateExpandoInstructionBlock"
},
@ -245,6 +248,9 @@
{
"name": "getFactoryDef"
},
{
"name": "getFirstNativeNode"
},
{
"name": "getInjectorIndex"
},
@ -257,15 +263,15 @@
{
"name": "getLView"
},
{
"name": "getLViewParent"
},
{
"name": "getNativeAnchorNode"
},
{
"name": "getNativeByTNode"
},
{
"name": "getNativeByTNodeOrNull"
},
{
"name": "getNodeInjectable"
},

View File

@ -665,6 +665,9 @@
{
"name": "getFactoryDef"
},
{
"name": "getFirstNativeNode"
},
{
"name": "getGuardMask"
},
@ -710,9 +713,6 @@
{
"name": "getNativeByTNode"
},
{
"name": "getNativeByTNodeOrNull"
},
{
"name": "getNodeInjectable"
},