var skipArray = ['width', 'height'];
var _renderToString = function (root) {
  var str = '';
  if (root.nodeName !== 'body') {
    str += `<${root.nodeName}`;
    if (root.classList.length > 0) {
      str += ' class="';
      BI.each(root.classList, (i, cls) => {
        str += ` ${cls}`;
      });
      str += '"';
    }
    str += ' style="';
    BI.each(root.styles, (key, stl) => {
      if (skipArray.includes(key)) {
        return;
      }
      key = BI.hyphenate(key);
      str += ` ${key}:${stl};`;
    });
    str += ` width:${root.width}px;`;
    str += ` height:${root.height}px;`;
    str += ' position: fixed;';
    str += ` left: ${root.position.x}px;`;
    str += ` top: ${root.position.y}px;`;
    str += '"';
    BI.each(root.attribs, (key, attr) => {
      str += ` ${key}:${attr}`;
    });
    str += '>';
  }
  BI.each(root.children, (i, child) => {
    str += _renderToString(child);
  });
  // if (root.htmlContent) {
  //     str += root.htmlContent;
  // }
  if (root.nodeName !== 'body') {
    if (root.text) {
      str += root.text;
    }
    str += `</${root.nodeName}>`;
  }
  return str;
};
export const registRenderToStringFun = (Element) => {
  Element.registerFunction('renderToString', function () {
    return _renderToString(this);
  });
};