diff --git a/src/assets/netteForms.js b/src/assets/netteForms.js index d98ea2da0..e42cfe969 100644 --- a/src/assets/netteForms.js +++ b/src/assets/netteForms.js @@ -31,6 +31,7 @@ var Nette = {}; var preventFiltering = {}; var formToggles = {}; + var toggleListeners = new window.WeakMap(); Nette.formErrors = []; Nette.version = '3.0'; @@ -592,7 +593,6 @@ emptyOptional = emptyOptional === undefined ? !Nette.validateRule(elem, ':filled', null, value) : emptyOptional; var has = false, - handled = [], handler = function () { Nette.toggleForm(elem.form, elem); }, @@ -634,9 +634,9 @@ els = curElem.tagName ? curElem.form.elements : curElem; for (var i = 0; i < els.length; i++) { - if (els[i].name === name && handled.indexOf(els[i]) < 0) { + if (els[i].name === name && !toggleListeners.has(els[i])) { els[i].addEventListener('change', handler); - handled.push(els[i]); + toggleListeners.set(els[i], null); } } }