refactor(ivy): minor refactoring / code clean-up (#27766)
PR Close #27766
This commit is contained in:
parent
7eb2c41fb2
commit
d026b675be
@ -490,9 +490,9 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
|||||||
const {name, value} = attr;
|
const {name, value} = attr;
|
||||||
if (name === NON_BINDABLE_ATTR) {
|
if (name === NON_BINDABLE_ATTR) {
|
||||||
isNonBindableMode = true;
|
isNonBindableMode = true;
|
||||||
} else if (name == 'style') {
|
} else if (name === 'style') {
|
||||||
stylingBuilder.registerStyleAttr(value);
|
stylingBuilder.registerStyleAttr(value);
|
||||||
} else if (name == 'class') {
|
} else if (name === 'class') {
|
||||||
stylingBuilder.registerClassAttr(value);
|
stylingBuilder.registerClassAttr(value);
|
||||||
} else if (attr.i18n) {
|
} else if (attr.i18n) {
|
||||||
i18nAttrs.push(attr);
|
i18nAttrs.push(attr);
|
||||||
@ -516,7 +516,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
|||||||
|
|
||||||
element.inputs.forEach((input: t.BoundAttribute) => {
|
element.inputs.forEach((input: t.BoundAttribute) => {
|
||||||
if (!stylingBuilder.registerBoundInput(input)) {
|
if (!stylingBuilder.registerBoundInput(input)) {
|
||||||
if (input.type == BindingType.Property) {
|
if (input.type === BindingType.Property) {
|
||||||
if (input.i18n) {
|
if (input.i18n) {
|
||||||
i18nAttrs.push(input);
|
i18nAttrs.push(input);
|
||||||
} else {
|
} else {
|
||||||
@ -733,7 +733,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
|||||||
parameters.push(o.importExpr(R3.templateRefExtractor));
|
parameters.push(o.importExpr(R3.templateRefExtractor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle property bindings e.g. p(1, 'forOf', ɵbind(ctx.items));
|
// handle property bindings e.g. p(1, 'ngForOf', ɵbind(ctx.items));
|
||||||
const context = o.variable(CONTEXT_NAME);
|
const context = o.variable(CONTEXT_NAME);
|
||||||
template.inputs.forEach(input => {
|
template.inputs.forEach(input => {
|
||||||
const value = input.value.visit(this._valueConverter);
|
const value = input.value.visit(this._valueConverter);
|
||||||
@ -756,7 +756,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
|||||||
// Nested templates must not be visited until after their parent templates have completed
|
// Nested templates must not be visited until after their parent templates have completed
|
||||||
// processing, so they are queued here until after the initial pass. Otherwise, we wouldn't
|
// processing, so they are queued here until after the initial pass. Otherwise, we wouldn't
|
||||||
// be able to support bindings in nested templates to local refs that occur after the
|
// be able to support bindings in nested templates to local refs that occur after the
|
||||||
// template definition. e.g. <div *ngIf="showing"> {{ foo }} </div> <div #foo></div>
|
// template definition. e.g. <div *ngIf="showing">{{ foo }}</div> <div #foo></div>
|
||||||
this._nestedTemplateFns.push(() => {
|
this._nestedTemplateFns.push(() => {
|
||||||
const templateFunctionExpr = templateVisitor.buildTemplateFunction(
|
const templateFunctionExpr = templateVisitor.buildTemplateFunction(
|
||||||
template.children, template.variables,
|
template.children, template.variables,
|
||||||
@ -1453,7 +1453,7 @@ function createCssSelector(tag: string, attributes: {[name: string]: string}): C
|
|||||||
|
|
||||||
cssSelector.addAttribute(name, value);
|
cssSelector.addAttribute(name, value);
|
||||||
if (name.toLowerCase() === 'class') {
|
if (name.toLowerCase() === 'class') {
|
||||||
const classes = value.trim().split(/\s+/g);
|
const classes = value.trim().split(/\s+/);
|
||||||
classes.forEach(className => cssSelector.addClassName(className));
|
classes.forEach(className => cssSelector.addClassName(className));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1570,8 +1570,10 @@ function isSingleElementTemplate(children: t.Node[]): children is[t.Element] {
|
|||||||
return children.length === 1 && children[0] instanceof t.Element;
|
return children.length === 1 && children[0] instanceof t.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasTextChildrenOnly(children: t.Node[]): boolean {
|
function isTextNode(node: t.Node): boolean {
|
||||||
return !children.find(
|
return node instanceof t.Text || node instanceof t.BoundText || node instanceof t.Icu;
|
||||||
child =>
|
}
|
||||||
!(child instanceof t.Text || child instanceof t.BoundText || child instanceof t.Icu));
|
|
||||||
|
function hasTextChildrenOnly(children: t.Node[]): boolean {
|
||||||
|
return children.every(isTextNode);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user