datatables.net 3.0.1 → 3.0.2

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.
package/js/dataTables.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! DataTables 3.0.1
1
+ /*! DataTables 3.0.2
2
2
  * Copyright (c) SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -3886,7 +3886,7 @@ const ext = {
3886
3886
  * Software version
3887
3887
  * @type string
3888
3888
  */
3889
- version: '3.0.1'
3889
+ version: '3.0.2'
3890
3890
  };
3891
3891
  //
3892
3892
  // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
@@ -4978,7 +4978,7 @@ function clearTable(settings) {
4978
4978
  * @param colIdx Column index to invalidate. If undefined the whole row will be
4979
4979
  * invalidated
4980
4980
  */
4981
- function invalidate(settings, rowIdx, src, colIdx) {
4981
+ function invalidateRow(settings, rowIdx, src, colIdx) {
4982
4982
  var row = settings.data[rowIdx];
4983
4983
  var i, iLen;
4984
4984
  if (!row) {
@@ -5008,6 +5008,18 @@ function invalidate(settings, rowIdx, src, colIdx) {
5008
5008
  }
5009
5009
  }
5010
5010
  }
5011
+ invalidColumn(settings, colIdx);
5012
+ // Update DataTables special `DT_*` attributes for the row
5013
+ rowAttributes(settings, row);
5014
+ callbackFire(settings, null, 'rowInvalidate', [settings, rowIdx, colIdx], false);
5015
+ }
5016
+ /**
5017
+ * Column specific invalidation
5018
+ *
5019
+ * @param settings DataTables settings object
5020
+ * @param colIdx Column index to invalidate, or all columns if not given
5021
+ */
5022
+ function invalidColumn(settings, colIdx) {
5011
5023
  // Column specific invalidation
5012
5024
  var cols = settings.columns;
5013
5025
  if (colIdx !== undefined) {
@@ -5018,14 +5030,12 @@ function invalidate(settings, rowIdx, src, colIdx) {
5018
5030
  cols[colIdx].wideStrings = null;
5019
5031
  }
5020
5032
  else {
5021
- for (i = 0, iLen = cols.length; i < iLen; i++) {
5033
+ for (let i = 0, iLen = cols.length; i < iLen; i++) {
5022
5034
  cols[i].type = null;
5023
5035
  cols[i].wideStrings = null;
5024
5036
  }
5025
- // Update DataTables special `DT_*` attributes for the row
5026
- rowAttributes(settings, row);
5027
5037
  }
5028
- callbackFire(settings, null, 'rowInvalidate', [settings, rowIdx, colIdx], false);
5038
+ settings.containerWidth = -1;
5029
5039
  }
5030
5040
  /**
5031
5041
  * Get the cells and data for a given row - from a <tr> element
@@ -5114,10 +5124,21 @@ function readCellData(settings, cell, data, colIdx) {
5114
5124
  }
5115
5125
  }
5116
5126
 
5127
+ /**
5128
+ * Recalculate the column widths, if needed (by a column having been
5129
+ * invalidated)
5130
+ *
5131
+ * @param settings DataTables settings object
5132
+ */
5133
+ function columnWidths(settings) {
5134
+ if (settings.columns.map(c => c.wideStrings).includes(null)) {
5135
+ calculateColumnWidths(settings);
5136
+ }
5137
+ }
5117
5138
  /**
5118
5139
  * Calculate the width of columns for the table
5119
5140
  *
5120
- * @param settings dataTables settings object
5141
+ * @param settings DataTables settings object
5121
5142
  */
5122
5143
  function calculateColumnWidths(settings) {
5123
5144
  // Not interested in doing column width calculation if auto-width is disabled
@@ -5665,12 +5686,9 @@ function scrollDraw(settings) {
5665
5686
  // Check against what the colgroup > col is set to and correct if needed
5666
5687
  for (let i = 0; i < colSizes.length; i++) {
5667
5688
  let colEl = settings.columns[colSizes[i].idx].colEl;
5668
- let colWidth = colEl.width();
5669
- if (colWidth !== colSizes[i].width) {
5670
- colEl.css('width', colSizes[i].width + 'px');
5671
- if (scroll.x) {
5672
- colEl.css('minWidth', colSizes[i].width + 'px');
5673
- }
5689
+ colEl.css('width', colSizes[i].width + 'px');
5690
+ if (scroll.x) {
5691
+ colEl.css('minWidth', colSizes[i].width + 'px');
5674
5692
  }
5675
5693
  }
5676
5694
  }
@@ -5968,13 +5986,15 @@ function _typeResult(typeDetect, res) {
5968
5986
  * Calculate the 'type' of a column
5969
5987
  * @param settings DataTables settings object
5970
5988
  */
5971
- function columnTypes(settings) {
5989
+ function columnTypes(settings, originalTypes = '') {
5972
5990
  var columns = settings.columns;
5973
5991
  var data = settings.data;
5974
5992
  var types = ext.type.detect;
5975
5993
  var i, iLen, j, jen, k, ken;
5976
5994
  var col, detectedType, cache;
5977
- var originalTypes = columns.map(c => c.type).join(',');
5995
+ if (!originalTypes) {
5996
+ originalTypes = columns.map(c => c.type).join(',');
5997
+ }
5978
5998
  // For each column, spin over the data type detection functions, seeing if
5979
5999
  // one matches
5980
6000
  for (i = 0, iLen = columns.length; i < iLen; i++) {
@@ -7673,6 +7693,7 @@ function ajaxUpdateDraw(settings, json) {
7673
7693
  var drawUnique = ajaxDataSrcParam(settings, 'draw', json);
7674
7694
  var recordsTotal = ajaxDataSrcParam(settings, 'recordsTotal', json);
7675
7695
  var recordsFiltered = ajaxDataSrcParam(settings, 'recordsFiltered', json);
7696
+ var existingTypes = settings.columns.map(c => c.type).join(',');
7676
7697
  if (drawUnique !== undefined) {
7677
7698
  // Protect against out of sequence returns
7678
7699
  if (drawUnique * 1 < settings.drawCount) {
@@ -7692,7 +7713,7 @@ function ajaxUpdateDraw(settings, json) {
7692
7713
  addData(settings, data[i]);
7693
7714
  }
7694
7715
  settings.display = settings.displayMaster.slice();
7695
- columnTypes(settings);
7716
+ columnTypes(settings, existingTypes);
7696
7717
  draw(settings, true);
7697
7718
  initComplete(settings);
7698
7719
  processingDisplay(settings, false);
@@ -8404,6 +8425,7 @@ function reDraw(settings, holdPosition, recompute) {
8404
8425
  // Resolve any column types that are unknown due to addition or
8405
8426
  // invalidation
8406
8427
  columnTypes(settings);
8428
+ columnWidths(settings);
8407
8429
  if (doSort) {
8408
8430
  sort(settings);
8409
8431
  }
@@ -9720,7 +9742,7 @@ registerPlural('cells().indexes()', 'cell().index()', function () {
9720
9742
  });
9721
9743
  registerPlural('cells().invalidate()', 'cell().invalidate()', function (src) {
9722
9744
  return this.iterator('cell', function (settings, row, column) {
9723
- invalidate(settings, row, src, column);
9745
+ invalidateRow(settings, row, src, column);
9724
9746
  });
9725
9747
  });
9726
9748
  register('cell()', function (rowSelector, columnSelector, opts) {
@@ -9737,7 +9759,7 @@ register('cell().data()', function (data) {
9737
9759
  }
9738
9760
  // Set
9739
9761
  setCellData(ctx[0], cell[0].row, cell[0].column, data);
9740
- invalidate(ctx[0], cell[0].row, 'data', cell[0].column);
9762
+ invalidateRow(ctx[0], cell[0].row, 'data', cell[0].column);
9741
9763
  return this;
9742
9764
  });
9743
9765
 
@@ -9753,7 +9775,7 @@ register('cell().data()', function (data) {
9753
9775
  */
9754
9776
  // can be an array of these items, comma separated list, or an array of comma
9755
9777
  // separated lists
9756
- const __re_column_selector = /^([^:]+)?:(name|title|visIdx|visible)$/;
9778
+ const __re_column_selector = /^(.*?):(name|title|visIdx|visible)$/;
9757
9779
  // r1 and r2 are redundant - but it means that the parameters match for the
9758
9780
  // iterator callback in columns().data()
9759
9781
  function columnData(settings, column, r1, r2, rows, type) {
@@ -10689,7 +10711,7 @@ register('rows().data()', function () {
10689
10711
  });
10690
10712
  registerPlural('rows().invalidate()', 'row().invalidate()', function (src) {
10691
10713
  return this.iterator('row', function (settings, row) {
10692
- invalidate(settings, row, src);
10714
+ invalidateRow(settings, row, src);
10693
10715
  });
10694
10716
  });
10695
10717
  registerPlural('rows().indexes()', 'row().index()', function () {
@@ -10776,7 +10798,7 @@ register('row().data()', function (data) {
10776
10798
  util.set(ctx[0].rowId)(data, row.tr.id);
10777
10799
  }
10778
10800
  // Automatically invalidate
10779
- invalidate(ctx[0], this[0][0], 'data');
10801
+ invalidateRow(ctx[0], this[0][0], 'data');
10780
10802
  return this;
10781
10803
  });
10782
10804
  register('row().node()', function () {
@@ -10790,12 +10812,15 @@ register('row().node()', function () {
10790
10812
  return null;
10791
10813
  });
10792
10814
  register('row.add()', function (row) {
10793
- // Allow a jQuery object to be passed in - only a single row is added from
10794
- // it though - the first element in the set
10815
+ // Allow an array-like object to be passed in - only a single row is added
10816
+ // from it though - the first element in the set
10795
10817
  if (row && row.fn && row.length) {
10796
10818
  row = row[0];
10797
10819
  }
10798
10820
  var rows = this.iterator('table', function (settings) {
10821
+ // New column could cause a change in the cached column properties such
10822
+ // as type and width.
10823
+ invalidColumn(settings);
10799
10824
  if (row.nodeName && row.nodeName.toUpperCase() === 'TR') {
10800
10825
  return addTr(settings, Dom.s(row))[0];
10801
10826
  }
@@ -11156,7 +11181,11 @@ function b64ToBuf(b64) {
11156
11181
  */
11157
11182
  function check(releaseDate, software) {
11158
11183
  let expires = _licenseInfo.expires;
11159
- if (_licenseInfo.valid === false) {
11184
+ if (!getSubtle()) {
11185
+ noticePrep('Unable to validate license key');
11186
+ noticeDisplay();
11187
+ }
11188
+ else if (_licenseInfo.valid === false) {
11160
11189
  noticePrep('License key invalid');
11161
11190
  noticeDisplay();
11162
11191
  }
@@ -11283,7 +11312,7 @@ function noticePrep(text) {
11283
11312
  * Display the license notice
11284
11313
  */
11285
11314
  function noticeDisplay() {
11286
- if (!_processingKey && !document.body.contains(_wm[0])) {
11315
+ if (!_processingKey && document.body && !document.body.contains(_wm[0])) {
11287
11316
  document.body.appendChild(_wm[0]);
11288
11317
  }
11289
11318
  }
@@ -11305,36 +11334,33 @@ function verify(licenseString) {
11305
11334
  }
11306
11335
  var payload = parts[0];
11307
11336
  var signatureB64 = parts[1];
11308
- // Backwards compat for old browsers
11309
- var cryptoObj = window.crypto || window.msCrypto;
11310
- var subtle = cryptoObj.subtle || cryptoObj.webkitSubtle;
11337
+ // Extract the payload to be useful
11338
+ var payloadParts = payload.match(/(plus|trial|editor)_(\d+)_(\d{4})(\d{2})(\d{2})/);
11339
+ if (!payloadParts || payloadParts.length !== 6) {
11340
+ _licenseInfo.valid = false;
11341
+ return resolve();
11342
+ }
11343
+ _licenseInfo.type = payloadParts[1];
11344
+ _licenseInfo.developers = parseInt(payloadParts[2]);
11345
+ _licenseInfo.expires = new Date(payloadParts[3] + '-' + payloadParts[4] + '-' + payloadParts[5]);
11346
+ var subtle = getSubtle();
11311
11347
  var rawKey = b64ToBuf(_publicKey);
11312
11348
  var rawSig = b64ToBuf(signatureB64);
11313
11349
  var data = new TextEncoder().encode(payload);
11350
+ // Non-secure environments don't have cryptographic verification
11351
+ // available.
11352
+ if (!subtle) {
11353
+ _licenseInfo.valid = false;
11354
+ resolve();
11355
+ return;
11356
+ }
11314
11357
  subtle
11315
11358
  .importKey('raw', rawKey, { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify'])
11316
11359
  .then(function (key) {
11317
11360
  return subtle.verify({ name: 'ECDSA', hash: { name: 'SHA-256' } }, key, rawSig, data);
11318
11361
  })
11319
11362
  .then(function (isValid) {
11320
- if (!isValid) {
11321
- _licenseInfo.valid = false;
11322
- return resolve();
11323
- }
11324
- // Extract the payload to be useful
11325
- var payloadParts = payload.match(/(plus|trial|editor)_(\d+)_(\d{4})(\d{2})(\d{2})/);
11326
- if (!payloadParts || payloadParts.length !== 6) {
11327
- _licenseInfo.valid = false;
11328
- return resolve();
11329
- }
11330
- _licenseInfo.valid = true;
11331
- _licenseInfo.type = payloadParts[1];
11332
- _licenseInfo.developers = parseInt(payloadParts[2]);
11333
- _licenseInfo.expires = new Date(payloadParts[3] +
11334
- '-' +
11335
- payloadParts[4] +
11336
- '-' +
11337
- payloadParts[5]);
11363
+ _licenseInfo.valid = isValid;
11338
11364
  resolve();
11339
11365
  })
11340
11366
  .catch(function () {
@@ -11383,6 +11409,12 @@ function plus (DataTable) {
11383
11409
  writable: false
11384
11410
  });
11385
11411
  }
11412
+ function getSubtle() {
11413
+ // Backwards compat for old browsers
11414
+ let cryptoObj = window.crypto || window.msCrypto;
11415
+ let subtle = cryptoObj.subtle || cryptoObj.webkitSubtle;
11416
+ return subtle;
11417
+ }
11386
11418
 
11387
11419
  /**
11388
11420
  * CommonJS factory function pass through. This will check if the arguments
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.js",
5
5
  "module": "js/dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "3.0.1",
7
+ "version": "3.0.2",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
package/types/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! DataTables 3.0.1
1
+ /*! DataTables 3.0.2
2
2
  * Copyright (c) SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -1562,7 +1562,7 @@ interface Defaults {
1562
1562
  * Add event listeners during the DataTables startup
1563
1563
  */
1564
1564
  on: {
1565
- [name: string]: (this: HTMLElement, e: Event, ...args: any[]) => void;
1565
+ [name: string]: (this: HTMLElement, e: DataTableEvent, ...args: any[]) => void;
1566
1566
  };
1567
1567
  /**
1568
1568
  * Initial order (sort) to apply to the table.