forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
8 years ago
|
//修复ie9下sort方法的bug
|
||
|
!function (window) {
|
||
|
var ua = window.navigator.userAgent.toLowerCase(),
|
||
|
reg = /msie|applewebkit.+safari/;
|
||
|
if (reg.test(ua)) {
|
||
|
var _sort = Array.prototype.sort;
|
||
|
Array.prototype.sort = function (fn) {
|
||
|
if (!!fn && typeof fn === 'function') {
|
||
|
if (this.length < 2) {
|
||
|
return this;
|
||
|
}
|
||
|
var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0;
|
||
|
for (; i < l; i++) {
|
||
|
for (j = i + 1; j < l; j++) {
|
||
|
t = fn.call(this, this[i], this[j]);
|
||
|
r = (typeof t === 'number' ? t :
|
||
|
!!t ? 1 : 0) > 0;
|
||
|
if (r === true) {
|
||
|
tmp = this[i];
|
||
|
this[i] = this[j];
|
||
|
this[j] = tmp;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return this;
|
||
|
} else {
|
||
|
return _sort.call(this);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}(window);
|