From e06b4dd9253fa7affdd95ff24fb13dd2975845aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 26 Oct 2020 19:06:48 +0100 Subject: Fix listener propagation for "root" element. --- static/input_list.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'static') diff --git a/static/input_list.js b/static/input_list.js index 642d9ade..b15162d6 100644 --- a/static/input_list.js +++ b/static/input_list.js @@ -12,8 +12,8 @@ function transferListeners(old_unit, new_unit) { - for (let [o, n] of zip(old_unit.querySelectorAll("*"), - new_unit.querySelectorAll("*"))) { + for (let [o, n] of zip([old_unit, ...old_unit.querySelectorAll("*")], + [new_unit, ...new_unit.querySelectorAll("*")])) { for (const key in o.listeners) { if (! o.listeners.hasOwnProperty(key)) continue; for (let proc of o.listeners[key]) { @@ -62,12 +62,12 @@ function update_inline_list () { function init_input_list() { for (let lst of document.getElementsByClassName('input-list')) { - let oldUnit = lst.querySelector('.final.unit') for (let el of lst.getElementsByTagName('input')) { el.addEventListener('input', update_inline_list); } + let oldUnit = lst.querySelector('.final.unit') let unit = oldUnit.cloneNode(true); transferListeners(oldUnit, unit); -- cgit v1.2.3