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

webc.renderAttributes loses dashes from original attribute names #216

Open
Gyanreyer opened this issue Nov 2, 2024 · 1 comment
Open

Comments

@Gyanreyer
Copy link
Contributor

Gyanreyer commented Nov 2, 2024

I have a component which accepts data- attributes like data-image-width. Obviously this gets serialized as dataImageWidth on the webc.attributes object, but then if you run webc.renderAttributes(webc.attributes), the attribute ends up getting serialized as dataimagewidth, losing the dashes. Here's a template which should reproduce it:

<!-- my-component.webc -->
<script webc:type="js" webc:root="override">
  `<div ${webc.renderAttributes(webc.attributes)}></div>`
</script>
<!-- page.webc -->
<my-component data-image-width="100"></my-component>

Current output:

<div dataimagewidth="100"></div>

Desired output:

<div data-image-width="100"></div>
@Gyanreyer
Copy link
Contributor Author

Wanted to add that I'm actually seeing this behavior with @attribute as well. This is a pretty big issue because it's killing aria-X attributes that I want to pass through to components. Example:

<!-- my-component.webc -->
<div @attributes>
</div>
<!-- page.webc -->
<my-component aria-label="A label"></my-component>

Current output:

<div arialabel="A label"></div>

Desired output:

<div aria-label="A label"></div>

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

No branches or pull requests

1 participant