Closed jaschaio closed 4 years ago
It's currentTarget
, not target ... target can be any node, currentTarget is the one where you attached the event.
That being said, I am not planning to rewrite the native event bus, so if currentTarget doesn't solve, you should find a better solution, as I don't think I can do much, it's all native behaviour you can replicate without the lib, hence expected.
P.S. of course unless it's not a bug of disconnected library
Thanks for your input. event.currentTarget
is actually null
when awaiting something.
But it works both with event.target
and event.currentTarget
when storing it to another variable before calling await
:
async onconnected( event ) {
var target = event.target;
await timeout( 1000 );
console.log( "connected Second Component", target );
}
As you said this is probably all native behaviour and has nothing to do with hyperhtml. I will leave it for reference in case somebody else runs into a similar issue.
I still suggest you use currentTarget
, as it will always be the element with a listener, not one of its children.
Hey there, it looks like the
event.target
of theonconnected
/ondisconnected
events changes to the last emitted event when using async event handlers.Codepen: https://codepen.io/jaschaio/pen/NWWevNN?editors=0010
Code Example:
I would expect the Following console.log output:
but I actually always get the Second Component div as the
event.target
: