Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interop problems with Svelte #73

Open
seriousManual opened this issue Sep 7, 2022 · 0 comments
Open

Interop problems with Svelte #73

seriousManual opened this issue Sep 7, 2022 · 0 comments

Comments

@seriousManual
Copy link

seriousManual commented Sep 7, 2022

I'm right now trying to integrate a Custom Element that has been created via preact-custom-element into a Svelte application.
Whenever the CE is rendered by svelte an error comes up that emerges at the "place" where Svelte hands over properties/attributes to the Custom Element:

image
("Uncaught TypeError: Cannot read properties of undefined (reading 'props')")

The place this error is thrown is this line of code:
image

(https://github.com/preactjs/preact-custom-element/blob/master/src/index.js#L27)

My understanding is that preact-custom-element assumes that a property value will always be set before it is ever read.
Therefore the if statement in line 30 that checks for an initialized vdom (https://github.com/preactjs/preact-custom-element/blob/master/src/index.js#L30).

Now the problem gets clearer when we look at the code where svelte assigns values to the custom element:
image
(https://github.com/sveltejs/svelte/blob/master/src/runtime/internal/dom.ts#L315)

The function that is responsible always reads (get) the value from the custom element (via the typeof statement) before it sets the value, while preact-custom-element assumes that the value is set before it is read.

Please let me know if my analysis makes sense and if you'd consider this something that should be fixed here or rather in the svelte implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant