mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[fieldFormat/contentType] fix a bug converting null to html
This commit is contained in:
parent
5924d844e6
commit
5e9559af96
1 changed files with 14 additions and 15 deletions
|
@ -6,30 +6,29 @@ define(function (require) {
|
|||
var types = {
|
||||
html: function (format, convert) {
|
||||
return function recurse(value, field, hit) {
|
||||
var type = typeof value;
|
||||
|
||||
if (type === 'object' && typeof value.map === 'function') {
|
||||
if (value.$$_formattedField) return value.$$_formattedField;
|
||||
|
||||
var subVals = value.map(recurse);
|
||||
var useMultiLine = subVals.some(function (sub) {
|
||||
return sub.indexOf('\n') > -1;
|
||||
});
|
||||
|
||||
return value.$$_formattedField = subVals.join(',' + (useMultiLine ? '\n' : ' '));
|
||||
if (!value || typeof value.map !== 'function') {
|
||||
return convert.call(format, value, field, hit);
|
||||
}
|
||||
|
||||
return convert.call(format, value, field, hit);
|
||||
// format a list of values. Lists of values will have their formatted values cached
|
||||
if (value.$$_formattedField) return value.$$_formattedField;
|
||||
var subVals = value.map(recurse);
|
||||
var useMultiLine = subVals.some(function (sub) {
|
||||
return sub.indexOf('\n') > -1;
|
||||
});
|
||||
|
||||
return value.$$_formattedField = subVals.join(',' + (useMultiLine ? '\n' : ' '));
|
||||
};
|
||||
},
|
||||
|
||||
text: function (format, convert) {
|
||||
return function recurse(value) {
|
||||
if (value && typeof value.map === 'function') {
|
||||
return angular.toJson(value.map(recurse), true);
|
||||
if (!value || typeof value.map !== 'function') {
|
||||
return convert.call(format, value);
|
||||
}
|
||||
|
||||
return convert.call(format, value);
|
||||
// format a list of values. In text contexts we just use JSON encoding
|
||||
return angular.toJson(value.map(recurse), true);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue