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

Allow definition of targets in kebab-case but access via camelCase #187

Open
erinnachen opened this issue Mar 11, 2022 · 2 comments
Open
Labels
Milestone

Comments

@erinnachen
Copy link
Contributor

For attributes, I define in the markup data-my-attr-name and in the controller as @attr myAttrName

For targets however, I have to define the target name in both the markup and the controller using camelCase:
data-targets="my-controller.myTargetsName" and @targets myTargetsName
I think it would be nice (more consistent?) if the markup could support kebab-case.

@keithamus
Copy link
Member

Thanks @erinnachen thats some great feedback!

This sounds like it might be a breaking change. If we're making a breaking change I wonder if we can really think about improving ergonomics for actions, targets and attrs to make them all consistent?

  • maybe attrs can drop the data- prefix? This felt like a safe choice but it's quite ugly
  • how bad would it be to remove the transformation altogether? Such that @attr fooBar mapped to the html attribute fooBar? IIRC attributes are case insensitive which could cause problems 🤷‍♂️

@keithamus keithamus added the @attr label May 3, 2022
@keithamus keithamus added this to the v2 milestone May 5, 2022
@rccc
Copy link

rccc commented Dec 19, 2022

Hello,

Let me add a comment about syntax :

Why

data-targets="my-controller.myTargetsName"

rather than

data-targets="myTargetsName" like stimulus (without "my-controller") ?

Is that the component root element does not corresponds to controller element ("this.element") in stimumlus ?

Thanks in advance

Eric

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

No branches or pull requests

3 participants