Fishy code - unremoved event handler in idom
anilanar opened this issue · 1 comments
anilanar commented
I've noticed a fishy line in idom
today while checking something else:
// packages/melody-idom/src/attributes.ts
if (typeof value === 'function') {
let useCapture = name !== (name = name.replace(/Capture$/, ''));
name = name.toLowerCase().substring(2);
if (value) {
if (!attrs[name])
el.addEventListener(name, eventProxy, useCapture);
} else {
el.removeEventListener(name, eventProxy, useCapture);
}
(el._listeners || (el._listeners = {}))[name] = value;
}
Because typeof value === 'function'
, if (value)
is always true. Therefore it will never go into the else condition in which the event handler is removed.
efegurkan commented
Had to reopen because of the revert. Will work on it again