Skip to content

Instantly share code, notes, and snippets.

@JohanObrink
Last active December 18, 2015 14:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JohanObrink/5796334 to your computer and use it in GitHub Desktop.
Save JohanObrink/5796334 to your computer and use it in GitHub Desktop.
Fix for Array.prototype.slice.call not working on NodeLists in IE8
(function() {
if(navigator.appVersion.indexOf('MSIE 8') > 0) {
var _slice = Array.prototype.slice;
Array.prototype.slice = function() {
if(this instanceof Array) {
return _slice.apply(this, arguments);
} else {
var result = [];
var start = (arguments.length >= 1) ? arguments[0] : 0;
var end = (arguments.length >= 2) ? arguments[1] : this.length;
for(var i=start; i<end; i++) {
result.push(this[i]);
}
return result;
}
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment