Open ivan-martinez opened 8 years ago
Hi, I got the same problem when sorting element in a table. Please find attached a zip file containing two test case which reproduce the error. The error is a "undefined" in normchunk() function, with the first test case (jslist_testcase0), if you make a sort, the first time you click the "sort by name" button, nothing happen, the javascript error is fired, but if you re click the button, the result comes out, but one line in the table as been removed ! With the second test case (jslist_testcase1) the sort fire javascript error each time you click the button "sort by name" and nothing is sorted. I fixed that by modifying the normchunk() function (around line 1184) like this:
normChunk = function(s, l) {
// normalize spaces; find floats not starting with '0', string or 0 if not defined (Clint Priest)
if (typeof(s) === 'undefined') return 0;
return (!s.match(ore) || l == 1) && parseFloat(s) || s.replace(snre, ' ').replace(sre, '') || 0;
},
But I don't know if this can have some bad effects.
--Cricri jslist_testcase.zip
Hi,
I ran into the same issue, ( in v1.1.1)
I solved it by changing this piece of code:
for (var cLoc = 0, xNl = xN.length, yNl = yN.length, numS = Math.max(xNl, yNl) ; cLoc < numS; cLoc++) { oFxNcL = normChunk(xN[cLoc], xNl); oFyNcL = normChunk(yN[cLoc], yNl);
I replaced the Match.max() function with the Match.min() function.
As far as I understand, xN and yN are lists of components of the two items to be compared. It makes more sense to me, to compare the components only up to the number of items in the smallest list. Beyond that the 'undefined' value is passed to the normChunk function, which caused an uncaught exception, in my case resulting in items being dropped from the table.
Just my $0.02
When you are filtering two equal strings and the second one ends with one number the loop for sends to normChunk function a null value in the first parameter of the second call.
List items: Recommendation Recommendation 2
Code executing: for (var cLoc = 0, xNl = xN.length, yNl = yN.length, numS = Math.max(xNl, yNl) ; cLoc < numS; cLoc++) { oFxNcL = normChunk(xN[cLoc], xNl); oFyNcL = normChunk(yN[cLoc], yNl); [...]
xN.length = 3 yN.length = 1
so the second loop with cLoc=1 => yN[cLoc] is undefined
In my file I fixed this issue with: normChunk = function (s, l) { // normalize spaces; find floats not starting with '0', string or 0 if not defined (Clint Priest) this line => if (s == null) { return ''; } return (!s.match(ore) || l == 1) && parseFloat(s) || s.replace(snre, ' ').replace(sre, '') || 0; }, I'm not sure whether it is the best solution.
Thanks, Regards