Alphanum: Javascript Natural Sorting Algorithm
這篇提到的問題跟我之前遇到的一模一樣,只要把str modified過之後,存回變數本身,IE就變得怪怪的,我遇到的狀況是會死在sorting function裡面,不過也不是每一次都會發生,ex: a = 'foo.png'; a = a.slice(0, a.indexOf('.'));
,解決的辦法就是用另外一個變數來接。
Alphanum: Javascript Natural Sorting Algorithm - The Roost - by Brian Huisman
a = chunkify(a);
b = chunkify(b);
Note the variable names, where the assignment tries to place the result back into the original variable. Actually, all that's required for the bug to manifest is to assign any array to the incoming a and b variables. For some strange reason this would fail in IE6 and IE7 while sorting arrays with larger than 23 or 24 elements. In these cases, at seemingly random times during the sort, "undefined" would be passed back to a, causing the next reference to it to trigger an exception.
沒有留言:
張貼留言