preact-custom-element icon indicating copy to clipboard operation
preact-custom-element copied to clipboard

fix: getting vdom prop when vdom is not ready yet

Open finalclass opened this issue 4 years ago • 2 comments

In my app something weird started to happen. I got this error message:

index.js:613 Uncaught TypeError: Cannot read property 'props' of undefined
    at HTMLElement.get (index.js:27)
(redacted)

This have been happening to me when I was using my web component like that:

<sw-text-input value="some value"/>

The weird thing is that removing the value attribute fixes it. Also any other attribute works just fine and also using this component in some other place of the app also works fine (even with the value attribute set).

For some unknown reason preact (or something else?) is trying to read the property of a component before the vdom is there, that's why we need to check for vdom existance (just like it's done in the set function).

finalclass avatar Dec 29 '21 20:12 finalclass

Hi there,

it looks like this might be related to https://github.com/preactjs/preact-custom-element/issues/73? A local test using the change proposed in this PR indicated that the Svelte issue would be solved by this. Any possibility that this gets merged? Or does the change have any other unwanted consequences?

@marvinhagemeister

lfleischmann avatar Sep 26 '22 14:09 lfleischmann