Permalink
Browse files

Merge pull request #1 from rvagg/master

dodgy Array.prototype.filter pollyfill
  • Loading branch information...
2 parents a7851d0 + cd83114 commit 87afb9f9893ba3d0cb898aac21add69ba65dc972 @cjohansen cjohansen committed Oct 27, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/buster-core.js
View
8 lib/buster-core.js
@@ -189,18 +189,18 @@ var buster = (function (setTimeout, B) {
};
} else {
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
- buster.filter = function (fn, thisp) {
+ buster.filter = function (arr, fn, thisp) {
"use strict";
- if (this == null) { throw new TypeError(); }
+ if (arr == null) { throw new TypeError(); }
- var t = Object(this);
+ var t = Object(arr);
var len = t.length >>> 0;
if (typeof fn != "function") { throw new TypeError(); }
var res = [];
for (var i = 0; i < len; i++) {
if (i in t) {
- var val = t[i]; // in case fun mutates this
+ var val = t[i];
if (fn.call(thisp, val, i, t)) { res.push(val); }
}
}

0 comments on commit 87afb9f

Please sign in to comment.