热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

HTMLAttributeNamingConventionsforFastComponents

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.


推荐阅读
author-avatar
是不是有谁代替我陪在你身旁
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有