Skip to content

Commit

Permalink
feat: allow nullish compareWith (ng-select#1857)
Browse files Browse the repository at this point in the history
There are 2 reasons to allow setting compareWith to null/undefined.

1. Reverting the set compareWith - possible the user of the ng-select might want to remove the previously set compareWith to allow default behaviour in combination with bindValue possibly.
2. Extensibility - we have a wrapper around the ng-select that provides custom styles, adds error messages. Not all use cases use compareWith, but some do. Now it is impossible to redirect the [compareWith] @input without setting the default. That hinders the bindValue default behaviour.
  • Loading branch information
kvetis authored Feb 8, 2021
1 parent 3503056 commit ca0be9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng-select/lib/ng-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class NgSelectComponent implements OnDestroy, OnChanges, AfterViewInit, C
get compareWith() { return this._compareWith; }

set compareWith(fn: CompareWithFn) {
if (!isFunction(fn)) {
if (fn !== undefined && fn !== null && !isFunction(fn)) {
throw Error('`compareWith` must be a function.');
}
this._compareWith = fn;
Expand Down

0 comments on commit ca0be9b

Please sign in to comment.