Skip to content

Commit

Permalink
fix(datagrid): reject undefined in the numeric property filter
Browse files Browse the repository at this point in the history
This is a backport of e87c678.
  • Loading branch information
derkoe authored and kevinbuhmann committed Aug 22, 2022
1 parent b67589c commit 0db3363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -26,10 +26,10 @@ export default function (): void {
// expect(this.filter.accepts({ a: 'not a number' }, null, 1)).toBe(false);
// });

// it('always rejects undefined', function () {
// this.filter = new DatagridPropertyNumericFilter('a');
// expect(this.filter.accepts({}, null, null)).toBe(false);
// });
it('always rejects undefined', function () {
this.filter = new DatagridPropertyNumericFilter('a');
expect(this.filter.accepts({}, null, null)).toBe(false);
});

it('supports nested properties', function () {
this.filter = new DatagridPropertyNumericFilter('a.b');
Expand Down
Expand Up @@ -16,6 +16,9 @@ export class DatagridPropertyNumericFilter<T = any> implements ClrDatagridNumeri

accepts(item: T, low: number, high: number): boolean {
const propValue = this.nestedProp.getPropValue(item);
if (propValue === undefined) {
return false;
}
if (low !== null && propValue < low) {
return false;
}
Expand Down

0 comments on commit 0db3363

Please sign in to comment.