parent
11325bad4a
commit
8934b736c8
@ -513,11 +513,11 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null {
|
|||||||
// We've got a parent which is an element in the current view. We just need to verify if the
|
// We've got a parent which is an element in the current view. We just need to verify if the
|
||||||
// parent element is not a component. Component's content nodes are not inserted immediately
|
// parent element is not a component. Component's content nodes are not inserted immediately
|
||||||
// because they will be projected, and so doing insert at this point would be wasteful.
|
// because they will be projected, and so doing insert at this point would be wasteful.
|
||||||
// Since the projection would than move it to its final destination.
|
// Since the projection would then move it to its final destination.
|
||||||
if (!(parent.flags & TNodeFlags.isComponent)) {
|
if (parent.flags & TNodeFlags.isComponent) {
|
||||||
return getNativeByTNode(parent, currentView) as RElement;
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
|
} else {
|
||||||
|
return getNativeByTNode(parent, currentView) as RElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2576,68 +2576,65 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('transclusion', () => {
|
describe('transclusion', () => {
|
||||||
fixmeIvy('FW-714: ng1 projected content is not being rendered')
|
it('should support single-slot transclusion', async(() => {
|
||||||
.it('should support single-slot transclusion', async(() => {
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
let ng2ComponentAInstance: Ng2ComponentA;
|
||||||
let ng2ComponentAInstance: Ng2ComponentA;
|
let ng2ComponentBInstance: Ng2ComponentB;
|
||||||
let ng2ComponentBInstance: Ng2ComponentB;
|
|
||||||
|
|
||||||
// Define `ng1Component`
|
// Define `ng1Component`
|
||||||
const ng1Component: angular.IComponent = {
|
const ng1Component: angular.IComponent = {
|
||||||
template: 'ng1(<div ng-transclude></div>)',
|
template: 'ng1(<div ng-transclude></div>)',
|
||||||
transclude: true
|
transclude: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ng2A',
|
selector: 'ng2A',
|
||||||
template: 'ng2A(<ng1>{{ value }} | <ng2B *ngIf="showB"></ng2B></ng1>)'
|
template: 'ng2A(<ng1>{{ value }} | <ng2B *ngIf="showB"></ng2B></ng1>)'
|
||||||
})
|
})
|
||||||
class Ng2ComponentA {
|
class Ng2ComponentA {
|
||||||
value = 'foo';
|
value = 'foo';
|
||||||
showB = false;
|
showB = false;
|
||||||
constructor() { ng2ComponentAInstance = this; }
|
constructor() { ng2ComponentAInstance = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'ng2B', template: 'ng2B({{ value }})'})
|
@Component({selector: 'ng2B', template: 'ng2B({{ value }})'})
|
||||||
class Ng2ComponentB {
|
class Ng2ComponentB {
|
||||||
value = 'bar';
|
value = 'bar';
|
||||||
constructor() { ng2ComponentBInstance = this; }
|
constructor() { ng2ComponentBInstance = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1Module', [])
|
||||||
angular.module('ng1Module', [])
|
.component('ng1', ng1Component)
|
||||||
.component('ng1', ng1Component)
|
.directive('ng2A', adapter.downgradeNg2Component(Ng2ComponentA));
|
||||||
.directive('ng2A', adapter.downgradeNg2Component(Ng2ComponentA));
|
|
||||||
|
|
||||||
// Define `Ng2Module`
|
// Define `Ng2Module`
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
declarations:
|
declarations: [adapter.upgradeNg1Component('ng1'), Ng2ComponentA, Ng2ComponentB]
|
||||||
[adapter.upgradeNg1Component('ng1'), Ng2ComponentA, Ng2ComponentB]
|
})
|
||||||
})
|
class Ng2Module {
|
||||||
class Ng2Module {
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
const element = html(`<ng2-a></ng2-a>`);
|
const element = html(`<ng2-a></ng2-a>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1Module']).ready((ref) => {
|
||||||
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(foo | ))');
|
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(foo | ))');
|
||||||
|
|
||||||
ng2ComponentAInstance.value = 'baz';
|
ng2ComponentAInstance.value = 'baz';
|
||||||
ng2ComponentAInstance.showB = true;
|
ng2ComponentAInstance.showB = true;
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(baz | ng2B(bar)))');
|
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(baz | ng2B(bar)))');
|
||||||
|
|
||||||
ng2ComponentBInstance.value = 'qux';
|
ng2ComponentBInstance.value = 'qux';
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(baz | ng2B(qux)))');
|
expect(multiTrim(element.textContent)).toBe('ng2A(ng1(baz | ng2B(qux)))');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should support single-slot transclusion with fallback content', async(() => {
|
it('should support single-slot transclusion with fallback content', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
@ -2943,22 +2940,21 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fixmeIvy('FW-714: ng1 projected content is not being rendered')
|
it('should support structural directives in transcluded content', async(() => {
|
||||||
.it('should support structural directives in transcluded content', async(() => {
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
let ng2ComponentInstance: Ng2Component;
|
||||||
let ng2ComponentInstance: Ng2Component;
|
|
||||||
|
|
||||||
// Define `ng1Component`
|
// Define `ng1Component`
|
||||||
const ng1Component: angular.IComponent = {
|
const ng1Component: angular.IComponent = {
|
||||||
template:
|
template:
|
||||||
'ng1(x(<div ng-transclude="slotX"></div>) | default(<div ng-transclude=""></div>))',
|
'ng1(x(<div ng-transclude="slotX"></div>) | default(<div ng-transclude=""></div>))',
|
||||||
transclude: {slotX: 'contentX'}
|
transclude: {slotX: 'contentX'}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
template: `
|
template: `
|
||||||
ng2(
|
ng2(
|
||||||
<ng1>
|
<ng1>
|
||||||
<content-x><div *ngIf="show">{{ x }}1</div></content-x>
|
<content-x><div *ngIf="show">{{ x }}1</div></content-x>
|
||||||
@ -2967,51 +2963,47 @@ withEachNg1Version(() => {
|
|||||||
<div *ngIf="show">{{ y }}2</div>
|
<div *ngIf="show">{{ y }}2</div>
|
||||||
</ng1>
|
</ng1>
|
||||||
)`
|
)`
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
x = 'foo';
|
x = 'foo';
|
||||||
y = 'bar';
|
y = 'bar';
|
||||||
show = true;
|
show = true;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() { ng2ComponentInstance = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1Module', [])
|
||||||
angular.module('ng1Module', [])
|
.component('ng1', ng1Component)
|
||||||
.component('ng1', ng1Component)
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
|
||||||
|
|
||||||
// Define `Ng2Module`
|
// Define `Ng2Module`
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
declarations: [adapter.upgradeNg1Component('ng1'), Ng2Component],
|
declarations: [adapter.upgradeNg1Component('ng1'), Ng2Component],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
class Ng2Module {
|
class Ng2Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
expect(multiTrim(element.textContent, true))
|
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
||||||
.toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
|
||||||
|
|
||||||
ng2ComponentInstance.x = 'baz';
|
ng2ComponentInstance.x = 'baz';
|
||||||
ng2ComponentInstance.y = 'qux';
|
ng2ComponentInstance.y = 'qux';
|
||||||
ng2ComponentInstance.show = false;
|
ng2ComponentInstance.show = false;
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true))
|
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
||||||
.toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
|
||||||
|
|
||||||
ng2ComponentInstance.show = true;
|
ng2ComponentInstance.show = true;
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true))
|
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
||||||
.toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
});
|
||||||
});
|
}));
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should bind input properties (<) of components', async(() => {
|
it('should bind input properties (<) of components', async(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user