Possible bug: DataTables 2.1.7 datatables.js - function _fnStringToCss( s ) - line 5604
Possible bug: DataTables 2.1.7 datatables.js - function _fnStringToCss( s ) - line 5604
rsiegel64
Posts: 5Questions: 2Answers: 0
Description of problem: _fnStringToCss(s) sometimes being sent an object, throwing an s.match not a function error. Bug either in the sender or this function. Locally, I fixed by replacing s.match(/\d$/) with s.toString().match(/\d$/), which works for me.
function _fnStringToCss( s )
{
if ( s === null ) {
return '0px';
}
if ( typeof s == 'number' ) {
return s < 0 ?
'0px' :
s+'px';
}
// Check it has a unit character already
return s.match(/\d$/) ?
s + 'px' :
s;
}
Answers
Can you post a link to a test case showing the issue please? I'm not sure under what conditions that would happen, so it would be instructive to see an example.
Allan
I can post code snippets. Here is the code used.
This code throws an s.match not a function error on line 5604 of the datatables.js file - function _fnStringToCss( s ). There is no error if I comment out the scrollX and scrollY lines. Think _fnStringToCss is being called directly from _fnScrollDraw( settings ) - line 5190.
Hope this helps.
It doesn't appear to trigger an error if I use that configuration here: https://live.datatables.net/zofobafo/1/edit .
What version of DataTables are you using? If not the latest (2.1.7), I'd suggest updating.
Allan
Thank you for the test case, I'll take a look. Just upgraded to 2.1.7 from 1.10.x.