refactor(): use const and let instead of var
This commit is contained in:

committed by
Victor Berchet

parent
73593d4bf3
commit
77ee27c59e
@ -31,23 +31,23 @@ export class CompileQuery {
|
||||
}
|
||||
|
||||
addValue(value: o.Expression, view: CompileView) {
|
||||
var currentView = view;
|
||||
var elPath: CompileElement[] = [];
|
||||
let currentView = view;
|
||||
const elPath: CompileElement[] = [];
|
||||
while (isPresent(currentView) && currentView !== this.view) {
|
||||
var parentEl = currentView.declarationElement;
|
||||
const parentEl = currentView.declarationElement;
|
||||
elPath.unshift(parentEl);
|
||||
currentView = parentEl.view;
|
||||
}
|
||||
var queryListForDirtyExpr = getPropertyInView(this.queryList, view, this.view);
|
||||
const queryListForDirtyExpr = getPropertyInView(this.queryList, view, this.view);
|
||||
|
||||
var viewValues = this._values;
|
||||
let viewValues = this._values;
|
||||
elPath.forEach((el) => {
|
||||
var last =
|
||||
const last =
|
||||
viewValues.values.length > 0 ? viewValues.values[viewValues.values.length - 1] : null;
|
||||
if (last instanceof ViewQueryValues && last.view === el.embeddedView) {
|
||||
viewValues = last;
|
||||
} else {
|
||||
var newViewValues = new ViewQueryValues(el.embeddedView, []);
|
||||
const newViewValues = new ViewQueryValues(el.embeddedView, []);
|
||||
viewValues.values.push(newViewValues);
|
||||
viewValues = newViewValues;
|
||||
}
|
||||
@ -65,10 +65,10 @@ export class CompileQuery {
|
||||
}
|
||||
|
||||
afterChildren(targetStaticMethod: CompileMethod, targetDynamicMethod: CompileMethod) {
|
||||
var values = createQueryValues(this._values);
|
||||
var updateStmts = [this.queryList.callMethod('reset', [o.literalArr(values)]).toStmt()];
|
||||
const values = createQueryValues(this._values);
|
||||
const updateStmts = [this.queryList.callMethod('reset', [o.literalArr(values)]).toStmt()];
|
||||
if (isPresent(this.ownerDirectiveExpression)) {
|
||||
var valueExpr = this.meta.first ? this.queryList.prop('first') : this.queryList;
|
||||
const valueExpr = this.meta.first ? this.queryList.prop('first') : this.queryList;
|
||||
updateStmts.push(
|
||||
this.ownerDirectiveExpression.prop(this.meta.propertyName).set(valueExpr).toStmt());
|
||||
}
|
||||
@ -100,7 +100,7 @@ function createQueryValues(viewValues: ViewQueryValues): o.Expression[] {
|
||||
|
||||
function mapNestedViews(
|
||||
viewContainer: o.Expression, view: CompileView, expressions: o.Expression[]): o.Expression {
|
||||
var adjustedExpressions: o.Expression[] = expressions.map(
|
||||
const adjustedExpressions: o.Expression[] = expressions.map(
|
||||
(expr) => o.replaceVarInExpression(o.THIS_EXPR.name, o.variable('nestedView'), expr));
|
||||
return viewContainer.callMethod('mapNestedViews', [
|
||||
o.variable(view.className),
|
||||
@ -115,7 +115,7 @@ export function createQueryList(
|
||||
compileView: CompileView): o.Expression {
|
||||
compileView.fields.push(new o.ClassField(
|
||||
propertyName, o.importType(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])));
|
||||
var expr = o.THIS_EXPR.prop(propertyName);
|
||||
const expr = o.THIS_EXPR.prop(propertyName);
|
||||
compileView.createMethod.addStmt(
|
||||
o.THIS_EXPR.prop(propertyName)
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])
|
||||
@ -126,7 +126,7 @@ export function createQueryList(
|
||||
|
||||
export function addQueryToTokenMap(map: Map<any, CompileQuery[]>, query: CompileQuery) {
|
||||
query.meta.selectors.forEach((selector) => {
|
||||
var entry = map.get(selector.reference);
|
||||
let entry = map.get(selector.reference);
|
||||
if (!entry) {
|
||||
entry = [];
|
||||
map.set(selector.reference, entry);
|
||||
|
Reference in New Issue
Block a user