Skip to content

Commit

Permalink
refactor(ivy): separate container into 2 instructions (#25509)
Browse files Browse the repository at this point in the history
PR Close #25509
  • Loading branch information
kara authored and jasonaden committed Aug 16, 2018
1 parent abcc430 commit 6482f6f
Show file tree
Hide file tree
Showing 26 changed files with 228 additions and 208 deletions.
Expand Up @@ -648,7 +648,7 @@ describe('compiler compliance', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵelementStart(0, "ul", null, $c1$);
$r3$.ɵcontainer(2, MyComponent_li_Template_2, null, $c2$);
$r3$.ɵtemplate(2, MyComponent_li_Template_2, null, $c2$);
$r3$.ɵelementEnd();
}
},
Expand Down Expand Up @@ -1345,7 +1345,7 @@ describe('compiler compliance', () => {
if (rf & 1) {
$r3$.ɵelementStart(0, "div");
$r3$.ɵtext(1);
$r3$.ɵcontainer(2, MyComponent_div_span_Template_2, null, $c2$);
$r3$.ɵtemplate(2, MyComponent_div_span_Template_2, null, $c2$);
$r3$.ɵelement(3, "span", null, $c4$);
$r3$.ɵelementEnd();
}
Expand All @@ -1366,7 +1366,7 @@ describe('compiler compliance', () => {
if (rf & 1) {
$r3$.ɵelement(0, "div", null, $c1$);
$r3$.ɵtext(2);
$r3$.ɵcontainer(3, MyComponent_div_Template_3, null, $c2$);
$r3$.ɵtemplate(3, MyComponent_div_Template_3, null, $c2$);
$r3$.ɵelement(4, "div", null, $c3$);
}
if (rf & 2) {
Expand Down Expand Up @@ -1430,7 +1430,7 @@ describe('compiler compliance', () => {
if (rf & 1) {
$i0$.ɵelementStart(0, "div");
$i0$.ɵelement(1, "div", null, $c1$);
$i0$.ɵcontainer(3, MyComponent_div_span_Template_3, null, $c2$);
$i0$.ɵtemplate(3, MyComponent_div_span_Template_3, null, $c2$);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -1442,7 +1442,7 @@ describe('compiler compliance', () => {
// ...
template:function MyComponent_Template(rf, ctx){
if (rf & 1) {
$i0$.ɵcontainer(0, MyComponent_div_Template_0, null, $c0$);
$i0$.ɵtemplate(0, MyComponent_div_Template_0, null, $c0$);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngForOf", $i0$.ɵbind(ctx.items));
Expand Down Expand Up @@ -1647,7 +1647,7 @@ describe('compiler compliance', () => {
if (rf & 1) {
$r3$.ɵnamespaceSVG();
$r3$.ɵelementStart(0,"svg");
$r3$.ɵcontainer(1,MyComponent__svg_g_Template_1,null,$_c0$);
$r3$.ɵtemplate(1,MyComponent__svg_g_Template_1,null,$_c0$);
$r3$.ɵelementEnd();
}
if (rf & 2) { $r3$.ɵelementProperty(1,"forOf",$r3$.ɵbind(ctx.items)); }
Expand Down Expand Up @@ -1723,7 +1723,7 @@ describe('compiler compliance', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵelementStart(0, "ul");
$r3$.ɵcontainer(1, MyComponent_li_Template_1, null, $_c0$);
$r3$.ɵtemplate(1, MyComponent_li_Template_1, null, $_c0$);
$r3$.ɵelementEnd();
}
if (rf & 2) {
Expand Down Expand Up @@ -1801,7 +1801,7 @@ describe('compiler compliance', () => {
$r3$.ɵtext(2);
$r3$.ɵelementEnd();
$r3$.ɵelementStart(3, "ul");
$r3$.ɵcontainer(4, MyComponent_li_li_Template_4, null, $c1$);
$r3$.ɵtemplate(4, MyComponent_li_li_Template_4, null, $c1$);
$r3$.ɵelementEnd();
$r3$.ɵelementEnd();
}
Expand All @@ -1821,7 +1821,7 @@ describe('compiler compliance', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵelementStart(0, "ul");
$r3$.ɵcontainer(1, MyComponent_li_Template_1, null, $c1$);
$r3$.ɵtemplate(1, MyComponent_li_Template_1, null, $c1$);
$r3$.ɵelementEnd();
}
if (rf & 2) {
Expand Down
Expand Up @@ -112,7 +112,7 @@ describe('compiler compliance: listen()', () => {
// ...
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵcontainer(0, MyComponent_div_Template_0, null, $c0$);
$r3$.ɵtemplate(0, MyComponent_div_Template_0, null, $c0$);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngIf", $i0$.ɵbind(ctx.showing));
Expand Down
Expand Up @@ -81,7 +81,7 @@ describe('compiler compliance: template', () => {
function MyComponent_ul_li_Template_1(rf, ctx) {
if (rf & 1) {
$i0$.ɵelementStart(0, "li");
$i0$.ɵcontainer(1, MyComponent_ul_li_div_Template_1, null, _c0);
$i0$.ɵtemplate(1, MyComponent_ul_li_div_Template_1, null, _c0);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -93,7 +93,7 @@ describe('compiler compliance: template', () => {
function MyComponent_ul_Template_0(rf, ctx) {
if (rf & 1) {
$i0$.ɵelementStart(0, "ul");
$i0$.ɵcontainer(1, MyComponent_ul_li_Template_1, null, _c0);
$i0$.ɵtemplate(1, MyComponent_ul_li_Template_1, null, _c0);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -104,7 +104,7 @@ describe('compiler compliance: template', () => {
// ...
template:function MyComponent_Template(rf, ctx){
if (rf & 1) {
$i0$.ɵcontainer(0, MyComponent_ul_Template_0, null, _c0);
$i0$.ɵtemplate(0, MyComponent_ul_Template_0, null, _c0);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngForOf", $i0$.ɵbind(ctx.items));
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('compiler compliance: template', () => {
// ...
template:function MyComponent_Template(rf, ctx){
if (rf & 1) {
$i0$.ɵcontainer(0, MyComponent_span_Template_0, null, _c0);
$i0$.ɵtemplate(0, MyComponent_span_Template_0, null, _c0);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngForOf", $i0$.ɵbind(ctx.items));
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('compiler compliance: template', () => {
function MyComponent_div_Template_0(rf, ctx) {
if (rf & 1) {
$i0$.ɵelementStart(0, "div");
$i0$.ɵcontainer(1, MyComponent_div_span_Template_1, null, $c1$);
$i0$.ɵtemplate(1, MyComponent_div_span_Template_1, null, $c1$);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -223,7 +223,7 @@ describe('compiler compliance: template', () => {
// ...
template:function MyComponent_Template(rf, ctx){
if (rf & 1) {
$i0$.ɵcontainer(0, MyComponent_div_Template_0, null, $c0$);
$i0$.ɵtemplate(0, MyComponent_div_Template_0, null, $c0$);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngForOf", $i0$.ɵbind(ctx.items));
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('compiler compliance: template', () => {
function MyComponent_div_div_Template_1(rf, ctx) {
if (rf & 1) {
$i0$.ɵelementStart(0, "div");
$i0$.ɵcontainer(1, MyComponent_div_div_div_Template_1, null, _c0);
$i0$.ɵtemplate(1, MyComponent_div_div_div_Template_1, null, _c0);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -291,7 +291,7 @@ describe('compiler compliance: template', () => {
function MyComponent_div_Template_0(rf, ctx) {
if (rf & 1) {
$i0$.ɵelementStart(0, "div");
$i0$.ɵcontainer(1, MyComponent_div_div_Template_1, null, _c0);
$i0$.ɵtemplate(1, MyComponent_div_div_Template_1, null, _c0);
$i0$.ɵelementEnd();
}
if (rf & 2) {
Expand All @@ -302,7 +302,7 @@ describe('compiler compliance: template', () => {
// ...
template:function MyComponent_Template(rf, ctx){
if (rf & 1) {
$i0$.ɵcontainer(0, MyComponent_div_Template_0, null, _c0);
$i0$.ɵtemplate(0, MyComponent_div_Template_0, null, _c0);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "ngForOf", $i0$.ɵbind(ctx.items));
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('compiler compliance: template', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$i0$.ɵcontainer(0, Template_0, null, $c0$);
$i0$.ɵtemplate(0, Template_0, null, $c0$);
}
if (rf & 2) {
$i0$.ɵelementProperty(0, "boundAttr", $i0$.ɵbind(ctx.b));
Expand Down
2 changes: 2 additions & 0 deletions packages/compiler/src/render3/r3_identifiers.ts
Expand Up @@ -52,6 +52,8 @@ export class Identifiers {

static nextContext: o.ExternalReference = {name: 'ɵnextContext', moduleName: CORE};

static templateCreate: o.ExternalReference = {name: 'ɵtemplate', moduleName: CORE};

static text: o.ExternalReference = {name: 'ɵtext', moduleName: CORE};

static textBinding: o.ExternalReference = {name: 'ɵtextBinding', moduleName: CORE};
Expand Down
5 changes: 2 additions & 3 deletions packages/compiler/src/render3/view/template.ts
Expand Up @@ -727,9 +727,8 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
parameters.push(this.constantPool.getConstLiteral(o.literalArr(attributeNames), true));
}

// e.g. C(1, C1Template)
this.creationInstruction(
template.sourceSpan, R3.containerCreate, trimTrailingNulls(parameters));
// e.g. template(1, MyComp_Template_1)
this.creationInstruction(template.sourceSpan, R3.templateCreate, trimTrailingNulls(parameters));

// e.g. p(1, 'forOf', ɵbind(ctx.items));
const context = o.variable(CONTEXT_NAME);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/core_render3_private_export.ts
Expand Up @@ -94,6 +94,7 @@ export {
elementStylingApply as ɵelementStylingApply,
elementClassProp as ɵelementClassProp,
textBinding as ɵtextBinding,
template as ɵtemplate,
embeddedViewEnd as ɵembeddedViewEnd,
store as ɵstore,
load as ɵload,
Expand Down Expand Up @@ -157,4 +158,4 @@ export {
bypassSanitizationTrustUrl as ɵbypassSanitizationTrustUrl,
bypassSanitizationTrustResourceUrl as ɵbypassSanitizationTrustResourceUrl,
} from './sanitization/bypass';
// clang-format on
// clang-format on
1 change: 1 addition & 0 deletions packages/core/src/render3/index.ts
Expand Up @@ -73,6 +73,7 @@ export {

text,
textBinding,
template,

reference,

Expand Down

0 comments on commit 6482f6f

Please sign in to comment.