stencil
stencil copied to clipboard
bug: hydrate crashes if component uses @Listen
Prerequisites
- [X] I have read the Contributing Guidelines.
- [X] I agree to follow the Code of Conduct.
- [X] I have searched for existing issues that already report this problem, without success.
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.