作者:是不是有谁代替我陪在你身旁 | 来源:互联网 | 2024-12-26 19:13
ThisdocumentoutlinestherecommendednamingconventionsforHTMLattributesinFastComponents,focusingonreadabilityandconsistencywithexistingstandards.
This discussion is based on the following GitHub pull request: microsoft/fast-dna#3015.
The goal is to establish a consistent convention for naming HTML attributes within the Fast Components framework. Two primary patterns are considered:
No Delineator (Lowercase Concatenation)
Native HTML attributes typically combine lowercase words without any separators. Examples include:
readonly
contenteditable
formaction
Advantages:
- Aligns closely with established HTML practices
- Simplifies attribute recognition and usage
Hyphen-Separated Words
Using hyphens between words is also valid in HTML, though less common compared to the no-delineator approach. Examples include:
- All
aria-
attributes - Custom
data-
attributes accept-charset
http-equiv
Advantages:
- Enhances readability
- Facilitates spell-checking
- Improves clarity for multi-word attributes
Note: CamelCase is not considered due to HTML's case-insensitive nature (reference).
Consensus has been reached on these conventions; however, new perspectives can be introduced if necessary.