Node.js: Fix MapModel rowData() calling map function even if the source model returned undefined

Also fix the function signature, which was wrong.
This commit is contained in:
Simon Hausmann 2024-02-07 16:46:56 +01:00 committed by Simon Hausmann
parent 55a8f202ea
commit 2d6edfbd6c
2 changed files with 31 additions and 2 deletions

View file

@ -502,8 +502,12 @@ export class MapModel<T, U> extends Model<U> {
* @param row index in range 0..(rowCount() - 1).
* @returns undefined if row is out of range otherwise the data.
*/
rowData(row: number): U {
return this.#mapFunction(this.sourceModel.rowData(row));
rowData(row: number): U | undefined {
let data = this.sourceModel.rowData(row);
if (data === undefined) {
return undefined;
}
return this.#mapFunction(data);
}
}
}