-
-
Save broofa/1099000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply: (Prototype.Browser.IE ? function(o, a) { | |
a = a || []; | |
switch (a.length) { | |
case 0: return this.call( o); | |
case 1: return this.call( o, a[0]);// shreddin' the argument powder | |
case 2: return this.call( o, a[0], a[1]);// \__O_/ | |
case 3: return this.call( o, a[0], a[1], a[2]);// | | |
case 4: return this.call( o, a[0], a[1], a[2], a[3]);// \ /\ | |
case 5: return this.call( o, a[0], a[1], a[2], a[3], a[4]);// \ / | |
case 6: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5]);// \ | |
case 7: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6]); | |
case 8: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); | |
case 9: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); | |
case 10: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]); | |
case 11: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10]); | |
case 12: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]); | |
case 13: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12]); | |
case 14: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13]); | |
case 15: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]); | |
case 16: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); | |
case 17: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16]); | |
case 18: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17]); | |
case 19: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18]); | |
case 20: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19]); | |
case 21: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20]); | |
case 22: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21]); | |
case 23: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22]); | |
case 24: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22], a[23]); | |
case 25: return this.call( o, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22], a[23], a[24]); | |
} | |
return this._apply(o, a); | |
} : Function.prototype.apply), |
no need to ua sniff amiright? what's this for?
just riffing on https://gist.github.com/1099000/02cd631cb52ab159e5085c82cf8e14b5a164332f
Don't recall the original rational for the ua sniff. either early versions of IE didn't support apply(), or they weren't performant .vs. call().
As I recall this was the solution to a weird error we encountered with cross-window js invocation in ie7.
apply() method didn't exist pre IE5.5 I believe. wrote that code circa 2006-2007.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I mean, if you need more than 7 arguments, you're code is pretty fucked anyway ...