Don't use forEach on nodeList objects (not supported by all browsers).

This commit is contained in:
JC Brand 2017-08-08 15:32:53 +02:00
parent 8113a14ace
commit a9d1e5c235
3 changed files with 6 additions and 9 deletions

View File

@ -137,7 +137,7 @@
initialize () {
this.model.on('change:current_skintone', this.render, this);
this.model.on('change:current_category', this.render, this);
this.setScrollPosition = _.debounce(this.setScrollPosition, 50);
this.setScrollPosition = _.debounce(this.setScrollPosition, 50).bind(this);
},
render () {
@ -152,10 +152,8 @@
}
));
this.el.innerHTML = emojis_html;
this.el.querySelectorAll('.emoji-picker').forEach((el) => {
el.addEventListener(
'scroll', this.setScrollPosition.bind(this)
);
_.forEach(this.el.querySelectorAll('.emoji-picker'), (el) => {
el.addEventListener('scroll', this.setScrollPosition);
});
this.restoreScrollPosition();
return this;
@ -188,7 +186,7 @@
}
},
setScrollPosition (ev, position) {
setScrollPosition (ev) {
this.model.save('scroll_position', ev.target.scrollTop);
},

View File

@ -413,8 +413,7 @@
};
this.giveFeedback = function (subject, klass, message) {
const els = document.querySelectorAll('.conn-feedback');
_.forEach(els, function (el) {
_.forEach(document.querySelectorAll('.conn-feedback'), (el) => {
el.classList.add('conn-feedback');
el.textContent = subject;
if (klass) {

View File

@ -26,7 +26,7 @@
}
});
document.querySelectorAll('.page-scroll a').forEach(function (el) {
Array.prototype.forEach.call(document.querySelectorAll('.page-scroll a'), function (el) {
el.addEventListener('click', function (ev) {
ev.preventDefault();
var hash = this.getAttribute("href")