refactor(ivy): clean up (#23899)

- remove unnecessary debugger statement
- rename `isSelfClosingElement` to `isEmptyElement`
- remove unnecessary template anchor in test

PR Close #23899
This commit is contained in:
Ben Lesh 2018-05-30 16:08:28 -07:00 committed by Victor Berchet
parent 0d06c866c6
commit 856ee73464
2 changed files with 3 additions and 6 deletions

View File

@ -315,12 +315,12 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
this._creationCode.push(...i18nMessages); this._creationCode.push(...i18nMessages);
} }
let isSelfClosingElement = element.outputs.length === 0 && element.children.length === 0; const isEmptyElement = element.outputs.length === 0 && element.children.length === 0;
const implicit = o.variable(CONTEXT_NAME); const implicit = o.variable(CONTEXT_NAME);
if (isSelfClosingElement) { if (isEmptyElement) {
this.instruction( this.instruction(
this._creationCode, element.sourceSpan, R3.element, ...trimTrailingNulls(parameters)); this._creationCode, element.sourceSpan, R3.element, ...trimTrailingNulls(parameters));
} else { } else {
@ -377,7 +377,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
t.visitAll(this, element.children); t.visitAll(this, element.children);
} }
if (!isSelfClosingElement) { if (!isEmptyElement) {
// Finish element construction mode. // Finish element construction mode.
this.instruction( this.instruction(
this._creationCode, element.endSourceSpan || element.sourceSpan, R3.elementEnd); this._creationCode, element.endSourceSpan || element.sourceSpan, R3.elementEnd);

View File

@ -133,15 +133,12 @@ describe('compiler compliance: template', () => {
}; };
const template = ` const template = `
// ...
template:function MyComponent_Template(rf: IDENT, $ctx$: IDENT){ template:function MyComponent_Template(rf: IDENT, $ctx$: IDENT){
if (rf & 1) { if (rf & 1) {
$i0$.ɵEe(0,'div'); $i0$.ɵEe(0,'div');
} }
}`; }`;
debugger;
const result = compile(files, angularFiles); const result = compile(files, angularFiles);
expectEmit(result.source, template, 'Incorrect template'); expectEmit(result.source, template, 'Incorrect template');