Skip to content

Commit

Permalink
fix #776
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jul 4, 2016
1 parent c635440 commit b779ae4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions core/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,28 @@ if (!String.prototype.endsWith) {
}

if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
Object.defineProperty(Array.prototype, "find", {
value: function(predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;

for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
}
return undefined;
};
});
}

// Disable resizing in Firefox
Expand Down

0 comments on commit b779ae4

Please sign in to comment.