Skip to content

Commit

Permalink
Enable compatibility for IE11
Browse files Browse the repository at this point in the history
Internet Explorer 11 and some other browsers [don't support calling `forEach` on a `NodeList`](https://caniuse.com/mdn-api_nodelist_foreach). Converting the `NodeList` to an array (for example via `slice`) solves the issue.
  • Loading branch information
stephtr authored Nov 1, 2020
1 parent b6c1409 commit ccc0866
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Nouislider = props => {
const setClickableListeners = () => {
if (props.clickablePips) {
const sliderHTML = sliderContainer.current;
sliderHTML.querySelectorAll(".noUi-value").forEach(pip => {
[].slice.call(sliderHTML.querySelectorAll(".noUi-value")).forEach(pip => {
pip.style.cursor = "pointer";
pip.addEventListener("click", clickOnPip);
});
Expand Down Expand Up @@ -117,7 +117,7 @@ const Nouislider = props => {
return () => {
if (slider) slider.destroy();
if (sliderHTML) {
sliderHTML.querySelectorAll(".noUi-value").forEach(pip => {
[].slice.call(sliderHTML.querySelectorAll(".noUi-value")).forEach(pip => {
pip.removeEventListener("click", clickOnPip);
});
}
Expand Down

0 comments on commit ccc0866

Please sign in to comment.