mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 22:18:41 +00:00
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:
13
utils.js
13
utils.js
@@ -1,7 +1,18 @@
|
|||||||
function contains(list, elem) {
|
function fastContains(list, elem) {
|
||||||
return list.indexOf(elem) !== -1;
|
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 = {
|
module.exports = {
|
||||||
contains: contains
|
contains: contains
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user