I've created a small search function that will go through a bunch of XML data and pull out results based on the user's query, it works swimmingly in Chrome but it consistently crashes IE11 after the user enters about two characters.
Before you ask, I am using a prototype for .filter
copied directly from MDN. I didn't include this because it works and doing so would have doubled the length of the code.
function search() {
var query = document.getElementById("query").value.toLowerCase();
returnSearch(query);
};
//loads xml data
function loadData() {
var data = new XMLHttpRequest();
data.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
getData(this);
}
};
data.open("GET", "abbreviations.xml", true);
data.send();
};
function getData(xml){
var xmlDoc = xml.responseXML;
var acronym = xmlDoc.getElementsByTagName("acronym");
for(var i=0; i < acronym.length; i++) {
content.push(acronym[i].getElementsByTagName("name")[0].childNodes[0].nodeValue + " means: "+ acronym[i].getElementsByTagName("meaning")[0].childNodes[0].nodeValue );
}
};
function returnSearch(query) {
var regexp = new RegExp(query, 'i');
//Its laughable that ie dosen't accept arrow functions
var results = content.filter(function (result) {
return regexp.test(result);
});
document.getElementById('results').innerHTML = results;
console.log(results);
};
This works fine in Chrome, so my question is less of a how to and more of a "why does IE not like this".