The following code regarding Mixitup.js doesn't work in Internet Explorer but working fine in all other browsers.
Could anyone help with this or could adjust the code for working in Internet Explorer?
<script src="https://cdnjs.cloudflare.com/ajax/libs/mixitup/3.3.0/mixitup.min.js">
</script>
<script>
// 2) Reusable function to convert any string/text to css-friendly format
var conv = function (str) {
if (!str) {
str = 'empty';
} return str.replace(/[!\"#$%&'\(\)\*\+,\.\/:;<=>\?\@\[\\\]\^`\{\|\}~]/g, '')
.replace(/ /g, "-")
.toLowerCase()
.trim();
};
// 3) Creating dynamic elements classes from its categories for filtering:
var catArray = document.querySelectorAll('.w-dyn-item .filter-category');
catArray.forEach( function(elem) {
var text = elem.innerText || elem.innerContent;
var className = conv(text);
elem.parentElement.parentElement.parentElement.parentElement.classList.add(className);
});
// 4) Creating custom data-date attributes from blog dates:
var sortArray = document.querySelectorAll('.w-dyn-item .sort-category');
sortArray.forEach( function(sortElem) {
var sortText = sortElem.innerText || sortElem.innerContent;
sortElem.parentElement.parentElement.setAttribute('data-date', sortText);
});
// 5) Set the reference to the container. Use the class-name of your Collection List or ID of the Collection List
var containerEl = document.querySelector('.collection-list');
// 6) Call the MixitUp plugin
mixitup(containerEl);
</script>
I run your code in IE and it shows error
Object doesn't support property or method 'forEach'.ForEachis defined for NodeList not HTMLCollection. We can polyfillforEachfor HTMLCollection then it can be used for both NodeList and HTMLCollection in IE.Polyfill: