-
Notifications
You must be signed in to change notification settings - Fork 75
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
Casing of signals/computed signal names #450
Comments
Just discovered that I can get my camelCase this way (which makes my normalizing comments above somewhat moot): data-signals-gradient-color="$pokemonType"
>
<h1 data-text="$gradientColor"></h1> Definitely needs to be documented somewhere. Yes, I realize this is just how I think it should be noted in the Datastar documentation that it will do this automatic conversion from kebab-case to camelCase for So let's call this a documentation issue. |
Interestingly, this little trick is supposed to work, but doesn't: data-signals--gradient-color="$pokemonType"
>
<h1 data-text="ctx.signals.JSON()"></h1> Outputs:
When it should be:
...according to this. |
Agreed that some of this should be documented. Raised a PR for the key conversion issue at #451. |
The docs currently state:
If this is insufficient, please make a suggestion. |
Released the fix in v1.0.0-beta.2. |
It appears that signal names and computed signal names defined like
data-signals-gradientName
&data-computed-gradientName
are lower-cased before the computed signals are created.This works:
but this doesn't work:
so it looks like it's lower-casing what I name the attribute, so this works:
which is frankly a little weird (and undocumented as far as I can tell).
I think signal and computed signal name case should be honored, so camelCase (or whatever people want) can be used for signal names. CamelCase and other casing does work if signals are declared via object syntax, e.g.:
...which is inconsistent, and also, of course, we can't use any kind of object syntax for defining computed signals.
If this is due to limitations of the HTML spec, then probably:
That means that
$gradientColor
would be normalized to$gradientcolor
before it is evaluated in an expression, and object keys indata-signals="{}"
should be normalized to lowercase as well, just like they are when I dodata-signals-gradientName
The text was updated successfully, but these errors were encountered: