Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Svelte: Web components passing prop camel case

I am using web components generated by svelte. I have props defined in camel case (someType) and the expectation was that the following should work but doesn't

<my-web-c some-type="stringVal"></my-web-c>

Is this to be expected? Are there any options by which this can work?

I am aware that passing props as snake case and plain values does work like in JS (some_type)

<my-web-c some_type="stringVal"></my-web-c>

or in JS (sometype)

<my-web-c sometype="stringVal"></my-web-c>

But was curious about the camel case.

like image 384
Syed Osama Maruf Avatar asked Sep 03 '25 07:09

Syed Osama Maruf


1 Answers

You can just use a camel case prop like this:

<my-web-c someType="stringVal"></my-web-c>

This REPL shows different props types in action. Kebab-case isn't currently supported. There is an issue open for it here.

like image 110
digby280 Avatar answered Sep 04 '25 23:09

digby280