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

View File

@ -413,8 +413,7 @@
}; };
this.giveFeedback = function (subject, klass, message) { this.giveFeedback = function (subject, klass, message) {
const els = document.querySelectorAll('.conn-feedback'); _.forEach(document.querySelectorAll('.conn-feedback'), (el) => {
_.forEach(els, function (el) {
el.classList.add('conn-feedback'); el.classList.add('conn-feedback');
el.textContent = subject; el.textContent = subject;
if (klass) { 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) { el.addEventListener('click', function (ev) {
ev.preventDefault(); ev.preventDefault();
var hash = this.getAttribute("href") var hash = this.getAttribute("href")