Skip to content

Custom elements and props #2615

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

Closed
jussiarpalahti opened this issue Apr 29, 2019 · 4 comments
Closed

Custom elements and props #2615

jussiarpalahti opened this issue Apr 29, 2019 · 4 comments

Comments

@jussiarpalahti
Copy link

jussiarpalahti commented Apr 29, 2019

Thought I'd report behavior that tripped me. It looks like component props behave differently when compiled with customElements settings than without. This happens when instantiating Svelte app directly. It also happens when using components as custom elements directly in page.

With customElements component's script part doesn't seem to evaluate props and instead uses the default value (or undefined if none is set). However, in the HTML part the prop has access to value given by parent.

Without customElements in the mix component's has prop's value set in script part as well.

Here's a Gist that should repeat the issue:
https://gist.github.com/jussiarpalahti/99ec05a9dc26cda078bee0846a7a5fd0

I used project exported from REPL as basis for this.

@caseywoolley
Copy link

I'm seeing this same issue while using webpack svelte-loader. Option customElement: true causes exported props to not pass down prop values.

@malinowskip
Copy link

It looks like props are undefined when the component initializes, but they are passed immediately afterwards.

https://gist.github.com/malinowskip/7335a1e878a3d9af3cff433f614cc468

@Marcus-Rise
Copy link

Same issue

@Marcus-Rise
Copy link

Duplicate of #2227

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

No branches or pull requests

6 participants