From 3293ef980c18f869e9ecd10029cce6be765503d5 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Tue, 5 Sep 2023 03:12:01 +0100 Subject: [PATCH] Refactor #4290 --- components/lib/utils/ObjectUtils.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/components/lib/utils/ObjectUtils.js b/components/lib/utils/ObjectUtils.js index d3a101004..e5e31629a 100755 --- a/components/lib/utils/ObjectUtils.js +++ b/components/lib/utils/ObjectUtils.js @@ -56,16 +56,21 @@ export default { }, resolveFieldData(data, field) { + if (!data || !field) { + // short circuit if there is nothing to resolve + return null; + } + try { const value = data[field]; - if (value) - return value; - } - catch { + + if (this.isNotEmpty(value)) return value; + } catch { + // Performance optimization: https://github.com/primefaces/primereact/issues/4797 // do nothing and continue to other methods to resolve field data } - if (data && Object.keys(data).length && field) { + if (Object.keys(data).length) { if (this.isFunction(field)) { return field(data); } else if (field.indexOf('.') === -1) { @@ -84,9 +89,9 @@ export default { return value; } - } else { - return null; } + + return null; }, getItemValue(obj, ...params) {