-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Update HTML style guide with rule for camel casing attribute values. #11653
Update HTML style guide with rule for camel casing attribute values. #11653
Conversation
@cjcenizal mind if we get some more eyes on this or link to a previous discussion? The text LGTM but I'm against camel casing ids, and I can't find previous discussions. Most html ids I've seen use hyphens and I'm not sure why we'd change it. |
It seems that any naming scheme relying on case sensitivity can lead to subtle bugs because html and css follow different case sensitivity rules. Different browsers also sometimes have different rules. Quoting from the linked article:
|
I'm not necessarily advocating for this, but historically I've found myself using hypens for CSS classes and camelCasing for ids within HTML, but I think it's just a convention I integrated from working with Bootstrap. |
data-test-subj="{{ 'clickMeButton-' + button.id }}" | ||
> | ||
{{ button.label }} | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per Slack convo w/ @archanid, we could expand this exception to use hyphens as a grouping mechanism among similar elements, e.g.
<section id="welcomePage-introSection">
<!-- Content -->
</section>
<section id="welcomePage-aboutSection">
<!-- Content -->
</section>
Ater thinking about this a bit I'm not sure how useful this would be, and I'd prefer to keep our naming as simple as possible. This still seems readable and understandable to me:
<section id="welcomePageIntroSection">
<!-- Content -->
</section>
<section id="welcomePageAboutSection">
<!-- Content -->
</section>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I agree with you @cjcenizal. Simpler is easier to do and clearer to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Bargs I looked into it and here is what I've found:
Given all of these, the only situations where I can see the casing being a problem in our CSS is when we use a |
@cjcenizal Sounds reasonable, thanks for doing the additional research. Just to cover our bases, how would you feel about adding a note that casing in html and css should always match, even if one happens to be case insensitive? |
5740154
to
9135375
Compare
@Bargs Updated, would you mind taking another look? |
9135375
to
cb567f4
Compare
cb567f4
to
28a8ab9
Compare
LGTM! |
Per #11602 (comment):