Skip to content

refactor(examples): use includes instead of indexOf to check whet… #22956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export class AutocompleteAutoActiveFirstOptionExample implements OnInit {
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();

return this.options.filter(option => option.toLowerCase().indexOf(filterValue) === 0);
return this.options.filter(option => option.toLowerCase().includes(filterValue));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ export class AutocompleteDisplayExample implements OnInit {
private _filter(name: string): User[] {
const filterValue = name.toLowerCase();

return this.options.filter(option => option.name.toLowerCase().indexOf(filterValue) === 0);
return this.options.filter(option => option.name.toLowerCase().includes(filterValue));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface StateGroup {
export const _filter = (opt: string[], value: string): string[] => {
const filterValue = value.toLowerCase();

return opt.filter(item => item.toLowerCase().indexOf(filterValue) === 0);
return opt.filter(item => item.toLowerCase().includes(filterValue));
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ export class AutocompleteOverviewExample {
private _filterStates(value: string): State[] {
const filterValue = value.toLowerCase();

return this.states.filter(state => state.name.toLowerCase().indexOf(filterValue) === 0);
return this.states.filter(state => state.name.toLowerCase().includes(filterValue));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ export class ChipsAutocompleteExample {
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();

return this.allFruits.filter(fruit => fruit.toLowerCase().indexOf(filterValue) === 0);
return this.allFruits.filter(fruit => fruit.toLowerCase().includes(filterValue));
}
}