Passing data to properties that use camel case names in svelte/sveltekit #4294
Replies: 1 comment 18 replies
-
I thought this would have been covered by custom-elements-everywhere.com, but apparently all the property binding tests use lower-case-only names: https://github.com/webcomponents/custom-elements-everywhere/blob/main/libraries/svelte/src/components/ComponentWithProperties.svelte Even so, looking at the Svelte code I'm not sure that this is an issue with camelCase property names. The I can see a bug there where the property logic only kicks in for own properties of the prototype though, so this logic won't work for inherited accessors. That could be done to avoid setting properties for accessors on HTMLElement, but it breaks inheritance. But don't see this inheritance pattern in ActiveTable - The only other things I could think of are
|
Beta Was this translation helpful? Give feedback.
-
Hi, when working with the Svelte/SvelteKit frameworks - passing data into lit elements generally works fine, however I am experiencing issues when attempting to pass data from state into my element's properties that use camel cases for their names.
Example:
As a workaround I can use the following approach, however this does not work well for passing functions as they don't keep state to the rest of the component:
What is happening here is that Svelte is automatically lower casing the property names and because they no longer match the expected property names - they are assumed to be attributes (hence the stringified approach works). This is also evident by the following line in their codebase:
I was wondering if there is any way to pass data into properties with camel cases using Lit Element.
Here is a live example where passing values into a property called
frameComponentsStyles
can only be done when it is stringified. For referenceframeComponentsStyles
is a simple property that is set up using the following code where FrameComponentsStyles type is an object:Thankyou for your feedback!
Beta Was this translation helpful? Give feedback.
All reactions