question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property names can be referenced as an attribute using kebab-case

See original GitHub issue

Feature

When using attributes, kebab-case should be automatically recognized.

When I register a property to my Direflow Component:

App.defaultProps = {
  componentTitle: "My Component Title"
}

I should be able to reference these as an attribute using kebab-case

<web-component component-title="New Title"></web-component>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JasonPaapecommented, Aug 27, 2020

@Silind,

Why is this closed and considered redundant? It seems that if I pass in a prop via an attribute that I need to use all lower case for my prop, for example:

App.defaultProps = { componenttitle: “My Component Title” }

<web-component componenttitle="New Title"></web-component>

So when componenttitle changes, my useEffect in my component gets the change. If my prop is componentTitle and I set the html attribute to componentTitle it reverts to all lowercase (as html is case insensitive), and my component doesn’t get the changed value.

I’m using the latest 3.5.0 version. Is there a way for me to use camelCase prop and have it update using an attribute in html?

1reaction
Silentscriptercommented, Apr 23, 2020

I agree with this strategy, sounds fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property and Attribute Names - Salesforce Developers
Property names in JavaScript are in camel case while HTML attribute names are in kebab case (dash-separated) to match HTML standards.
Read more >
What is kebab case? - TheServerSide.com
Kebab case, or kebab-case, is a naming convention that allows a developer to create whitespace between words in code with a dash.
Read more >
Allow for multiple naming conventions (camelCase vs kebab ...
Description json:api documentation recommends using camelCase instead of kebab case here and is discussed on json-api/json-api#1255.
Read more >
lwc Kebab Case child component - Salesforce Stack Exchange
I'm not entirely sure that -case-name is a valid identifier. ... should be prefixed with hyphen(-) followed by the character in lowercase )....
Read more >
Famous camelCase vs kebab-case JavaScript - Medium
HTML5 attributes can start with data- (data-name, data-price). CSS property names has a hyphen (font-size, background-color).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found