JS for IE8: failsafe console handling & others
It's quite tricky to get this working. Still not perfect, but works as expected. Also added Function.bind and Array.indexOf - absence of both used to cause JS errors. refs #6417
This commit is contained in:
parent
ca6b373be2
commit
0d9f8786f9
|
@ -16,7 +16,28 @@
|
|||
|
||||
})(Object);
|
||||
|
||||
(function (console) {
|
||||
(function (Array) {
|
||||
|
||||
'use strict';
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function(elt) {
|
||||
var len = this.length >>> 0;
|
||||
|
||||
var from = Number(arguments[1]) || 0;
|
||||
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
|
||||
if (from < 0) from += len;
|
||||
|
||||
for (; from < len; from++) {
|
||||
if (from in this && this[from] === elt) {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
})(Array);
|
||||
|
||||
if ('undefined' !== typeof console) { (function (console) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -40,7 +61,32 @@
|
|||
console[method] = this.call(console[method], console);
|
||||
}, Function.prototype.bind);
|
||||
}
|
||||
})(console);
|
||||
})(console); }
|
||||
|
||||
/* I intentionally moved this here, AFTER console handling */
|
||||
/* Could be switched, but please take care when doing so */
|
||||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function (oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
||||
}
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
fNOP = function () {},
|
||||
fBound = function () {
|
||||
return fToBind.apply(this instanceof fNOP && oThis
|
||||
? this
|
||||
: oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
|
||||
fNOP.prototype = this.prototype;
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
return fBound;
|
||||
};
|
||||
}
|
||||
|
||||
/* jQuery Plugins */
|
||||
(function ($) {
|
||||
|
|
Loading…
Reference in New Issue