这很可能是源代码中未被注意到的错误(可能是通过使用搜索和替换?)。 React 接受以 - 字符结尾的元素名称,并通过 document.createElement() 像任何其他元素一样呈现给 DOM(有关简单示例,请参见此处:https://jsfiddle.net/nso3gjpw/)。由于浏览器对奇怪的 html 非常宽容,它只是将元素呈现为一个未知的自定义元素,其行为大致类似于 span 元素。 row- 和 col- 元素也有样式 (https://github.com/pusher/react-slack-clone/blob/master/src/index.css#L73)。
在 Blink 渲染引擎源代码中,给出了以下标签名称的定义(https://www.w3.org/TR/REC-xml/#NT-CombiningChar):
// DOM Level 2 says (letters added):
//
// a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
// b) Name characters other than Name-start characters must have one of the categories Mc, Me, Mn, Lm, or Nd.
// c) Characters in the compatibility area (i.e. with character code greater than #xF900 and less than #xFFFE) are not allowed in XML names.
// d) Characters which have a font or compatibility decomposition (i.e. those with a "compatibility formatting tag" in field 5 of the database -- marked by field 5 beginning with a "<") are not allowed.
// e) The following characters are treated as name-start characters rather than name characters, because the property file classifies them as Alphabetic: [#x02BB-#x02C1], #x0559, #x06E5, #x06E6.
// f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section 5.14).
// g) Character #x00B7 is classified as an extender, because the property list so identifies it.
// h) Character #x0387 is added as a name character, because #x00B7 is its canonical equivalent.
// i) Characters ':' and '_' are allowed as name-start characters.
// j) Characters '-' and '.' are allowed as name characters.
//
// It also contains complete tables. If we decide it's better, we could include those instead of the following code.
这里特别重要的是规则j) Characters '-' and '.' are allowed as name characters.