mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 17:02:38 +00:00
Refactor #4290
This commit is contained in:
parent
86350195b5
commit
3293ef980c
1 changed files with 12 additions and 7 deletions
|
@ -56,16 +56,21 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveFieldData(data, field) {
|
resolveFieldData(data, field) {
|
||||||
|
if (!data || !field) {
|
||||||
|
// short circuit if there is nothing to resolve
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const value = data[field];
|
const value = data[field];
|
||||||
if (value)
|
|
||||||
return value;
|
if (this.isNotEmpty(value)) return value;
|
||||||
}
|
} catch {
|
||||||
catch {
|
// Performance optimization: https://github.com/primefaces/primereact/issues/4797
|
||||||
// do nothing and continue to other methods to resolve field data
|
// 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)) {
|
if (this.isFunction(field)) {
|
||||||
return field(data);
|
return field(data);
|
||||||
} else if (field.indexOf('.') === -1) {
|
} else if (field.indexOf('.') === -1) {
|
||||||
|
@ -84,9 +89,9 @@ export default {
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
getItemValue(obj, ...params) {
|
getItemValue(obj, ...params) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue