Prerequisites
Stencil Version
4.19.0
Current Behavior
If a component has a @Listen() function (tested with keydown) Stencil hydrate crashes and does not serialize the component.

Culprit is the hydrateComponent method:
async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
tagName = tagName.toLowerCase();
const Cstr = loadModule(
{
$tagName$: tagName,
$flags$: null
});
if (Cstr != null) {
const cmpMeta = Cstr.cmpMeta;
if (cmpMeta != null) {
waitingElements.add(elm);
const hostRef = getHostRef(this);
addHostEventListeners(this, hostRef, cmpMeta.$listeners$); // --------------------------------- "this" is undefined
Expected Behavior
For components to correctly serialize with @Listen() methods.
System Info
No response
Steps to Reproduce
See repository.
Code Reproduction URL
https://github.com/mayerraphael/stencil-dsd-ssr-playground
Additional Information
The my-whatever-component has an @Listen() method.
Affects both serializeShadowRoot true and false.
Prerequisites
Stencil Version
4.19.0
Current Behavior
If a component has a
@Listen()function (tested with keydown) Stencil hydrate crashes and does not serialize the component.Culprit is the
hydrateComponentmethod:Expected Behavior
For components to correctly serialize with
@Listen()methods.System Info
No response
Steps to Reproduce
See repository.
Code Reproduction URL
https://github.com/mayerraphael/stencil-dsd-ssr-playground
Additional Information
The
my-whatever-componenthas an@Listen()method.Affects both
serializeShadowRoottrue and false.