代码之家  ›  专栏  ›  技术社区  ›  bsr

不熟悉的html/react标记行、列-

  •  3
  • bsr  · 技术社区  · 6 年前

    看见 https://github.com/pusher/react-slack-clone/blob/master/src/index.js#L243

     <row->
                  <col->
       ....
                  </col->
    </row->
    

    为什么? - 在html标签之后?那它是如何被接受的标签呢?

    2 回复  |  直到 6 年前
        1
  •  0
  •   Johannes Reuter    6 年前

    这很可能是源代码中未被注意到的错误(可能是使用search&更换?)。React接受以 - document.createElement() 与任何其他元素一样(有关简单示例,请参见: 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.

        2
  •  3
  •   Josiah Nunemaker Sayed Ibrahim Hashimi    6 年前

    他们是 custom elements . 关于标记的有效性,您可能已经注意到代码中没有定义它。按照第5步 spec ,它是有效的,命名空间为 Element .

    有关自定义元素的更高级别概述,请查看 MDN tutorial

    另请注意: 这些标签可以用普通标签代替 <div>