fix(ivy): compiler should emit new refresh pattern (#21862)

Change compiler to reflect changes made in #21650

PR Close #21862
This commit is contained in:
Chuck Jazdzewski 2018-01-29 09:11:04 -08:00 committed by Jason Aden
parent 9dca5f2743
commit 06d6c76192
3 changed files with 11 additions and 15 deletions

View File

@ -21,7 +21,6 @@ export class Identifiers {
/* Methods */
static NEW_METHOD = 'n';
static HOST_BINDING_METHOD = 'h';
static REFRESH_METHOD = 'r';
/* Instructions */
static createElement: o.ExternalReference = {name: 'ɵE', moduleName: CORE};

View File

@ -464,11 +464,10 @@ class TemplateDefinitionBuilder implements TemplateAstVisitor, LocalResolver {
o.importExpr(R3.bind).callFn([convertedBinding.currValExpr]));
}
// e.g. TodoComponentDef.r(0, 0);
this._refreshMode.push(
this.definitionOf(directiveType, kind)
.callMethod(R3.REFRESH_METHOD, [o.literal(directiveIndex), o.literal(nodeIndex)])
.toStmt());
// e.g. r(0, 0);
this.instruction(
this._refreshMode, directive.sourceSpan, R3.refreshComponent, o.literal(directiveIndex),
o.literal(nodeIndex));
}
}

View File

@ -208,8 +208,8 @@ describe('r3_view_compiler', () => {
IDENT.ɵe();
IDENT.ɵT(3, '!');
}
ChildComponent.ngComponentDef.r(1, 0);
SomeDirective.ngDirectiveDef.r(2, 0);
IDENT.ɵr(1, 0);
IDENT.ɵr(2, 0);
}
});
`;
@ -272,7 +272,7 @@ describe('r3_view_compiler', () => {
}
const IDENT = IDENT.ɵm(1);
IDENT.ɵcR(2);
IfDirective.ngDirectiveDef.r(3,2);
IDENT.ɵr(3,2);
IDENT.ɵcr();
function MyComponent_IfDirective_Template_2(ctx0: IDENT, cm: IDENT) {
@ -495,13 +495,11 @@ describe('r3_view_compiler', () => {
// TODO(chuckj): Enforce this when the directives are specified
const ForDirectiveDefinition = `
static ngDirectiveDef = IDENT.ɵdefineDirective({
type: ForOfDirective,
factory: function ForOfDirective_Factory() {
return new ForOfDirective(IDENT.ɵinjectViewContainerRef(), IDENT.ɵinjectTemplateRef());
},
features: [IDENT.ɵNgOnChangesFeature(NgForOf)],
refresh: function ForOfDirective_Refresh(directiveIndex: IDENT, elementIndex: IDENT) {
IDENT.ɵm<ForOfDirective>(directiveIndex).ngDoCheck();
},
inputs: {forOf: 'forOf'}
});
`;
@ -519,7 +517,7 @@ describe('r3_view_compiler', () => {
}
IDENT.ɵp(1, 'forOf', IDENT.ɵb(ctx.items));
IDENT.ɵcR(1);
ForOfDirective.ngDirectiveDef.r(2, 1);
IDENT.ɵr(2, 1);
IDENT.ɵcr();
function MyComponent_ForOfDirective_Template_1(ctx0: IDENT, cm: IDENT) {
@ -593,7 +591,7 @@ describe('r3_view_compiler', () => {
}
IDENT.ɵp(1, 'forOf', IDENT.ɵb(ctx.items));
IDENT.ɵcR(1);
IDENT.r(2, 1);
IDENT.ɵr(2, 1);
IDENT.ɵcr();
function MyComponent_ForOfDirective_Template_1(ctx0: IDENT, cm: IDENT) {
@ -611,7 +609,7 @@ describe('r3_view_compiler', () => {
IDENT.ɵp(4, 'forOf', IDENT.ɵb(IDENT.infos));
IDENT.ɵt(2, IDENT.ɵb1('', IDENT.name, ''));
IDENT.ɵcR(4);
IDENT.r(5, 4);
IDENT.ɵr(5, 4);
IDENT.ɵcr();
function MyComponent_ForOfDirective_ForOfDirective_Template_4(