首先看一下 goog.dom.htmlToDocumentFragment 的实现代码:

goog.dom.htmlToDocumentFragment_ = function(doc, htmlString) {
      var tempDiv = doc.createElement('div');
      if (goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) {
        tempDiv.innerHTML = '
        ' + htmlString;
        tempDiv.removeChild(tempDiv.firstChild);
      } else {
        tempDiv.innerHTML = htmlString;
      }
      if (tempDiv.childNodes.length == 1) {
        return /** @type {!Node} */ (tempDiv.removeChild(tempDiv.firstChild));
      } else {
        var fragment = doc.createDocumentFragment();
        while (tempDiv.firstChild) {
          fragment.appendChild(tempDiv.firstChild);
        }
        return fragment;
      }
    };

这个方法利用一个临时 Div 容器来生成 Dom 片段,因为<tr>标签本身不能在<div>标签内使用,所以这个函数不能返回单独地<tr>标签。