mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
perf(all): minify better by using arrow functions (#18730)
This commit is contained in:
@ -496,7 +496,7 @@ export class Select implements ComponentInterface {
|
||||
}
|
||||
}
|
||||
|
||||
function parseValue(value: any) {
|
||||
const parseValue = (value: any) => {
|
||||
if (value == null) {
|
||||
return undefined;
|
||||
}
|
||||
@ -504,9 +504,9 @@ function parseValue(value: any) {
|
||||
return value.join(',');
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
};
|
||||
|
||||
function isOptionSelected(currentValue: any[] | any, compareValue: any, compareWith?: string | SelectCompareFn | null) {
|
||||
const isOptionSelected = (currentValue: any[] | any, compareValue: any, compareWith?: string | SelectCompareFn | null) => {
|
||||
if (currentValue === undefined) {
|
||||
return false;
|
||||
}
|
||||
@ -515,9 +515,9 @@ function isOptionSelected(currentValue: any[] | any, compareValue: any, compareW
|
||||
} else {
|
||||
return compareOptions(currentValue, compareValue, compareWith);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function compareOptions(currentValue: any, compareValue: any, compareWith?: string | SelectCompareFn | null): boolean {
|
||||
const compareOptions = (currentValue: any, compareValue: any, compareWith?: string | SelectCompareFn | null): boolean => {
|
||||
if (typeof compareWith === 'function') {
|
||||
return compareWith(currentValue, compareValue);
|
||||
} else if (typeof compareWith === 'string') {
|
||||
@ -525,9 +525,9 @@ function compareOptions(currentValue: any, compareValue: any, compareWith?: stri
|
||||
} else {
|
||||
return currentValue === compareValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function generateText(opts: HTMLIonSelectOptionElement[], value: any | any[], compareWith?: string | SelectCompareFn | null) {
|
||||
const generateText = (opts: HTMLIonSelectOptionElement[], value: any | any[], compareWith?: string | SelectCompareFn | null) => {
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
}
|
||||
@ -539,15 +539,15 @@ function generateText(opts: HTMLIonSelectOptionElement[], value: any | any[], co
|
||||
} else {
|
||||
return textForValue(opts, value, compareWith) || '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function textForValue(opts: HTMLIonSelectOptionElement[], value: any, compareWith?: string | SelectCompareFn | null): string | null {
|
||||
const textForValue = (opts: HTMLIonSelectOptionElement[], value: any, compareWith?: string | SelectCompareFn | null): string | null => {
|
||||
const selectOpt = opts.find(opt => {
|
||||
return compareOptions(opt.value, value, compareWith);
|
||||
});
|
||||
return selectOpt
|
||||
? selectOpt.textContent
|
||||
: null;
|
||||
}
|
||||
};
|
||||
|
||||
let selectIds = 0;
|
||||
|
Reference in New Issue
Block a user