-
Notifications
You must be signed in to change notification settings - Fork 131
Guideline for feature IDs for interfaces and methods #2866
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
Comments
If removing hyphens, |
Here's an example that did not hyphenate. (So it further illustrates the need for some guidelines) Float16Array
|
This came up in the WebDX call yesterday. I don't feel strongly about this, but I thought it would help to think through how we'd describe the rule. After writing it out, I decided that I like the appearance of the hyphens style better and though that it might be more convenient for certain kinds of transformations (e.g., you can convert the hyphens style to camelCase). But found the pattern more difficult to explain. For the WebGL extensions, we could probably have a special rule in either case that says to convert underscores to hyphens ( So one of these, perhaps? All one word styleIf a feature is named for an API, CSS property, or other literal identifier that you would find in a web developer's source code, then propose an ID that takes the identifier, removes any non-hyphen non-alphanumeric characters (i.e., If a feature has a descriptive name, then propose an ID that replaces any spaces with hyphens, removes any non-alphanumeric characters, and sets the remaining characters to lowercase.
Hyphens styleIf a feature is named for an API, CSS property, or other literal identifier that you would find in a web developer's source code, then propose an ID that takes the identifier, inserts hyphens between each word in the identifier, removes any non-hyphen non-alphanumeric characters, and sets the remaining characters to lowercase. If a feature has a descriptive name, then propose an ID that replaces any spaces with hyphens, removes any non-alphanumeric characters, and sets the remaining characters to lowercase.
|
Thanks @ddbeck! One small benefit of the one word style I can see is that you could often tell from the identifier if something is named after code as opposed to CSS. But I don't love that identifiers will seem less consistent at first glance. In the hyphens style, how do you think we should treat Do you have a strong preference? |
As a minor point in favor of the hyphens style, @mfreed7 was quite reasonable assumed in https://chromium-review.googlesource.com/c/chromium/src/+/6495042 that |
In the hyphens style, I believe the rule would call for naming the features
Ugh, I guess we can either amend the guideline to say something like, "don't willfully ignore obvious word breaks that should exist" (getting |
(This has me wishing we had made the IDs more arbitrary. If I were starting this today, I'd probably have advocated for something goofy like |
We currently have a mix of two styles for features named after interfaces or methods.
All as one word:
CloseWatcher
→ "closewatcher"getHTML()
→ "gethtml"requestIdleCallback()
→ "requestidlecallback"Hyphenated:
EditContext
→ "edit-context"getComputedStyle()
→ "get-computed-style"requestVideoFrameCallback()
→ "request-video-frame-callback"I think we should bless one style.
The text was updated successfully, but these errors were encountered: