Open xPapay opened 2 years ago
Also one other thing I've noticed when I tried to debug this is that connectedCallback is called multiple times and the complex properties are reset right after the connectedCallback is called. I don't know yet why connectedCallback is called multiple times, but I if it's called I would expect disconnectedCallback to be called before connectedCallback is called second time. But it's never called.
I took a look into this. It turns out that the browser only calls connectedCallback
once, which is why you're not seeing any calls to disconnectedCallback
. However preact-custom-element
also calls connectedCallback
itself the first time a setter is called, which is why the function ends up being called twice. I'm not sure why that call was added, it doesn't really seem like the correct thing to do.
Hi. Firstly, thank you all for your amazing work on the preactjs project!
When I set a complex property (callback) AFTER at least one other property Then the complex property become undefined.
All complex properties become undefined, unless the complex property is the first property set.
I wrote failing test to explain better. (See attached diff file)
TLDR;
Also one other thing I've noticed when I tried to debug this is that
connectedCallback
is called multiple times and the complex properties are reset right after theconnectedCallback
is called. I don't know yet whyconnectedCallback
is called multiple times, but I if it's called I would expectdisconnectedCallback
to be called beforeconnectedCallback
is called second time. But it's never called.When I forcefully prevent the connecting new vdom if we already connected one, then it works as expected. But I would rather understand what causes the element to connect to dom second time, and if we should set there the same properties we already set (same as we do in
attributeChangedCallback
when we cloning the previous vdom).version: 4.2.1
Git diff file: preact-custom-element-bug.txt