Make contains() actually work in IE8
Summary: IE8 doesn't have indexOf on arrays! Reviewers: emily Reviewed By: emily Differential Revision: http://phabricator.khanacademy.org/D3052
This commit is contained in:
parent
ed9d62d98c
commit
c774b69de8
13
utils.js
13
utils.js
|
@ -1,7 +1,18 @@
|
|||
function contains(list, elem) {
|
||||
function fastContains(list, elem) {
|
||||
return list.indexOf(elem) !== -1;
|
||||
}
|
||||
|
||||
function slowContains(list, elem) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i] === elem) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var contains = Array.prototype.indexOf ? fastContains : slowContains;
|
||||
|
||||
module.exports = {
|
||||
contains: contains
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user