From 74709b0abcbba89c14e0b600df83ff24d8844037 Mon Sep 17 00:00:00 2001 From: James Birtles Date: Mon, 20 Feb 2017 00:16:23 +0000 Subject: [PATCH] Apply context when dispatching event `this` inside of event listeners should be the element that the listener was registered on. Without this, dispatching events on preact elements was failing with `Cannot read property 'click' of undefined` --- src/undom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/undom.js b/src/undom.js index 818a811..fe211e0 100644 --- a/src/undom.js +++ b/src/undom.js @@ -134,7 +134,7 @@ export default function undom() { do { l = t.__handlers[toLower(event.type)]; if (l) for (i=l.length; i--; ) { - if ((l[i](event)===false || event._end) && c) break; + if ((l[i].call(t, event)===false || event._end) && c) break; } } while (event.bubbles && !(c && event._stop) && (event.target=t=t.parentNode)); return !event.defaultPrevented;