[#286,bugfix]: fix for case where fields array has nulls in it.
If passed fields = [ null, ..., ...] or [ ... , null, ...] we fail in Dataset._normalizeRecordsAndFields method because: 1. If null is first element we do not do field generation correctly because typeof(null) is object -ede211646a/src/model.js (L108)2. We call toString on field names which fails for nullede211646a/src/model.js (L113)
This commit is contained in:
@@ -105,12 +105,16 @@ my.Dataset = Backbone.Model.extend({
|
||||
}
|
||||
|
||||
// fields is an array of strings (i.e. list of field headings/ids)
|
||||
if (fields && fields.length > 0 && typeof(fields[0]) != 'object') {
|
||||
if (fields && fields.length > 0 && (fields[0] === null || typeof(fields[0]) != 'object')) {
|
||||
// Rename duplicate fieldIds as each field name needs to be
|
||||
// unique.
|
||||
var seen = {};
|
||||
fields = _.map(fields, function(field, index) {
|
||||
field = field.toString();
|
||||
if (field === null) {
|
||||
field = '';
|
||||
} else {
|
||||
field = field.toString();
|
||||
}
|
||||
// cannot use trim as not supported by IE7
|
||||
var fieldId = field.replace(/^\s+|\s+$/g, '');
|
||||
if (fieldId === '') {
|
||||
|
||||
Reference in New Issue
Block a user