datatables.net 1.10.21 → 1.10.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- /*! DataTables 1.10.21
1
+ /*! DataTables 1.10.22
2
2
  * ©2008-2020 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  /**
6
6
  * @summary DataTables
7
7
  * @description Paginate, search and order HTML tables
8
- * @version 1.10.21
8
+ * @version 1.10.22
9
9
  * @file jquery.dataTables.js
10
10
  * @author SpryMedia Ltd
11
11
  * @contact www.datatables.net
@@ -251,7 +251,7 @@
251
251
  var api = this.api( true );
252
252
 
253
253
  /* Check if we want to add multiple rows or not */
254
- var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
254
+ var rows = Array.isArray(data) && ( Array.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
255
255
  api.rows.add( data ) :
256
256
  api.row.add( data );
257
257
 
@@ -975,7 +975,7 @@
975
975
  // If the length menu is given, but the init display length is not, use the length menu
976
976
  if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
977
977
  {
978
- oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
978
+ oInit.iDisplayLength = Array.isArray( oInit.aLengthMenu[0] ) ?
979
979
  oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
980
980
  }
981
981
 
@@ -1066,7 +1066,7 @@
1066
1066
  if ( oInit.iDeferLoading !== null )
1067
1067
  {
1068
1068
  oSettings.bDeferLoading = true;
1069
- var tmp = $.isArray( oInit.iDeferLoading );
1069
+ var tmp = Array.isArray( oInit.iDeferLoading );
1070
1070
  oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
1071
1071
  oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
1072
1072
  }
@@ -1356,7 +1356,7 @@
1356
1356
  // - Ƀ - Bitcoin
1357
1357
  // - Ξ - Ethereum
1358
1358
  // standards as thousands separators.
1359
- var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
1359
+ var _re_formatted_numeric = /['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
1360
1360
 
1361
1361
 
1362
1362
  var _empty = function ( d ) {
@@ -1584,6 +1584,36 @@
1584
1584
  return out;
1585
1585
  };
1586
1586
 
1587
+ // Surprisingly this is faster than [].concat.apply
1588
+ // https://jsperf.com/flatten-an-array-loop-vs-reduce/2
1589
+ var _flatten = function (out, val) {
1590
+ if (Array.isArray(val)) {
1591
+ for (var i=0 ; i<val.length ; i++) {
1592
+ _flatten(out, val[i]);
1593
+ }
1594
+ }
1595
+ else {
1596
+ out.push(val);
1597
+ }
1598
+
1599
+ return out;
1600
+ }
1601
+
1602
+ // Array.isArray polyfill.
1603
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
1604
+ if (! Array.isArray) {
1605
+ Array.isArray = function(arg) {
1606
+ return Object.prototype.toString.call(arg) === '[object Array]';
1607
+ };
1608
+ }
1609
+
1610
+ // .trim() polyfill
1611
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
1612
+ if (!String.prototype.trim) {
1613
+ String.prototype.trim = function () {
1614
+ return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
1615
+ };
1616
+ }
1587
1617
 
1588
1618
  /**
1589
1619
  * DataTables utility methods
@@ -1841,7 +1871,7 @@
1841
1871
 
1842
1872
  // orderData can be given as an integer
1843
1873
  var dataSort = init.aDataSort;
1844
- if ( typeof dataSort === 'number' && ! $.isArray( dataSort ) ) {
1874
+ if ( typeof dataSort === 'number' && ! Array.isArray( dataSort ) ) {
1845
1875
  init.aDataSort = [ dataSort ];
1846
1876
  }
1847
1877
  }
@@ -2325,7 +2355,7 @@
2325
2355
  def.targets :
2326
2356
  def.aTargets;
2327
2357
 
2328
- if ( ! $.isArray( aTargets ) )
2358
+ if ( ! Array.isArray( aTargets ) )
2329
2359
  {
2330
2360
  aTargets = [ aTargets ];
2331
2361
  }
@@ -2644,7 +2674,7 @@
2644
2674
  innerSrc = a.join('.');
2645
2675
 
2646
2676
  // Traverse each entry in the array getting the properties requested
2647
- if ( $.isArray( data ) ) {
2677
+ if ( Array.isArray( data ) ) {
2648
2678
  for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
2649
2679
  out.push( fetchData( data[j], type, innerSrc ) );
2650
2680
  }
@@ -2732,6 +2762,11 @@
2732
2762
 
2733
2763
  for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
2734
2764
  {
2765
+ // Protect against prototype pollution
2766
+ if (a[i] === '__proto__') {
2767
+ throw new Error('Cannot set prototype values');
2768
+ }
2769
+
2735
2770
  // Check if we are dealing with an array notation request
2736
2771
  arrayNotation = a[i].match(__reArray);
2737
2772
  funcNotation = a[i].match(__reFn);
@@ -2747,7 +2782,7 @@
2747
2782
  innerSrc = b.join('.');
2748
2783
 
2749
2784
  // Traverse each entry in the array setting the properties requested
2750
- if ( $.isArray( val ) )
2785
+ if ( Array.isArray( val ) )
2751
2786
  {
2752
2787
  for ( var j=0, jLen=val.length ; j<jLen ; j++ )
2753
2788
  {
@@ -2994,7 +3029,7 @@
2994
3029
  var cellProcess = function ( cell ) {
2995
3030
  if ( colIdx === undefined || colIdx === i ) {
2996
3031
  col = columns[i];
2997
- contents = $.trim(cell.innerHTML);
3032
+ contents = (cell.innerHTML).trim();
2998
3033
 
2999
3034
  if ( col && col._bAttrSrc ) {
3000
3035
  var setter = _fnSetObjectDataFn( col.mData._ );
@@ -3244,11 +3279,11 @@
3244
3279
  }
3245
3280
 
3246
3281
  /* ARIA role for the rows */
3247
- $(thead).find('>tr').attr('role', 'row');
3282
+ $(thead).children('tr').attr('role', 'row');
3248
3283
 
3249
3284
  /* Deal with the footer - add classes if required */
3250
- $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
3251
- $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
3285
+ $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
3286
+ $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
3252
3287
 
3253
3288
  // Cache the footer cells. Note that we only take the cells from the first
3254
3289
  // row in the footer. If there is more than one row the user wants to
@@ -3834,7 +3869,7 @@
3834
3869
 
3835
3870
  // Convert to object based for 1.10+ if using the old array scheme which can
3836
3871
  // come from server-side processing or serverParams
3837
- if ( data && $.isArray(data) ) {
3872
+ if ( data && Array.isArray(data) ) {
3838
3873
  var tmp = {};
3839
3874
  var rbracket = /(.*?)\[\]$/;
3840
3875
 
@@ -4819,7 +4854,7 @@
4819
4854
  classes = settings.oClasses,
4820
4855
  tableId = settings.sTableId,
4821
4856
  menu = settings.aLengthMenu,
4822
- d2 = $.isArray( menu[0] ),
4857
+ d2 = Array.isArray( menu[0] ),
4823
4858
  lengths = d2 ? menu[0] : menu,
4824
4859
  language = d2 ? menu[1] : menu;
4825
4860
 
@@ -5865,7 +5900,7 @@
5865
5900
  fixedObj = $.isPlainObject( fixed ),
5866
5901
  nestedSort = [],
5867
5902
  add = function ( a ) {
5868
- if ( a.length && ! $.isArray( a[0] ) ) {
5903
+ if ( a.length && ! Array.isArray( a[0] ) ) {
5869
5904
  // 1D array
5870
5905
  nestedSort.push( a );
5871
5906
  }
@@ -5877,7 +5912,7 @@
5877
5912
 
5878
5913
  // Build the sort array, with pre-fix and post-fix options if they have been
5879
5914
  // specified
5880
- if ( $.isArray( fixed ) ) {
5915
+ if ( Array.isArray( fixed ) ) {
5881
5916
  add( fixed );
5882
5917
  }
5883
5918
 
@@ -6506,9 +6541,9 @@
6506
6541
  */
6507
6542
  function _fnMap( ret, src, name, mappedName )
6508
6543
  {
6509
- if ( $.isArray( name ) ) {
6544
+ if ( Array.isArray( name ) ) {
6510
6545
  $.each( name, function (i, val) {
6511
- if ( $.isArray( val ) ) {
6546
+ if ( Array.isArray( val ) ) {
6512
6547
  _fnMap( ret, src, val[0], val[1] );
6513
6548
  }
6514
6549
  else {
@@ -6560,7 +6595,7 @@
6560
6595
  }
6561
6596
  $.extend( true, out[prop], val );
6562
6597
  }
6563
- else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
6598
+ else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && Array.isArray(val) ) {
6564
6599
  out[prop] = val.slice();
6565
6600
  }
6566
6601
  else {
@@ -6904,7 +6939,7 @@
6904
6939
  }
6905
6940
  };
6906
6941
 
6907
- if ( $.isArray( context ) ) {
6942
+ if ( Array.isArray( context ) ) {
6908
6943
  for ( var i=0, ien=context.length ; i<ien ; i++ ) {
6909
6944
  ctxSettings( context[i] );
6910
6945
  }
@@ -7262,7 +7297,7 @@
7262
7297
 
7263
7298
  _Api.register = _api_register = function ( name, val )
7264
7299
  {
7265
- if ( $.isArray( name ) ) {
7300
+ if ( Array.isArray( name ) ) {
7266
7301
  for ( var j=0, jen=name.length ; j<jen ; j++ ) {
7267
7302
  _Api.register( name[j], val );
7268
7303
  }
@@ -7332,7 +7367,7 @@
7332
7367
  // New API instance returned, want the value from the first item
7333
7368
  // in the returned array for the singular result.
7334
7369
  return ret.length ?
7335
- $.isArray( ret[0] ) ?
7370
+ Array.isArray( ret[0] ) ?
7336
7371
  new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
7337
7372
  ret[0] :
7338
7373
  undefined;
@@ -7355,7 +7390,7 @@
7355
7390
  */
7356
7391
  var __table_selector = function ( selector, a )
7357
7392
  {
7358
- if ( $.isArray(selector) ) {
7393
+ if ( Array.isArray(selector) ) {
7359
7394
  return $.map( selector, function (item) {
7360
7395
  return __table_selector(item, a);
7361
7396
  } );
@@ -7744,7 +7779,7 @@
7744
7779
  [ selector[i] ];
7745
7780
 
7746
7781
  for ( j=0, jen=a.length ; j<jen ; j++ ) {
7747
- res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
7782
+ res = selectFn( typeof a[j] === 'string' ? (a[j]).trim() : a[j] );
7748
7783
 
7749
7784
  if ( res && res.length ) {
7750
7785
  out = out.concat( res );
@@ -8170,7 +8205,7 @@
8170
8205
  row._aData = data;
8171
8206
 
8172
8207
  // If the DOM has an id, and the data source is an array
8173
- if ( $.isArray( data ) && row.nTr && row.nTr.id ) {
8208
+ if ( Array.isArray( data ) && row.nTr && row.nTr.id ) {
8174
8209
  _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
8175
8210
  }
8176
8211
 
@@ -8216,7 +8251,7 @@
8216
8251
  var rows = [];
8217
8252
  var addRow = function ( r, k ) {
8218
8253
  // Recursion to allow for arrays of jQuery objects
8219
- if ( $.isArray( r ) || r instanceof $ ) {
8254
+ if ( Array.isArray( r ) || r instanceof $ ) {
8220
8255
  for ( var i=0, ien=r.length ; i<ien ; i++ ) {
8221
8256
  addRow( r[i], k );
8222
8257
  }
@@ -8230,7 +8265,7 @@
8230
8265
  }
8231
8266
  else {
8232
8267
  // Otherwise create a row with a wrapper
8233
- var created = $('<tr><td/></tr>').addClass( k );
8268
+ var created = $('<tr><td></td></tr>').addClass( k );
8234
8269
  $('td', created)
8235
8270
  .addClass( k )
8236
8271
  .html( r )
@@ -8726,14 +8761,12 @@
8726
8761
  return _selector_first( this.columns( selector, opts ) );
8727
8762
  } );
8728
8763
 
8729
-
8730
-
8731
8764
  var __cell_selector = function ( settings, selector, opts )
8732
8765
  {
8733
8766
  var data = settings.aoData;
8734
8767
  var rows = _selector_row_indexes( settings, opts );
8735
8768
  var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
8736
- var allCells = $( [].concat.apply([], cells) );
8769
+ var allCells = $(_flatten( [], cells ));
8737
8770
  var row;
8738
8771
  var columns = settings.aoColumns.length;
8739
8772
  var a, i, ien, j, o, host;
@@ -9005,7 +9038,7 @@
9005
9038
  // Simple column / direction passed in
9006
9039
  order = [ [ order, dir ] ];
9007
9040
  }
9008
- else if ( order.length && ! $.isArray( order[0] ) ) {
9041
+ else if ( order.length && ! Array.isArray( order[0] ) ) {
9009
9042
  // Arguments passed in (list of 1D arrays)
9010
9043
  order = Array.prototype.slice.call( arguments );
9011
9044
  }
@@ -9041,7 +9074,7 @@
9041
9074
  ctx[0].aaSortingFixed :
9042
9075
  undefined;
9043
9076
 
9044
- return $.isArray( fixed ) ?
9077
+ return Array.isArray( fixed ) ?
9045
9078
  { pre: fixed } :
9046
9079
  fixed;
9047
9080
  }
@@ -9501,7 +9534,7 @@
9501
9534
  * @type string
9502
9535
  * @default Version number
9503
9536
  */
9504
- DataTable.version = "1.10.21";
9537
+ DataTable.version = "1.10.22";
9505
9538
 
9506
9539
  /**
9507
9540
  * Private data store, containing all of the settings objects that are
@@ -9919,8 +9952,8 @@
9919
9952
  * version is still, internally the primary interface, but is is not documented
9920
9953
  * - hence the @name tags in each doc comment. This allows a Javascript function
9921
9954
  * to create a map from Hungarian notation to camel case (going the other direction
9922
- * would require each property to be listed, which would at around 3K to the size
9923
- * of DataTables, while this method is about a 0.5K hit.
9955
+ * would require each property to be listed, which would add around 3K to the size
9956
+ * of DataTables, while this method is about a 0.5K hit).
9924
9957
  *
9925
9958
  * Ultimately this does pave the way for Hungarian notation to be dropped
9926
9959
  * completely, but that is a massive amount of work and will break current
@@ -14575,7 +14608,7 @@
14575
14608
  for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
14576
14609
  button = buttons[i];
14577
14610
 
14578
- if ( $.isArray( button ) ) {
14611
+ if ( Array.isArray( button ) ) {
14579
14612
  var inner = $( '<'+(button.DT_el || 'div')+'/>' )
14580
14613
  .appendTo( container );
14581
14614
  attach( inner, button );
@@ -14620,14 +14653,14 @@
14620
14653
  case 'last':
14621
14654
  btnDisplay = lang.sLast;
14622
14655
 
14623
- if ( page === pages-1 ) {
14656
+ if ( pages === 0 || page === pages-1 ) {
14624
14657
  tabIndex = -1;
14625
14658
  btnClass += ' ' + disabledClass;
14626
14659
  }
14627
14660
  break;
14628
14661
 
14629
14662
  default:
14630
- btnDisplay = button + 1;
14663
+ btnDisplay = settings.fnFormatNumber( button + 1 );
14631
14664
  btnClass = page === button ?
14632
14665
  classes.sPageButtonActive : '';
14633
14666
  break;