Web 组件(JavaScript 本机)命名限制?
Web components (JavaScript native) naming limitations?
我知道 Web 组件命名有以下限制:
- 不允许使用大写字母符号。
- 必须至少包含一个正破折号。
还有其他的吗?下划线、数字和其他符号呢?
这是 HTML 规范的完整规范:
有效的自定义元素名称是满足以下所有要求的字符名称序列:
name must match the PotentialCustomElementName production:
PotentialCustomElementName ::=
[a-z] (PCENChar)* '-' (PCENChar)*
PCENChar ::=
"-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] |
[#xD8-#xF6] | [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
[#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
[#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
[#x10000-#xEFFFF]
This uses the EBNF notation from the XML specification. [XML]
name must not be any of the following:
annotation-xml
color-profile
font-face
font-face-src
font-face-uri
font-face-format
font-face-name
missing-glyph
https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
我知道 Web 组件命名有以下限制:
- 不允许使用大写字母符号。
- 必须至少包含一个正破折号。
还有其他的吗?下划线、数字和其他符号呢?
这是 HTML 规范的完整规范:
有效的自定义元素名称是满足以下所有要求的字符名称序列:
name must match the PotentialCustomElementName production:
PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)* PCENChar ::= "-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
This uses the EBNF notation from the XML specification. [XML]
name must not be any of the following:
annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph
https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name