aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-10-26 19:06:48 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-10-26 19:06:48 +0100
commite06b4dd9253fa7affdd95ff24fb13dd2975845aa (patch)
tree7637e875c18c4c4d3d1569ed831446412557290c
parentCleanup and move input_list to own file. (diff)
downloadcalp-e06b4dd9253fa7affdd95ff24fb13dd2975845aa.tar.gz
calp-e06b4dd9253fa7affdd95ff24fb13dd2975845aa.tar.xz
Fix listener propagation for "root" element.
-rw-r--r--static/input_list.js6
1 files changed, 3 insertions, 3 deletions
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);